From 96cdc102dd64e3134ec0ac5cc22c956b80c95e0b Mon Sep 17 00:00:00 2001 From: d4rkk3y <43563783+d4rkk3y@users.noreply.github.com> Date: Tue, 12 Dec 2023 07:07:01 +0700 Subject: [PATCH] feat(Tiktok): Bump compatibility to `32.5.3` (#3389) BREAKING CHANGE: This removes a patch but consolidates it into another. --- api/revanced-patches.api | 6 - .../patches/tiktok/ad/HideAdsPatch.kt | 51 ------ .../ConvertHelpFeedItemListFingerprint.kt | 10 -- .../FeedItemListCloneFingerprint.kt | 9 - .../tiktok/feedfilter/FeedFilterPatch.kt | 32 ++-- .../FeedApiServiceLIZFingerprint.kt | 5 +- .../interaction/downloads/DownloadsPatch.kt | 161 +++++++++--------- .../DownloadPathParentFingerprint.kt | 19 ++- .../interaction/speed/PlaybackSpeedPatch.kt | 28 +-- .../SpeedControlParentFingerprint.kt | 9 +- .../tiktok/misc/settings/SettingsPatch.kt | 61 +++---- .../AddSettingsEntryFingerprint.kt | 14 +- .../tiktok/misc/spoof/sim/SpoofSimPatch.kt | 10 +- 13 files changed, 170 insertions(+), 245 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/tiktok/ad/HideAdsPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 1bc81b63c..d84d9dc46 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -814,12 +814,6 @@ public final class app/revanced/patches/ticktick/misc/themeunlock/UnlockProPatch public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/tiktok/ad/HideAdsPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/tiktok/ad/HideAdsPatch; - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V -} - public final class app/revanced/patches/tiktok/feedfilter/FeedFilterPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/tiktok/feedfilter/FeedFilterPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/HideAdsPatch.kt deleted file mode 100644 index bf6403f65..000000000 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/HideAdsPatch.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.revanced.patches.tiktok.ad - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.tiktok.ad.fingerprints.ConvertHelpFeedItemListFingerprint -import app.revanced.patches.tiktok.ad.fingerprints.FeedItemListCloneFingerprint -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference - -@Patch( - name = "Hide ads", - compatiblePackages = [ - CompatiblePackage("com.ss.android.ugc.trill", ["30.8.4"]), - CompatiblePackage("com.zhiliaoapp.musically", ["30.8.4"]) - ] -) -@Suppress("unused") -object HideAdsPatch : BytecodePatch( - setOf(FeedItemListCloneFingerprint, ConvertHelpFeedItemListFingerprint) -) { - override fun execute(context: BytecodeContext) { - listOf( - FeedItemListCloneFingerprint, - ConvertHelpFeedItemListFingerprint - ).forEach { fingerprint -> - val method = fingerprint.result!!.mutableMethod - // iterate all instructions in the clone method - for ((index, instruction) in method.implementation!!.instructions.withIndex()) { - // conditions for the instruction we need - if (instruction.opcode.ordinal != Opcode.IPUT_OBJECT.ordinal) continue - val preloadAdsFieldInstruction = (instruction as? ReferenceInstruction) - if ((preloadAdsFieldInstruction?.reference as? FieldReference)?.name != "preloadAds") continue - - // set null instead of the field "preloadAds" - val overrideRegister = (preloadAdsFieldInstruction as TwoRegisterInstruction).registerA - method.addInstruction( - index, - "const/4 v$overrideRegister, 0x0" - ) - return@forEach - } - throw PatchException("Can not find required instruction.") - } - } -} diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt deleted file mode 100644 index 9fab703ff..000000000 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.tiktok.ad.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -internal object ConvertHelpFeedItemListFingerprint : MethodFingerprint( - customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/ConvertHelp;") && - methodDef.name.endsWith("${'$'}FeedItemList") - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt deleted file mode 100644 index 181b88d71..000000000 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.tiktok.ad.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -internal object FeedItemListCloneFingerprint : MethodFingerprint( - customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/FeedItemList;") && methodDef.name == "clone" - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt index ea5d855e7..01f7c2f8a 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt @@ -1,8 +1,8 @@ package app.revanced.patches.tiktok.feedfilter -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch @@ -10,31 +10,35 @@ import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFing import app.revanced.patches.tiktok.misc.integrations.IntegrationsPatch import app.revanced.patches.tiktok.misc.settings.SettingsPatch import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Feed filter", - description = "Filters tiktok videos: removing ads, removing livestreams.", + description = "Removes ads, livestreams, stories, image videos " + + "and videos with a specific amount of views or likes from the feed.", dependencies = [IntegrationsPatch::class, SettingsPatch::class], compatiblePackages = [ - CompatiblePackage("com.ss.android.ugc.trill"), - CompatiblePackage("com.zhiliaoapp.musically") + CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]), + CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]) ] ) @Suppress("unused") -object FeedFilterPatch : BytecodePatch(setOf(FeedApiServiceLIZFingerprint, SettingsStatusLoadFingerprint)) { +object FeedFilterPatch : BytecodePatch( + setOf(FeedApiServiceLIZFingerprint, SettingsStatusLoadFingerprint) +) { override fun execute(context: BytecodeContext) { - val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod - for ((index, instruction) in method.implementation!!.instructions.withIndex()) { - if (instruction.opcode != Opcode.RETURN_OBJECT) continue - val feedItemsRegister = (instruction as OneRegisterInstruction).registerA - method.addInstruction( - index, - "invoke-static {v$feedItemsRegister}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V" + FeedApiServiceLIZFingerprint.result?.mutableMethod?.apply { + val returnFeedItemInstruction = getInstructions().first { it.opcode == Opcode.RETURN_OBJECT } + val feedItemsRegister = (returnFeedItemInstruction as OneRegisterInstruction).registerA + + addInstruction( + returnFeedItemInstruction.location.index, + "invoke-static { v$feedItemsRegister }, " + + "Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V" ) - break - } + } ?: throw FeedApiServiceLIZFingerprint.exception SettingsStatusLoadFingerprint.result?.mutableMethod?.addInstruction( 0, diff --git a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt index 1084d67ea..1872ea485 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt @@ -1,12 +1,9 @@ package app.revanced.patches.tiktok.feedfilter.fingerprints -import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags internal object FeedApiServiceLIZFingerprint : MethodFingerprint( - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.SYNTHETIC, customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/FeedApiService;") && methodDef.name == "LIZ" + methodDef.definingClass.endsWith("/FeedApiService;") && methodDef.name == "fetchFeedList" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt index 21add8cc3..afb088929 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt @@ -4,10 +4,9 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions +import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod @@ -18,18 +17,19 @@ import app.revanced.patches.tiktok.interaction.downloads.fingerprints.DownloadPa import app.revanced.patches.tiktok.misc.integrations.IntegrationsPatch import app.revanced.patches.tiktok.misc.settings.SettingsPatch import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint +import app.revanced.util.exception +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference +import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c +import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Patch( name = "Downloads", description = "Removes download restrictions and changes the default path to download to.", dependencies = [IntegrationsPatch::class, SettingsPatch::class], compatiblePackages = [ - CompatiblePackage("com.ss.android.ugc.trill", ["30.8.4"]), - CompatiblePackage("com.zhiliaoapp.musically", ["30.8.4"]) + CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]), + CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]) ] ) @Suppress("unused") @@ -43,86 +43,83 @@ object DownloadsPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext) { - val method1 = ACLCommonShareFingerprint.result!!.mutableMethod - method1.replaceInstructions( - 0, - """ - const/4 v0, 0x0 - return v0 - """ - ) - val method2 = ACLCommonShareFingerprint2.result!!.mutableMethod - method2.replaceInstructions( - 0, - """ - const/4 v0, 0x2 - return v0 - """ - ) - //Download videos without watermark. - val method3 = ACLCommonShareFingerprint3.result!!.mutableMethod - method3.addInstructionsWithLabels( - 0, - """ - invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->shouldRemoveWatermark()Z - move-result v0 - if-eqz v0, :noremovewatermark - const/4 v0, 0x1 - return v0 - :noremovewatermark - nop - """ - ) - //Change the download path patch - val method4 = DownloadPathParentFingerprint.result!!.mutableMethod - val implementation4 = method4.implementation - val instructions = implementation4!!.instructions - var targetOffset = -1 - //Search for the target method called instruction offset. - for ((index, instruction) in instructions.withIndex()) { - if (instruction.opcode != Opcode.CONST_STRING) continue - val reference = (instruction as ReferenceInstruction).reference as StringReference - if (reference.string != "video/mp4") continue - val targetInstruction = instructions[index + 1] - if (targetInstruction.opcode != Opcode.INVOKE_STATIC) continue - targetOffset = index + 1 - break - } - if (targetOffset == -1) throw PatchException("Can not find download path uri method.") - //Change videos' download path. - val downloadUriMethod = context - .toMethodWalker(DownloadPathParentFingerprint.result!!.method) - .nextMethod(targetOffset, true) - .getMethod() as MutableMethod - downloadUriMethod.implementation!!.instructions.forEachIndexed { index, instruction -> - if (instruction.opcode == Opcode.SGET_OBJECT) { - val overrideRegister = (instruction as OneRegisterInstruction).registerA - downloadUriMethod.addInstructions( - index + 1, + fun MethodFingerprint.getMethod() = result?.mutableMethod ?: throw exception + + mapOf Unit>( + ACLCommonShareFingerprint to { + replaceInstructions( + 0, """ - invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->getDownloadPath()Ljava/lang/String; - move-result-object v$overrideRegister + const/4 v0, 0x0 + return v0 """ ) - } - if (instruction.opcode == Opcode.CONST_STRING) { - val string = ((instruction as ReferenceInstruction).reference as StringReference).string - if (string.contains("/Camera")) { - val overrideRegister = (instruction as OneRegisterInstruction).registerA - val overrideString = string.replace("/Camera", "") - downloadUriMethod.replaceInstruction( - index, - """ - const-string v$overrideRegister, "$overrideString" - """ + }, + ACLCommonShareFingerprint2 to { + replaceInstructions( + 0, + """ + const/4 v0, 0x2 + return v0 + """ + ) + }, + // Download videos without watermark. + ACLCommonShareFingerprint3 to { + addInstructionsWithLabels( + 0, + """ + invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->shouldRemoveWatermark()Z + move-result v0 + if-eqz v0, :noremovewatermark + const/4 v0, 0x1 + return v0 + :noremovewatermark + nop + """ + ) + }, + // Change the download path patch. + DownloadPathParentFingerprint to { + val targetIndex = indexOfFirstInstruction { opcode == Opcode.INVOKE_STATIC } + val downloadUriMethod = context + .toMethodWalker(this) + .nextMethod(targetIndex, true) + .getMethod() as MutableMethod + + val firstIndex = downloadUriMethod.indexOfFirstInstruction { + opcode == Opcode.INVOKE_DIRECT && ((this as Instruction35c).reference as MethodReference).name == "" + } + val secondIndex = downloadUriMethod.indexOfFirstInstruction { + opcode == Opcode.INVOKE_STATIC && ((this as Instruction35c).reference as MethodReference).returnType.contains( + "Uri" ) } + + downloadUriMethod.addInstructions( + secondIndex, + """ + invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->getDownloadPath()Ljava/lang/String; + move-result-object v0 + """ + ) + + downloadUriMethod.addInstructions( + firstIndex, + """ + invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->getDownloadPath()Ljava/lang/String; + move-result-object v0 + """ + ) + }, + SettingsStatusLoadFingerprint to { + addInstruction( + 0, + "invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableDownload()V" + ) } + ).forEach { (fingerprint, patch) -> + fingerprint.getMethod().patch() } - val method5 = SettingsStatusLoadFingerprint.result!!.mutableMethod - method5.addInstruction( - 0, - "invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableDownload()V" - ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt index 150e70bea..53f41dc20 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt @@ -3,13 +3,22 @@ package app.revanced.patches.tiktok.interaction.downloads.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode internal object DownloadPathParentFingerprint : MethodFingerprint( - "V", - AccessFlags.PUBLIC or AccessFlags.FINAL, + "L", + AccessFlags.PUBLIC or AccessFlags.STATIC, strings = listOf( - "code", - "reason", - "params insufficient" + "video/mp4" + ), + parameters = listOf( + "L", + "L" + ), + opcodes = listOf( + Opcode.CONST_STRING, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.RETURN_OBJECT ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt index dbde0bb50..3f7c17e7b 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt @@ -7,27 +7,36 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.tiktok.interaction.speed.fingerprints.SpeedControlParentFingerprint +import app.revanced.util.exception +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c +import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Patch( name = "Playback speed", description = "Enables the playback speed option for all videos.", compatiblePackages = [ - CompatiblePackage("com.ss.android.ugc.trill"), - CompatiblePackage("com.zhiliaoapp.musically") + CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]), + CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]) ] ) @Suppress("unused") object PlaybackSpeedPatch : BytecodePatch(setOf(SpeedControlParentFingerprint)) { override fun execute(context: BytecodeContext) { - val parentMethod = SpeedControlParentFingerprint.result!!.mutableMethod - val parentMethodInstructions = parentMethod.implementation!!.instructions - for ((index, instruction) in parentMethodInstructions.withIndex()) { - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue + SpeedControlParentFingerprint.result?.mutableMethod?.apply { + val targetMethodCallIndex = indexOfFirstInstruction { + if (opcode == Opcode.INVOKE_STATIC) { + val paramsTypes = ((this as Instruction35c).reference as MethodReference).parameterTypes + paramsTypes.size == 1 && paramsTypes[0].contains("/Aweme;") + } else false + } + val isSpeedEnableMethod = context - .toMethodWalker(parentMethod) - .nextMethod(index, true) + .toMethodWalker(this) + .nextMethod(targetMethodCallIndex, true) .getMethod() as MutableMethod + isSpeedEnableMethod.addInstructions( 0, """ @@ -35,7 +44,6 @@ object PlaybackSpeedPatch : BytecodePatch(setOf(SpeedControlParentFingerprint)) return v0 """ ) - break - } + } ?: throw SpeedControlParentFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt index 61159b029..7edae32e1 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt @@ -5,12 +5,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags internal object SpeedControlParentFingerprint : MethodFingerprint( - returnType = "L", - accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, - parameters = listOf( - "L" - ), strings = listOf( - "playback_speed" + "onStopTrackingTouch, hasTouchMove=", + ", isCurVideoPaused: ", + "already_shown_edge_speed_guide" ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt index 9c4e37d93..d5980924d 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.tiktok.misc.settings -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -14,17 +13,19 @@ import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationA import app.revanced.patches.tiktok.misc.settings.fingerprints.AddSettingsEntryFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsEntryFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsEntryInfoFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c +import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c +import com.android.tools.smali.dexlib2.iface.reference.FieldReference @Patch( name = "Settings", description = "Adds ReVanced settings to TikTok.", dependencies = [IntegrationsPatch::class], compatiblePackages = [ - CompatiblePackage("com.ss.android.ugc.trill", ["30.8.4"]), - CompatiblePackage("com.zhiliaoapp.musically", ["30.8.4"]) + CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]), + CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]) ] ) object SettingsPatch : BytecodePatch( @@ -57,31 +58,31 @@ object SettingsPatch : BytecodePatch( ?: throw SettingsEntryInfoFingerprint.exception // Create a settings entry for 'revanced settings' and add it to settings fragment - AddSettingsEntryFingerprint.result?.apply { - scanResult.patternScanResult?.startIndex?.let { - val settingsEntries = mutableMethod.getInstruction(it + 3) - val addEntry = mutableMethod.getInstruction(it + 5) - val register1 = addEntry.registerC - val register2 = addEntry.registerD - // Add the settings entry created to the settings fragment - mutableMethod.addInstructions( - it + 6, - listOf( - settingsEntries, - addEntry - ) - ) - // These instructions call a method that create a settings entry use reflection base on the class name of classes that construct settings entry - mutableMethod.addInstructions( - it + 6, - """ - const-string v$register1, "$settingsButtonClass" - const-string v$register2, "$settingsButtonInfoClass" - invoke-static {v$register1, v$register2}, $CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR - move-result-object v$register2 - """ - ) + AddSettingsEntryFingerprint.result?.mutableMethod?.apply { + val markIndex = implementation!!.instructions.indexOfFirst { + it.opcode == Opcode.IGET_OBJECT && ((it as Instruction22c).reference as FieldReference).name == "headerUnit" } + + val getUnitManager = getInstruction(markIndex + 2) + val addEntry = getInstruction(markIndex + 1) + + addInstructions( + markIndex + 2, + listOf( + getUnitManager, + addEntry + ) + ) + + addInstructions( + markIndex + 2, + """ + const-string v0, "$settingsButtonClass" + const-string v1, "$settingsButtonInfoClass" + invoke-static {v0, v1}, $CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR + move-result-object v0 + """ + ) } ?: throw AddSettingsEntryFingerprint.exception // Initialize the settings menu once the replaced setting entry is clicked. @@ -98,10 +99,10 @@ object SettingsPatch : BytecodePatch( """ invoke-static {v$thisRegister}, $INITIALIZE_SETTINGS_METHOD_DESCRIPTOR move-result v$usableRegister - if-eqz v$usableRegister, :notrevanced + if-eqz v$usableRegister, :do_not_open return-void """, - ExternalLabel("notrevanced", getInstruction(initializeSettingsIndex)) + ExternalLabel("do_not_open", getInstruction(initializeSettingsIndex)) ) } ?: throw AdPersonalizationActivityOnCreateFingerprint.exception } diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AddSettingsEntryFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AddSettingsEntryFingerprint.kt index ce1fd7785..be2a1fc31 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AddSettingsEntryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AddSettingsEntryFingerprint.kt @@ -1,22 +1,10 @@ package app.revanced.patches.tiktok.misc.settings.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode internal object AddSettingsEntryFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.CONST_CLASS, - Opcode.APUT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - ), customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/SettingNewVersionFragment;") && - methodDef.name == "onViewCreated" + methodDef.name == "initUnitManger" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt index 4434575c7..137347aab 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.tiktok.misc.spoof.sim -import app.revanced.util.findMutableMethodOf import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -10,8 +9,9 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.tiktok.misc.integrations.IntegrationsPatch -import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint import app.revanced.patches.tiktok.misc.settings.SettingsPatch +import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint +import app.revanced.util.findMutableMethodOf import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c @@ -39,7 +39,7 @@ object SpoofSimPatch : BytecodePatch() { ) override fun execute(context: BytecodeContext) { - // Find all api call to check sim information + // Find all api call to check sim information. buildMap { context.classes.forEach { classDef -> classDef.methods.let { methods -> @@ -81,7 +81,7 @@ object SpoofSimPatch : BytecodePatch() { } } - // Enable patch in settings + // Enable patch in settings. with(SettingsStatusLoadFingerprint.result!!.mutableMethod) { addInstruction( 0, @@ -90,7 +90,7 @@ object SpoofSimPatch : BytecodePatch() { } } - // Patch Android API and return fake sim information + // Patch Android API and return fake sim information. private fun MutableMethod.replaceReference(index: Int, replacement: String) { val resultReg = getInstruction(index + 1).registerA