Skip to content

Commit

Permalink
fix(TikTok - Settings): Prevent crash by fixing invalid patch
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Sep 21, 2024
1 parent 82d53cb commit 8074032
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
dependencies = [IntegrationsPatch::class],
compatiblePackages = [
CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]),
CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"])
]
CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]),
],
)
object SettingsPatch : BytecodePatch(
setOf(
AdPersonalizationActivityOnCreateFingerprint,
AddSettingsEntryFingerprint,
SettingsEntryFingerprint,
SettingsEntryInfoFingerprint,
)
),
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/tiktok/settings/AdPersonalizationActivityHook;"

private const val INITIALIZE_SETTINGS_METHOD_DESCRIPTOR =
"$INTEGRATIONS_CLASS_DESCRIPTOR->initialize(" +
"Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;" +
")Z"
"Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;" +
")Z"

private const val CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR =
"$INTEGRATIONS_CLASS_DESCRIPTOR->createSettingsEntry(" +
"Ljava/lang/String;" +
"Ljava/lang/String;" +
")Ljava/lang/Object;"
"Ljava/lang/String;" +
"Ljava/lang/String;" +
")Ljava/lang/Object;"

override fun execute(context: BytecodeContext) {
// Find the class name of classes which construct a settings entry
Expand All @@ -70,8 +70,8 @@ object SettingsPatch : BytecodePatch(
markIndex + 2,
listOf(
getUnitManager,
addEntry
)
addEntry,
),
)

addInstructions(
Expand All @@ -81,7 +81,8 @@ object SettingsPatch : BytecodePatch(
const-string v1, "$settingsButtonInfoClass"
invoke-static {v0, v1}, $CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR
move-result-object v0
"""
check-cast v0, ${SettingsEntryFingerprint.result!!.classDef}
""",
)
} ?: throw AddSettingsEntryFingerprint.exception

Expand All @@ -102,12 +103,10 @@ object SettingsPatch : BytecodePatch(
if-eqz v$usableRegister, :do_not_open
return-void
""",
ExternalLabel("do_not_open", getInstruction(initializeSettingsIndex))
ExternalLabel("do_not_open", getInstruction(initializeSettingsIndex)),
)
} ?: throw AdPersonalizationActivityOnCreateFingerprint.exception
}

private fun String.toClassName(): String {
return substring(1, this.length - 1).replace("/", ".")
}
}
private fun String.toClassName(): String = substring(1, this.length - 1).replace("/", ".")
}

0 comments on commit 8074032

Please sign in to comment.