fix(YouTube - Swipe controls): Patch fails on YouTube 19.43.41 when Player components patch is included

This commit is contained in:
inotia00 2025-03-31 21:09:11 +09:00
parent 09a8eb7114
commit bccd6dc5df
2 changed files with 23 additions and 14 deletions

View File

@ -10,6 +10,7 @@ import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.or
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal val fullScreenEngagementOverlayFingerprint = legacyFingerprint(
@ -113,11 +114,17 @@ internal val playerGestureConfigSyntheticFingerprint = legacyFingerprint(
// This method is always called "a" because this kind of class always has a single method.
method.name == "a" &&
classDef.methods.count() == 2 &&
method.indexOfFirstInstruction {
indexOfPlayerConfigModelBooleanInstruction(method) >= 0
},
)
internal fun indexOfPlayerConfigModelBooleanInstruction(
method: Method,
startIndex: Int = 0
) = method.indexOfFirstInstruction(startIndex) {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_VIRTUAL &&
reference?.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;" &&
reference.parameterTypes.isEmpty() &&
reference.returnType == "Z"
} >= 0
},
)
}

View File

@ -30,7 +30,6 @@ import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.mutableClassOrThrow
import app.revanced.util.getReference
@ -212,14 +211,17 @@ val swipeControlsPatch = bytecodePatch(
// region patch for disable swipe to enter fullscreen mode (in the player) and disable swipe to exit fullscreen mode
playerGestureConfigSyntheticFingerprint.matchOrThrow().let {
val endIndex = it.patternMatch!!.endIndex
playerGestureConfigSyntheticFingerprint.methodOrThrow().apply {
val disableSwipeToExitFullscreenModeIndex =
indexOfPlayerConfigModelBooleanInstruction(this)
val disableSwipeToEnterFullscreenModeInThePlayerIndex =
indexOfPlayerConfigModelBooleanInstruction(this, disableSwipeToExitFullscreenModeIndex + 1)
mapOf(
3 to "disableSwipeToEnterFullscreenModeInThePlayer",
9 to "disableSwipeToExitFullscreenMode"
).forEach { (offSet, methodName) ->
it.getWalkerMethod(endIndex - offSet).apply {
disableSwipeToExitFullscreenModeIndex to "disableSwipeToExitFullscreenMode",
disableSwipeToEnterFullscreenModeInThePlayerIndex to "disableSwipeToEnterFullscreenModeInThePlayer"
).forEach { (walkerIndex, methodName) ->
getWalkerMethod(walkerIndex).apply {
val index = implementation!!.instructions.lastIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA