mirror of
https://github.com/revanced/revanced-patches
synced 2025-01-13 06:47:31 +01:00
fix(YouTube): Change fingerprints to support a wider range of target versions
This commit is contained in:
parent
979565e7b5
commit
8a09174def
@ -15,22 +15,16 @@ internal val onBackPressedFingerprint = fingerprint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val recyclerViewScrollingFingerprint = fingerprint {
|
internal val scrollPositionFingerprint = fingerprint {
|
||||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
|
accessFlags(AccessFlags.PROTECTED, AccessFlags.FINAL)
|
||||||
returns("V")
|
returns("V")
|
||||||
parameters()
|
parameters("L")
|
||||||
opcodes(
|
opcodes(
|
||||||
Opcode.IGET_OBJECT,
|
Opcode.IF_NEZ,
|
||||||
Opcode.IGET_OBJECT,
|
Opcode.INVOKE_DIRECT,
|
||||||
Opcode.IF_EQZ,
|
Opcode.RETURN_VOID
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.CHECK_CAST,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IF_LEZ,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.CONST_4,
|
|
||||||
)
|
)
|
||||||
|
strings("scroll_position")
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val recyclerViewTopScrollingFingerprint = fingerprint {
|
internal val recyclerViewTopScrollingFingerprint = fingerprint {
|
||||||
|
@ -1,54 +1,49 @@
|
|||||||
package app.revanced.patches.youtube.misc.fix.backtoexitgesture
|
package app.revanced.patches.youtube.misc.fix.backtoexitgesture
|
||||||
|
|
||||||
import app.revanced.patcher.Fingerprint
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
|
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/FixBackToExitGesturePatch;"
|
||||||
|
|
||||||
internal val fixBackToExitGesturePatch = bytecodePatch(
|
internal val fixBackToExitGesturePatch = bytecodePatch(
|
||||||
description = "Fixes the swipe back to exit gesture.",
|
description = "Fixes the swipe back to exit gesture.",
|
||||||
) {
|
) {
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
/**
|
recyclerViewTopScrollingFingerprint.match(recyclerViewTopScrollingParentFingerprint.originalClassDef)
|
||||||
* Inject a call to a method from the extension.
|
.let {
|
||||||
*
|
it.method.addInstruction(
|
||||||
* @param targetMethod The target method to call.
|
it.patternMatch!!.endIndex,
|
||||||
*/
|
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->onTopView()V"
|
||||||
fun Fingerprint.injectCall(targetMethod: ExtensionMethod) = method.addInstruction(
|
|
||||||
patternMatch!!.endIndex,
|
|
||||||
targetMethod.toString(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
mapOf(
|
|
||||||
recyclerViewTopScrollingFingerprint.also {
|
|
||||||
it.match(recyclerViewTopScrollingParentFingerprint.originalClassDef)
|
|
||||||
} to ExtensionMethod(
|
|
||||||
methodName = "onTopView",
|
|
||||||
),
|
|
||||||
recyclerViewScrollingFingerprint to ExtensionMethod(
|
|
||||||
methodName = "onScrollingViews",
|
|
||||||
),
|
|
||||||
onBackPressedFingerprint to ExtensionMethod(
|
|
||||||
"p0",
|
|
||||||
"onBackPressed",
|
|
||||||
"Landroid/app/Activity;",
|
|
||||||
),
|
|
||||||
).forEach { (fingerprint, target) -> fingerprint.injectCall(target) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
scrollPositionFingerprint.let {
|
||||||
* A reference to a method from the extension for [fixBackToExitGesturePatch].
|
navigate(it.originalMethod)
|
||||||
*
|
.to(it.patternMatch!!.startIndex + 1)
|
||||||
* @param register The method registers.
|
.stop().apply {
|
||||||
* @param methodName The method name.
|
val index = indexOfFirstInstructionOrThrow {
|
||||||
* @param parameterTypes The parameters of the method.
|
opcode == Opcode.INVOKE_VIRTUAL && getReference<MethodReference>()?.definingClass ==
|
||||||
*/
|
"Landroid/support/v7/widget/RecyclerView;"
|
||||||
private class ExtensionMethod(
|
}
|
||||||
val register: String = "",
|
|
||||||
val methodName: String,
|
addInstruction(
|
||||||
val parameterTypes: String = "",
|
index,
|
||||||
) {
|
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->onScrollingViews()V"
|
||||||
override fun toString() =
|
)
|
||||||
"invoke-static {$register}, Lapp/revanced/extension/youtube/patches/FixBackToExitGesturePatch;->$methodName($parameterTypes)V"
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onBackPressedFingerprint.let {
|
||||||
|
it.method.addInstruction(
|
||||||
|
it.patternMatch!!.endIndex,
|
||||||
|
"invoke-static { p0 }, $EXTENSION_CLASS_DESCRIPTOR->onBackPressed(Landroid/app/Activity;)V"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user