feat(tiktok): bump compatibility to 29.3.4

This commit is contained in:
inotia00 2023-05-07 05:27:41 +09:00
parent 43d22014c7
commit 7f3f75dc44
9 changed files with 104 additions and 115 deletions

View File

@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[ [
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")), Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
Package("com.zhiliaoapp.musically", arrayOf("27.8.3")) Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
] ]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -1,12 +1,12 @@
package app.revanced.patches.tiktok.feedfilter.fingerprints package app.revanced.patches.tiktok.feedfilter.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode
object FeedApiServiceLIZFingerprint : MethodFingerprint( object FeedApiServiceLIZFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.SYNTHETIC, opcodes = listOf(
customFingerprint = { methodDef -> Opcode.RETURN_OBJECT,
methodDef.definingClass.endsWith("/FeedApiService;") && methodDef.name == "LIZ" Opcode.MOVE_EXCEPTION
} ),
customFingerprint = { it.definingClass.endsWith("/FeedApiService;") }
) )

View File

@ -1,5 +1,6 @@
package app.revanced.patches.tiktok.feedfilter.patch package app.revanced.patches.tiktok.feedfilter.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
@ -15,7 +16,6 @@ import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFing
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch @Patch
@ -31,21 +31,24 @@ class FeedFilterPatch : BytecodePatch(
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod
for ((index, instruction) in method.implementation!!.instructions.withIndex()) { FeedApiServiceLIZFingerprint.result?.let {
if (instruction.opcode != Opcode.RETURN_OBJECT) continue val index = it.scanResult.patternScanResult!!.startIndex
val feedItemsRegister = (instruction as OneRegisterInstruction).registerA
method.addInstruction( with (it.mutableMethod) {
val register = (this.implementation!!.instructions[index] as OneRegisterInstruction).registerA
addInstruction(
index, index,
"invoke-static {v$feedItemsRegister}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V" "invoke-static {v$register}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V"
) )
break
} }
val method2 = SettingsStatusLoadFingerprint.result!!.mutableMethod } ?: return FeedApiServiceLIZFingerprint.toErrorResult()
method2.addInstruction(
SettingsStatusLoadFingerprint.result?.mutableMethod?.addInstruction(
0, 0,
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V" "invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V"
) ) ?: return SettingsStatusLoadFingerprint.toErrorResult()
return PatchResultSuccess() return PatchResultSuccess()
} }
} }

View File

@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[ [
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")), Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
Package("com.zhiliaoapp.musically", arrayOf("27.8.3")) Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
] ]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[ [
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")), Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
Package("com.zhiliaoapp.musically", arrayOf("27.8.3")) Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
] ]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -0,0 +1,17 @@
package app.revanced.patches.tiktok.misc.settings.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object AboutPageFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_STRING
),
customFingerprint = {
it.definingClass == "Lcom/ss/android/ugc/aweme/setting/page/AboutPage;" &&
it.name == "onViewCreated"
}
)

View File

@ -1,37 +0,0 @@
package app.revanced.patches.tiktok.misc.settings.fingerprints
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
@FuzzyPatternScanMethod(4)
object AboutViewFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_DIRECT_RANGE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.NEW_INSTANCE,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.SGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.CONST_4,
Opcode.CONST_STRING,
Opcode.INVOKE_DIRECT_RANGE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.CONST,
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.CONST
)
)

View File

