fix(TikTok - Show seekbar): fix seekbar not always showing (#2660)

This commit is contained in:
Vu Hoan Huy 2023-07-19 19:55:17 +07:00 committed by GitHub
parent 2edb923548
commit f2742f1ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 33 deletions

View File

@ -1,12 +0,0 @@
package app.revanced.patches.tiktok.interaction.seekbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object AwemeGetVideoControlFingerprint : MethodFingerprint(
"L",
AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/Aweme;") && methodDef.name == "getVideoControl"
}
)

View File

@ -0,0 +1,9 @@
package app.revanced.patches.tiktok.interaction.seekbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SetSeekBarShowTypeFingerprint : MethodFingerprint(
strings = listOf(
"seekbar show type change, change to:"
),
)

View File

@ -6,17 +6,14 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCompatibility
import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.AwemeGetVideoControlFingerprint
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction11n
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.SetSeekBarShowTypeFingerprint
import org.jf.dexlib2.iface.instruction.formats.Instruction22t
@Patch
@Name("Show seekbar")
@ -25,27 +22,20 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
@Version("0.0.1")
class ShowSeekbarPatch : BytecodePatch(
listOf(
AwemeGetVideoControlFingerprint
SetSeekBarShowTypeFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
//Get VideoControl FieldReference
val videoControl = context.findClass { it.type.endsWith("/VideoControl;") }
?: return PatchResultError("Can not find target class")
val fieldList = videoControl.immutableClass.fields.associateBy { field -> field.name }
SetSeekBarShowTypeFingerprint.result?.mutableMethod?.apply {
val typeRegister = getInstruction<Instruction22t>(1).registerB
AwemeGetVideoControlFingerprint.result?.mutableMethod?.implementation?.apply {
val ifNullLabel = newLabelForIndex(1)
addInstructions(
1,
listOf(
BuilderInstruction11n(Opcode.CONST_4, 1, 1),
BuilderInstruction21t(Opcode.IF_EQZ, 0, ifNullLabel),
BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["showProgressBar"]!!),
BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["draftProgressBar"]!!)
)
0,
"""
const/16 v$typeRegister, 0x64
"""
)
} ?: return AwemeGetVideoControlFingerprint.toErrorResult()
} ?: return SetSeekBarShowTypeFingerprint.toErrorResult()
return PatchResultSuccess()
}