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