feat(YouTube): Support version 18.29.38
This commit is contained in:
-12
@@ -1,12 +0,0 @@
|
||||
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingResourcePatch
|
||||
import app.revanced.util.patch.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object AccessibilityPlayerProgressTimeFingerprint : LiteralValueFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
literal = EnableSeekbarTappingResourcePatch.accessibilityPlayerProgressTime
|
||||
)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
@FuzzyPatternScanMethod(3)
|
||||
object OnTouchEventHandlerFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.PUBLIC,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL, // oMethodReference
|
||||
Opcode.RETURN,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_BOOLEAN,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN,
|
||||
Opcode.INT_TO_FLOAT,
|
||||
Opcode.INT_TO_FLOAT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.RETURN,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.INVOKE_VIRTUAL, // pMethodReference
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "onTouchEvent" }
|
||||
)
|
||||
+17
-29
@@ -13,13 +13,15 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
|
||||
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AccessibilityPlayerProgressTimeFingerprint
|
||||
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.OnTouchEventHandlerFingerprint
|
||||
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, EnableSeekbarTappingResourcePatch::class])
|
||||
@@ -27,37 +29,23 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
@Description("Enables tap-to-seek on the seekbar of the video player.")
|
||||
@SeekbarTappingCompatibility
|
||||
class EnableSeekbarTappingPatch : BytecodePatch(
|
||||
listOf(AccessibilityPlayerProgressTimeFingerprint, SeekbarTappingFingerprint)
|
||||
listOf(OnTouchEventHandlerFingerprint, SeekbarTappingFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// Find the required methods to tap the seekbar.
|
||||
val seekbarTappingMethods =
|
||||
AccessibilityPlayerProgressTimeFingerprint.result?.classDef?.methods?.let { methods ->
|
||||
buildMap {
|
||||
// find the methods which tap the seekbar
|
||||
methods.forEach { method ->
|
||||
if (method.implementation == null) return@forEach
|
||||
val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let {
|
||||
val patternScanResult = it.scanResult.patternScanResult!!
|
||||
|
||||
val instructions = method.implementation!!.instructions
|
||||
fun getReference(index: Int) = it.mutableMethod.getInstruction<ReferenceInstruction>(index)
|
||||
.reference as MethodReference
|
||||
|
||||
// The method has more than 7 instructions.
|
||||
if (instructions.count() < 7) return@forEach
|
||||
|
||||
// The 7th instruction has the opcode CONST_4.
|
||||
val instruction = instructions.elementAt(6)
|
||||
if (instruction.opcode != Opcode.CONST_4) return@forEach
|
||||
|
||||
// the literal for this instruction has to be either 1 or 2.
|
||||
val literal = (instruction as NarrowLiteralInstruction).narrowLiteral
|
||||
|
||||
// Based on the literal, determine which method is which.
|
||||
if (literal == 1) this["P"] = method
|
||||
if (literal == 2) this["O"] = method
|
||||
}
|
||||
}
|
||||
buildMap {
|
||||
put("O", getReference(patternScanResult.endIndex))
|
||||
put("N", getReference(patternScanResult.startIndex))
|
||||
}
|
||||
}
|
||||
|
||||
seekbarTappingMethods ?: return AccessibilityPlayerProgressTimeFingerprint.toErrorResult()
|
||||
seekbarTappingMethods ?: return OnTouchEventHandlerFingerprint.toErrorResult()
|
||||
|
||||
SeekbarTappingFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
|
||||
@@ -68,11 +56,11 @@ class EnableSeekbarTappingPatch : BytecodePatch(
|
||||
val freeRegister = 0
|
||||
val xAxisRegister = 2
|
||||
|
||||
val pMethod = seekbarTappingMethods["P"]!!
|
||||
val oMethod = seekbarTappingMethods["O"]!!
|
||||
val nMethod = seekbarTappingMethods["N"]!!
|
||||
|
||||
fun Method.toInvokeInstructionString() =
|
||||
"invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $definingClass->$name(I)V"
|
||||
fun MethodReference.toInvokeInstructionString() =
|
||||
"invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $this"
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex,
|
||||
@@ -81,7 +69,7 @@ class EnableSeekbarTappingPatch : BytecodePatch(
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :disabled
|
||||
${oMethod.toInvokeInstructionString()}
|
||||
${pMethod.toInvokeInstructionString()}
|
||||
${nMethod.toInvokeInstructionString()}
|
||||
""",
|
||||
ExternalLabel("disabled", getInstruction(insertIndex))
|
||||
)
|
||||
|
||||
+1
-12
@@ -2,16 +2,14 @@ package app.revanced.patches.youtube.interaction.seekbar.patch
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@DependsOn([SettingsPatch::class])
|
||||
class EnableSeekbarTappingResourcePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
|
||||
@@ -22,15 +20,6 @@ class EnableSeekbarTappingResourcePatch : ResourcePatch {
|
||||
StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled")
|
||||
)
|
||||
)
|
||||
|
||||
accessibilityPlayerProgressTime = ResourceMappingPatch.resourceMappings.find {
|
||||
it.name == "accessibility_player_progress_time"
|
||||
}?.id ?: return PatchResultError("Failed to find required resource")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
var accessibilityPlayerProgressTime = -1L
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user