diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/Fingerprints.kt index 00ac1b22f..6440b9e6e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/Fingerprints.kt @@ -155,6 +155,27 @@ internal val searchBarParentFingerprint = legacyFingerprint( literals = listOf(voiceSearch), ) +internal val voiceInputControllerParentFingerprint = legacyFingerprint( + name = "voiceInputControllerParentFingerprint", + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("[B", "Z"), + strings = listOf("VoiceInputController"), +) + +internal val voiceInputControllerFingerprint = legacyFingerprint( + name = "voiceInputControllerFingerprint", + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = emptyList(), + customFingerprint = { method, _ -> + method.indexOfFirstInstruction { + opcode == Opcode.INVOKE_VIRTUAL && + getReference()?.name == "resolveActivity" + } >= 0 + }, +) + internal val searchResultFingerprint = legacyFingerprint( name = "searchResultFingerprint", returnType = "Landroid/view/View;", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt index 1b24b1bf8..74f762141 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt @@ -18,7 +18,6 @@ import app.revanced.patches.youtube.utils.patch.PatchList.TOOLBAR_COMPONENTS import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.resourceid.actionBarRingoBackground import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch -import app.revanced.patches.youtube.utils.resourceid.voiceSearch import app.revanced.patches.youtube.utils.resourceid.ytOutlineVideoCamera import app.revanced.patches.youtube.utils.resourceid.ytPremiumWordMarkHeader import app.revanced.patches.youtube.utils.resourceid.ytWordMarkHeader @@ -32,6 +31,7 @@ import app.revanced.util.doRecursively import app.revanced.util.findInstructionIndicesReversedOrThrow import app.revanced.util.findMethodOrThrow import app.revanced.util.fingerprint.matchOrThrow +import app.revanced.util.fingerprint.methodCall import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.fingerprint.mutableClassOrThrow import app.revanced.util.getReference @@ -332,8 +332,17 @@ val toolBarComponentsPatch = bytecodePatch( searchResultFingerprint.matchOrThrow().let { it.method.apply { - val startIndex = indexOfFirstLiteralInstructionOrThrow(voiceSearch) - val setOnClickListenerIndex = indexOfFirstInstructionOrThrow(startIndex) { + val voiceInputControllerActivityMethodCall = + voiceInputControllerFingerprint + .methodOrThrow(voiceInputControllerParentFingerprint) + .methodCall() + + val voiceInputControllerActivityIndex = + indexOfFirstInstructionOrThrow { + opcode == Opcode.INVOKE_VIRTUAL && + getReference()?.toString() == voiceInputControllerActivityMethodCall + } + val setOnClickListenerIndex = indexOfFirstInstructionOrThrow(voiceInputControllerActivityIndex) { opcode == Opcode.INVOKE_VIRTUAL && getReference()?.name == "setOnClickListener" }