mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-30 22:54:40 +02:00
chore: Fix merge typo, refactor
This commit is contained in:
parent
b91e932e65
commit
02e9f78b88
@ -12,12 +12,14 @@ import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater
|
|||||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||||
|
import app.revanced.util.findInstructionIndicesReversed
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;"
|
internal const val EXTENSION_METHOD_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;->isSlideToSeekDisabled(Z)Z"
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val enableSlideToSeekPatch = bytecodePatch(
|
val enableSlideToSeekPatch = bytecodePatch(
|
||||||
@ -59,51 +61,35 @@ val enableSlideToSeekPatch = bytecodePatch(
|
|||||||
var modifiedMethods = false
|
var modifiedMethods = false
|
||||||
|
|
||||||
// Restore the behaviour to slide to seek.
|
// Restore the behaviour to slide to seek.
|
||||||
val checkIndex =
|
val checkIndex = slideToSeekMatch.patternMatch!!.startIndex
|
||||||
slideToSeekMatch.patternMatch!!.startIndex
|
val checkReference = slideToSeekMatch.mutableMethod.getInstruction(checkIndex)
|
||||||
val checkReference =
|
.getReference<MethodReference>()!!
|
||||||
slideToSeekMatch.mutableMethod.getInstruction(checkIndex).getReference<MethodReference>()!!
|
|
||||||
|
|
||||||
// A/B check method was only called on this class.
|
// A/B check method was only called on this class.
|
||||||
slideToSeekMatch.mutableClass.methods.forEach { method ->
|
slideToSeekMatch.mutableClass.methods.forEach { method ->
|
||||||
method.implementation!!.instructions.forEachIndexed { index, instruction ->
|
method.findInstructionIndicesReversed {
|
||||||
if (instruction.opcode == Opcode.INVOKE_VIRTUAL &&
|
opcode == Opcode.INVOKE_VIRTUAL && getReference<MethodReference>() == checkReference
|
||||||
instruction.getReference<MethodReference>() == checkReference
|
}.forEach { index ->
|
||||||
) {
|
|
||||||
method.apply {
|
method.apply {
|
||||||
val targetRegister = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
index + 2,
|
index + 2,
|
||||||
"""
|
"""
|
||||||
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR
|
invoke-static { v$register }, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
move-result v$targetRegister
|
move-result v$register
|
||||||
""",
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
modifiedMethods = true
|
modifiedMethods = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!modifiedMethods) throw PatchException("Could not find methods to modify")
|
if (!modifiedMethods) throw PatchException("Could not find methods to modify")
|
||||||
|
|
||||||
// Disable the double speed seek gesture.
|
// Disable the double speed seek gesture.
|
||||||
if (!is_19_17_or_greater) {
|
if (is_19_17_or_greater) {
|
||||||
disableFastForwardLegacyMatch.mutableMethod.apply {
|
|
||||||
val insertIndex = disableFastForwardLegacyMatch.patternMatch!!.endIndex + 1
|
|
||||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
|
||||||
insertIndex,
|
|
||||||
"""
|
|
||||||
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR
|
|
||||||
move-result v$targetRegister
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
disableFastForwardGestureMatch,
|
disableFastForwardGestureMatch,
|
||||||
disableFastForwardNoticeMatch,
|
disableFastForwardNoticeMatch,
|
||||||
@ -115,12 +101,27 @@ val enableSlideToSeekPatch = bytecodePatch(
|
|||||||
addInstructions(
|
addInstructions(
|
||||||
targetIndex + 1,
|
targetIndex + 1,
|
||||||
"""
|
"""
|
||||||
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR
|
invoke-static { v$targetRegister }, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
move-result v$targetRegister
|
move-result v$targetRegister
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
disableFastForwardLegacyMatch.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val insertIndex = it.patternMatch!!.endIndex + 1
|
||||||
|
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
invoke-static { v$targetRegister }, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
|
move-result v$targetRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,10 @@ internal val disableFastForwardNoticeFingerprint = fingerprint {
|
|||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT,
|
Opcode.MOVE_RESULT,
|
||||||
)
|
)
|
||||||
strings("Failed to easy seek haptics vibrate")
|
strings("search_landing_cache_key", "batterymanager")
|
||||||
|
custom { method, _ ->
|
||||||
|
method.name == "run"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val onTouchEventHandlerFingerprint = fingerprint(fuzzyPatternScanThreshold = 3) {
|
internal val onTouchEventHandlerFingerprint = fingerprint(fuzzyPatternScanThreshold = 3) {
|
||||||
@ -107,7 +110,7 @@ internal val seekbarTappingFingerprint = fingerprint {
|
|||||||
|
|
||||||
internal val slideToSeekFingerprint = fingerprint {
|
internal val slideToSeekFingerprint = fingerprint {
|
||||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
|
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
|
||||||
returns("Z")
|
returns("V")
|
||||||
parameters("Landroid/view/View;", "F")
|
parameters("Landroid/view/View;", "F")
|
||||||
opcodes(
|
opcodes(
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user