@ -8,23 +8,24 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
import app.revanced.patches.tiktok.misc.settings.fingerprints.AboutViewFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.AboutPageFingerprint
import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityOnCreateFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityOnCreateFingerprint
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsOnViewCreatedFingerprint import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsOnViewCreatedFingerprint
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c import org.jf.dexlib2.iface.instruction.formats.Instruction35c
import org.jf.dexlib2.iface.reference.StringReference
import org.jf.dexlib2.iface.reference.TypeReference import org.jf.dexlib2.iface.reference.TypeReference
@Patch @Patch
@ -35,77 +36,82 @@ import org.jf.dexlib2.iface.reference.TypeReference
@Version("0.0.1") @Version("0.0.1")
class SettingsPatch : BytecodePatch( class SettingsPatch : BytecodePatch(
listOf( listOf(
AboutPageFingerprint,
AdPersonalizationActivityOnCreateFingerprint, AdPersonalizationActivityOnCreateFingerprint,
SettingsOnViewCreatedFingerprint, SettingsOnViewCreatedFingerprint,
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
SettingsOnViewCreatedFingerprint.result?.let {
AboutViewFingerprint.resolve(context, it.method, it.classDef) AboutPageFingerprint.result?.let {
val startIndex = it.scanResult.patternScanResult!!.startIndex
with(it.mutableMethod.implementation!!.instructions) {
copyrightPolicyLabelId = (this[startIndex] as WideLiteralInstruction).wideLiteral
} }
// Patch Settings UI to add 'Revanced Settings'.
val targetIndexes = findOptionsOnClickIndex() } ?: return AboutPageFingerprint.toErrorResult()
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
for (index in targetIndexes) { SettingsOnViewCreatedFingerprint.result?.mutableMethod?.let { method ->
if ( val copyrightInstructions = method.implementation!!.instructions
instruction(index).opcode != Opcode.NEW_INSTANCE ||
instruction(index - 4).opcode != Opcode.MOVE_RESULT_OBJECT val copyrightIndex = copyrightInstructions.indexOfFirst {
) it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "copyright_policy"
} - 6
val copyrightPolicyIndex = copyrightInstructions.indexOfFirst {
it.opcode == Opcode.CONST &&
(it as WideLiteralInstruction).wideLiteral == copyrightPolicyLabelId
} + 2
arrayOf(
copyrightIndex,
copyrightPolicyIndex
).forEach {
if (method.instruction(it).opcode != Opcode.MOVE_RESULT_OBJECT)
return PatchResultError("Hardcode offset changed.") return PatchResultError("Hardcode offset changed.")
patchOptionNameAndOnClickEvent(index, context) val register = (method.instruction(it) as OneRegisterInstruction).registerA
method.insertSettings(context, it, register)
} }
}
// Implement settings screen in `AdPersonalizationActivity` } ?: return SettingsOnViewCreatedFingerprint.toErrorResult()
with(AdPersonalizationActivityOnCreateFingerprint.result!!.mutableMethod) {
for ((index, instruction) in implementation!!.instructions.withIndex()) { AdPersonalizationActivityOnCreateFingerprint.result?.mutableMethod?.let {
for ((index, instruction) in it.implementation!!.instructions.withIndex()) {
if (instruction.opcode != Opcode.INVOKE_SUPER) continue if (instruction.opcode != Opcode.INVOKE_SUPER) continue
val thisRegister = (instruction as Instruction35c).registerC val thisRegister = (instruction as Instruction35c).registerC
addInstructions( it.addInstructions(
index + 1, index + 1,
""" """
invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V
return-void return-void
""" """
) )
break
}
}
return PatchResultSuccess() return PatchResultSuccess()
} }
} ?: return AdPersonalizationActivityOnCreateFingerprint.toErrorResult()
private fun findOptionsOnClickIndex(): IntArray { return PatchResultError("Could not find the method to hook.")
val results = IntArray(2)
SettingsOnViewCreatedFingerprint.result?.apply {
for ((index, instruction) in mutableMethod.implementation!!.instructions.withIndex()) {
// Old UI settings option to replace to 'Revanced Settings'
if (instruction.opcode == Opcode.CONST_STRING) {
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
if (string == "copyright_policy") {
results[0] = index - 2
break
}
}
} }
// New UI settings option to replace to 'Revanced Settings' private companion object {
results[1] = AboutViewFingerprint.result!!.scanResult.patternScanResult!!.startIndex var copyrightPolicyLabelId: Long = -1
} ?: throw SettingsOnViewCreatedFingerprint.toErrorResult()
return results
}
private fun patchOptionNameAndOnClickEvent(index: Int, context: BytecodeContext) { fun MutableMethod.insertSettings(
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) { context: BytecodeContext,
// Patch option name index: Int,
val overrideRegister = (instruction(index - 4) as OneRegisterInstruction).registerA overrideRegister: Int
) {
replaceInstruction( replaceInstruction(
index - 4, index,
""" """
const-string v$overrideRegister, "Revanced Settings" const-string v$overrideRegister, "Revanced Settings"
""" """
) )
// Patch option OnClick Event with(((instruction(index + 4) as ReferenceInstruction).reference as TypeReference).type) {
with(((instruction(index) as ReferenceInstruction).reference as TypeReference).type) {
context.findClass(this)!!.mutableClass.methods.first { it.name == "onClick" } context.findClass(this)!!.mutableClass.methods.first { it.name == "onClick" }
.addInstructions( .addInstructions(
0, 0,

View File

@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[ [
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")), Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
Package("com.zhiliaoapp.musically", arrayOf("27.8.3")) Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
] ]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)