Skip to content

Commit

Permalink
fix(YouTube - Toolbar components): Hide voice search button setting…
Browse files Browse the repository at this point in the history
… does not work
  • Loading branch information
anddea committed Dec 23, 2024
1 parent 8426f74 commit cb6868a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<MethodReference>()?.name == "resolveActivity"
} >= 0
},
)

internal val searchResultFingerprint = legacyFingerprint(
name = "searchResultFingerprint",
returnType = "Landroid/view/View;",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<MethodReference>()?.toString() == voiceInputControllerActivityMethodCall
}
val setOnClickListenerIndex = indexOfFirstInstructionOrThrow(voiceInputControllerActivityIndex) {
opcode == Opcode.INVOKE_VIRTUAL &&
getReference<MethodReference>()?.name == "setOnClickListener"
}
Expand Down

0 comments on commit cb6868a

Please sign in to comment.