diff --git a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt index ed4e79c7f..a2a3f7043 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.music.misc.backgroundplayback.fingerprints.PodCastCo import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.util.getReference import app.revanced.util.getWalkerMethod -import app.revanced.util.indexOfFirstInstructionReversedOrThrow +import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstStringInstructionOrThrow import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.resultOrThrow @@ -52,8 +52,8 @@ object BackgroundPlaybackPatch : BaseBytecodePatch( // don't play music video MusicBrowserServiceFingerprint.resultOrThrow().let { it.mutableMethod.apply { - val stringIndex = MusicBrowserServiceFingerprint.indexOfMBSInstruction(this) - val targetIndex = indexOfFirstInstructionReversedOrThrow(stringIndex) { + val stringIndex = it.scanResult.stringsScanResult!!.matches.first().index + val targetIndex = indexOfFirstInstructionOrThrow(stringIndex) { val reference = getReference() opcode == Opcode.INVOKE_VIRTUAL && reference?.returnType == "Z" && diff --git a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/MusicBrowserServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/MusicBrowserServiceFingerprint.kt index 2823a0079..714e4fa05 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/MusicBrowserServiceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/MusicBrowserServiceFingerprint.kt @@ -2,28 +2,14 @@ package app.revanced.patches.music.misc.backgroundplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patches.music.misc.backgroundplayback.fingerprints.MusicBrowserServiceFingerprint.indexOfMBSInstruction -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstruction 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.StringReference internal object MusicBrowserServiceFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("Ljava/lang/String;", "Landroid/os/Bundle;"), - customFingerprint = custom@{ methodDef, _ -> - if (!methodDef.definingClass.endsWith("/MusicBrowserService;")) - return@custom false - - indexOfMBSInstruction(methodDef) >= 0 - } -) { - fun indexOfMBSInstruction(methodDef: Method) = - methodDef.indexOfFirstInstruction { - opcode == Opcode.CONST_STRING && - getReference()?.string?.startsWith("MBS: Return empty root for client: %s") == true - } -} \ No newline at end of file + strings = listOf("android.service.media.extra.RECENT"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("/MusicBrowserService;") + }, +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index db57d3732..3926a3abf 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -8,7 +8,6 @@ import app.revanced.patches.shared.mapping.ResourceMappingPatch.getId import app.revanced.patches.shared.mapping.ResourceType.BOOL import app.revanced.patches.shared.mapping.ResourceType.COLOR import app.revanced.patches.shared.mapping.ResourceType.DIMEN -import app.revanced.patches.shared.mapping.ResourceType.DRAWABLE import app.revanced.patches.shared.mapping.ResourceType.ID import app.revanced.patches.shared.mapping.ResourceType.LAYOUT import app.revanced.patches.shared.mapping.ResourceType.STRING diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt index b36448aaf..b1ea2546c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt @@ -9,6 +9,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * It appears this hook may no longer be needed as one of the constructor parameters is the already hooked * [EmbeddedPlayerControlsOverlayFingerprint] */ +@Deprecated("Fingerprint is obsolete and will be deleted soon") internal object APIPlayerServiceFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" }, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt index 31550f9b7..71d25eaf7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt @@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * Note: this fingerprint may no longer be needed, as it appears * [RemoteEmbedFragmentFingerprint] may be set before this hook is called. */ +@Deprecated("Fingerprint is obsolete and will be deleted soon") internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt index 0bd3994e5..0eee834b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt @@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * Note: this fingerprint may or may not be needed, as * [RemoteEmbedFragmentFingerprint] might be set before this is called. */ +@Deprecated("Fingerprint is obsolete and will be deleted soon") internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, returnType = "L", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt index 99a131a8a..e67934209 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt @@ -7,6 +7,7 @@ import com.android.tools.smali.dexlib2.AccessFlags /** * For embedded playback. Likely covers Google Play store and other Google products. */ +@Deprecated("Fingerprint is obsolete and will be deleted soon") internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt index 4313dfdc0..df47f1bfe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt @@ -7,6 +7,7 @@ import com.android.tools.smali.dexlib2.AccessFlags /** * For embedded playback inside 3rd party android app (such as 3rd party Reddit apps). */ +@Deprecated("Fingerprint is obsolete and will be deleted soon") internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt index 65d8819e7..632c6207a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/navigation/NavigationBarHookPatch.kt @@ -56,8 +56,7 @@ object NavigationBarHookPatch : BytecodePatch( private lateinit var navigationTabCreatedCallback: MutableMethod private lateinit var bottomBarContainerMethod: MutableMethod - private var bottomBarContainerIndex = 0 - private var bottomBarContainerRegister = 0 + private var bottomBarContainerOffset = 0 override fun execute(context: BytecodeContext) { fun MutableMethod.addHook(hook: Hook, insertPredicate: Instruction.() -> Boolean) { @@ -131,13 +130,8 @@ object NavigationBarHookPatch : BytecodePatch( "onBackPressed" ) - InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod.apply { - bottomBarContainerMethod = this - bottomBarContainerIndex = - InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this) - bottomBarContainerRegister = - getInstruction(bottomBarContainerIndex).registerC - } + bottomBarContainerMethod = + InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod } val hookNavigationButtonCreated: (String) -> Unit by lazy { @@ -152,11 +146,19 @@ object NavigationBarHookPatch : BytecodePatch( } } - fun addBottomBarContainerHook(descriptor: String) = - bottomBarContainerMethod.addInstruction( - bottomBarContainerIndex, - "invoke-static { v$bottomBarContainerRegister }, $descriptor" - ) + fun addBottomBarContainerHook(descriptor: String) { + bottomBarContainerMethod.apply { + val layoutChangeListenerIndex = + InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this) + val bottomBarContainerRegister = + getInstruction(layoutChangeListenerIndex).registerC + + addInstruction( + layoutChangeListenerIndex + bottomBarContainerOffset--, + "invoke-static { v$bottomBarContainerRegister }, $descriptor" + ) + } + } private enum class Hook(val methodName: String, val parameters: String) { SET_LAST_APP_NAVIGATION_ENUM("setLastAppNavigationEnum", "Ljava/lang/Enum;"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt index 331a79f96..fffbe452b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt @@ -2,20 +2,26 @@ package app.revanced.patches.youtube.utils.playertype.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.reference.FieldReference internal object VideoStateFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), + parameters = listOf("Lcom/google/android/libraries/youtube/player/features/overlay/controls/ControlsState;"), opcodes = listOf( - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, Opcode.CONST_4, Opcode.IF_EQZ, Opcode.IF_EQZ, Opcode.IGET_OBJECT, // obfuscated parameter field name - ) + ), + customFingerprint = { methodDef, _ -> + methodDef.indexOfFirstInstruction { + opcode == Opcode.IGET_OBJECT && + getReference()?.definingClass == methodDef.parameterTypes.firstOrNull() + } >= 0 + } ) \ No newline at end of file