mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 09:34:37 +02:00
refactor: always-autorepeat
patch
This commit is contained in:
parent
835a14a2d5
commit
4eac4dd5a9
@ -3,18 +3,10 @@ package app.revanced.patches.youtube.button.autorepeat.fingerprints
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object AutoNavInformerFingerprint : MethodFingerprint(
|
||||
"Z",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
),
|
||||
returnType = "Z",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf(),
|
||||
customFingerprint = { it.definingClass.endsWith("WillAutonavInformer;") }
|
||||
)
|
@ -5,8 +5,8 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object AutoRepeatFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
listOf(),
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf(),
|
||||
customFingerprint = { methodDef -> methodDef.implementation!!.instructions.count() == 3 && methodDef.annotations.isEmpty()}
|
||||
)
|
@ -5,8 +5,8 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object AutoRepeatParentFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf(
|
||||
"play() called when the player wasn't loaded.",
|
||||
"play() blocked because Background Playability failed"
|
||||
|
@ -10,12 +10,12 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.button.autorepeat.fingerprints.AutoNavInformerFingerprint
|
||||
import app.revanced.patches.youtube.button.autorepeat.fingerprints.AutoRepeatFingerprint
|
||||
import app.revanced.patches.youtube.button.autorepeat.fingerprints.AutoRepeatParentFingerprint
|
||||
import app.revanced.patches.youtube.button.autorepeat.fingerprints.*
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.shared.util.integrations.Constants.VIDEO_PATH
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("always-autorepeat")
|
||||
@YouTubeCompatibility
|
||||
@ -27,30 +27,34 @@ class AutoRepeatPatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
with(AutoRepeatFingerprint.also {
|
||||
it.resolve(context, AutoRepeatParentFingerprint.result!!.classDef)
|
||||
}.result!!.mutableMethod) {
|
||||
addInstructions(
|
||||
AutoRepeatParentFingerprint.result?.classDef?.let { classDef ->
|
||||
AutoRepeatFingerprint.also {
|
||||
it.resolve(context, classDef)
|
||||
}.result?.mutableMethod?.let {
|
||||
it.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $VIDEO_PATH/VideoInformation;->videoEnded()Z
|
||||
move-result v0
|
||||
if-eqz v0, :noautorepeat
|
||||
return-void
|
||||
""", listOf(ExternalLabel("noautorepeat", instruction(0)))
|
||||
""", listOf(ExternalLabel("noautorepeat", it.instruction(0)))
|
||||
)
|
||||
}
|
||||
} ?: return AutoRepeatFingerprint.toErrorResult()
|
||||
} ?: return AutoRepeatParentFingerprint.toErrorResult()
|
||||
|
||||
with(AutoNavInformerFingerprint.result!!.mutableMethod) {
|
||||
addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $UTILS_PATH/EnableAutoRepeatPatch;->enableAutoRepeat()Z
|
||||
AutoNavInformerFingerprint.result?.mutableMethod?.let {
|
||||
with (it.implementation!!.instructions) {
|
||||
val index = this.size - 1 - 1
|
||||
val register = (this[index] as OneRegisterInstruction).registerA
|
||||
it.addInstructions(
|
||||
index + 1, """
|
||||
invoke-static {v$register}, $UTILS_PATH/EnableAutoRepeatPatch;->enableAutoRepeat(Z)Z
|
||||
move-result v0
|
||||
if-eqz v0, :hidden
|
||||
const/4 v0, 0x0
|
||||
return v0
|
||||
""", listOf(ExternalLabel("hidden", instruction(0)))
|
||||
"""
|
||||
)
|
||||
|
||||
}
|
||||
} ?: return AutoNavInformerFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user