From cc59f47f4c826fffe2431464c6895ec92fe9785f Mon Sep 17 00:00:00 2001 From: bibarub Date: Wed, 15 Jun 2022 14:22:09 +0300 Subject: [PATCH 1/9] refactor: rename `shorts-button` to `disable-shorts-button` (#20) --- .../layout/shorts/button/patch/ShortsButtonRemoverPatch.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt index 7d0e5d46d..aab7dd0d9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt @@ -18,7 +18,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11x @Patch @Dependencies(dependencies = [IntegrationsPatch::class]) -@Name("shorts-button") +@Name("disable-shorts-button") @Description("Hide the shorts button.") @ShortsButtonCompatibility @Version("0.0.1") From d733981342e5425e63ab2acc57de6239544507b7 Mon Sep 17 00:00:00 2001 From: Affan Zaman <47723802+afnzmn@users.noreply.github.com> Date: Wed, 15 Jun 2022 09:44:47 -0400 Subject: [PATCH 2/9] Changed app name to ReVanced (#21) --- .../revanced/patches/youtube/misc/microg/shared/Constants.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt index 5d56903c9..65d848274 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt @@ -3,5 +3,5 @@ package app.revanced.patches.youtube.misc.microg.shared object Constants { internal const val BASE_MICROG_PACKAGE_NAME = "com.mgoogle" internal const val REVANCED_PACKAGE_NAME = "app.revanced.android.youtube" - internal const val REVANCED_APP_NAME = "YouTube ReVanced" -} \ No newline at end of file + internal const val REVANCED_APP_NAME = "ReVanced" +} From 0e3c705dc9b54d40f05748c4b4769e41aa63e35c Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 22:58:24 +0300 Subject: [PATCH 3/9] cast work in progress some terrible code --- .../annotations/CastPatchCompatibility.kt | 13 +++++ .../castbutton/patch/CastRemoverPatch.kt | 50 +++++++++++++++++++ .../signatures/CastButtonSignature.kt | 29 +++++++++++ 3 files changed, 92 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt new file mode 100644 index 000000000..23a42c56a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.layout.castbutton.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [Package( + "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36", "17.20.37", "17.22.36") + )] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class CastButtonCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt new file mode 100644 index 000000000..c5f229e2e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt @@ -0,0 +1,50 @@ +package app.revanced.patches.youtube.layout.castbutton.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.extensions.or +import app.revanced.patcher.patch.annotations.Dependencies +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultError +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.signature.implementation.method.MethodSignature +import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.util.smali.toInstruction +import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility +import app.revanced.patches.youtube.layout.castbutton.signatures.CastButtonSignature +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +@Patch +@Dependencies(dependencies = [IntegrationsPatch::class]) +@Name("disable-cast-button") +@Description("Patch to remove the cast button.") +@CastButtonCompatibility +@Version("0.0.1") +class CastButtonRemoverPatch : BytecodePatch( + listOf( + CastButtonSignature + ) +) { + override fun execute(data: BytecodeData): PatchResult { + val result = signatures.first().result!! + val implementation = result.method.implementation!! + + implementation.addInstruction( + 0, + "invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I".toInstruction() + ) + + implementation.addInstruction( + 1, + "move-result p1".toInstruction() + ) + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt new file mode 100644 index 000000000..00bbde012 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt @@ -0,0 +1,29 @@ +package app.revanced.patches.youtube.layout.castbutton.signatures + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.signature.implementation.method.MethodSignature +import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +@Name("cast-button-signature") +@MatchingMethod( + "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" +) +@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. +@CastButtonCompatibility +@Version("0.0.1") +object CastButtonSignature : MethodSignature( + "V", + AccessFlags.PUBLIC or AccessFlags.FINAL, + listOf("L","L"), + listOf( + Opcode.IPUT, + Opcode.INVOKE_VIRTUAL, + Opcode.RETURN_VOID, + ) +) \ No newline at end of file From c3208ff2d1723ed16e6fa2282b4919b5118e2cd3 Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:02:54 +0300 Subject: [PATCH 4/9] comments --- .../layout/castbutton/annotations/CastPatchCompatibility.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt index 23a42c56a..8abac8082 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.annotation.Package @Compatibility( [Package( - "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36", "17.20.37", "17.22.36") + "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36", "17.20.37", "17.22.36") // only 17.20.37 is tested )] ) @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) -internal annotation class CastButtonCompatibility \ No newline at end of file +internal annotation class CastButtonCompatibility From 9b0e6b5ed873a528d65c5eb0591f349fabcfa6f1 Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:04:27 +0300 Subject: [PATCH 5/9] comments --- .../layout/castbutton/signatures/CastButtonSignature.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt index 00bbde012..c6ab273b2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt @@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode @Name("cast-button-signature") @MatchingMethod( - "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" + "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" // first one is prolly causing the issue ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CastButtonCompatibility @@ -26,4 +26,4 @@ object CastButtonSignature : MethodSignature( Opcode.INVOKE_VIRTUAL, Opcode.RETURN_VOID, ) -) \ No newline at end of file +) From a8940d8cd020f718f4e3f97f84d0b1381317f6aa Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:06:40 +0300 Subject: [PATCH 6/9] more comments --- .../youtube/layout/castbutton/patch/CastRemoverPatch.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt index c5f229e2e..1263e2f82 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt @@ -34,7 +34,7 @@ class CastButtonRemoverPatch : BytecodePatch( ) { override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! - val implementation = result.method.implementation!! + val implementation = result.method.implementation!! // stole code from shorts button since it worked pretty good implementation.addInstruction( 0, @@ -47,4 +47,4 @@ class CastButtonRemoverPatch : BytecodePatch( ) return PatchResultSuccess() } -} \ No newline at end of file +} From 903c01b76511082114cd4227051b05fcac4e3a20 Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:08:16 +0300 Subject: [PATCH 7/9] fix: comments --- .../layout/castbutton/signatures/CastButtonSignature.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt index c6ab273b2..fa1a51640 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt @@ -12,15 +12,15 @@ import org.jf.dexlib2.Opcode @Name("cast-button-signature") @MatchingMethod( - "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" // first one is prolly causing the issue + "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" // first one is prolly causing the issue since not sure what to write there ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CastButtonCompatibility @Version("0.0.1") object CastButtonSignature : MethodSignature( - "V", + "V", // this might be broken as well since idk what is this AccessFlags.PUBLIC or AccessFlags.FINAL, - listOf("L","L"), + listOf("L","L"), // this too listOf( Opcode.IPUT, Opcode.INVOKE_VIRTUAL, From 887a916c1ad466d35cc19f501e9f759e30360835 Mon Sep 17 00:00:00 2001 From: Canny1913 <94744045+Canny1913@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:52:41 +0300 Subject: [PATCH 8/9] Update annotation Co-authored-by: Sculas --- .../layout/castbutton/annotations/CastPatchCompatibility.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt index 8abac8082..2ccd0a2a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package @Compatibility( [Package( - "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36", "17.20.37", "17.22.36") // only 17.20.37 is tested + "com.google.android.youtube", arrayOf("17.20.37") )] ) @Target(AnnotationTarget.CLASS) From e85c30c9c2569b43dcc086cb3cdede18362c8b68 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 16 Jun 2022 00:25:21 +0200 Subject: [PATCH 9/9] fix: `hide-cast-button` patch --- .../annotations/CastPatchCompatibility.kt | 2 +- .../castbutton/patch/CastRemoverPatch.kt | 50 ------------------- .../castbutton/patch/HideCastButtonPatch.kt | 44 ++++++++++++++++ .../signatures/CastButtonSignature.kt | 29 ----------- .../patch/bytecode/MicroGBytecodePatch.kt | 17 ++----- 5 files changed, 49 insertions(+), 93 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt index 2ccd0a2a6..2ed7cc14c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/annotations/CastPatchCompatibility.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package @Compatibility( [Package( - "com.google.android.youtube", arrayOf("17.20.37") + "com.google.android.youtube", arrayOf() )] ) @Target(AnnotationTarget.CLASS) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt deleted file mode 100644 index 1263e2f82..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/CastRemoverPatch.kt +++ /dev/null @@ -1,50 +0,0 @@ -package app.revanced.patches.youtube.layout.castbutton.patch - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.annotations.Dependencies -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.implementation.BytecodePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patcher.util.smali.toInstruction -import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility -import app.revanced.patches.youtube.layout.castbutton.signatures.CastButtonSignature -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - -@Patch -@Dependencies(dependencies = [IntegrationsPatch::class]) -@Name("disable-cast-button") -@Description("Patch to remove the cast button.") -@CastButtonCompatibility -@Version("0.0.1") -class CastButtonRemoverPatch : BytecodePatch( - listOf( - CastButtonSignature - ) -) { - override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!! - val implementation = result.method.implementation!! // stole code from shorts button since it worked pretty good - - implementation.addInstruction( - 0, - "invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I".toInstruction() - ) - - implementation.addInstruction( - 1, - "move-result p1".toInstruction() - ) - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt new file mode 100644 index 000000000..a4283c381 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.youtube.layout.castbutton.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.implementation.proxy +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.annotations.Dependencies +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.util.smali.toInstructions +import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch + +@Patch +@Dependencies(dependencies = [IntegrationsPatch::class]) +@Name("hide-cast-button") +@Description("Patch to hide the cast button.") +@CastButtonCompatibility +@Version("0.0.1") +class HideCastButtonPatch : BytecodePatch(listOf()) { + override fun execute(data: BytecodeData): PatchResult { + data.classes.forEach { classDef -> + classDef.methods.forEach { method -> + if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") { + val implementation = + data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }.implementation!! + + implementation.addInstructions( + 0, """ + invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I + move-result p1 + """.trimIndent().toInstructions("I", 2, false) + ) + } + } + } + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt deleted file mode 100644 index fa1a51640..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/signatures/CastButtonSignature.kt +++ /dev/null @@ -1,29 +0,0 @@ -package app.revanced.patches.youtube.layout.castbutton.signatures - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - -@Name("cast-button-signature") -@MatchingMethod( - "Landroidx/mediarouter/app/MediaRouteButton", "setVisibility" // first one is prolly causing the issue since not sure what to write there -) -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. -@CastButtonCompatibility -@Version("0.0.1") -object CastButtonSignature : MethodSignature( - "V", // this might be broken as well since idk what is this - AccessFlags.PUBLIC or AccessFlags.FINAL, - listOf("L","L"), // this too - listOf( - Opcode.IPUT, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID, - ) -) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index 1edad9760..d1d1d8cb7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -15,6 +15,7 @@ import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.smali.toInstruction import app.revanced.patcher.util.smali.toInstructions +import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePatch import app.revanced.patches.youtube.misc.microg.patch.resource.enum.StringReplaceMode @@ -24,13 +25,14 @@ import app.revanced.patches.youtube.misc.microg.signatures.* import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.MutableMethodImplementation import org.jf.dexlib2.builder.instruction.BuilderInstruction21c -import org.jf.dexlib2.builder.instruction.BuilderInstruction21s import org.jf.dexlib2.iface.instruction.formats.Instruction21c import org.jf.dexlib2.iface.reference.StringReference import org.jf.dexlib2.immutable.reference.ImmutableStringReference @Patch(include = false) -@Dependencies(dependencies = [MicroGResourcePatch::class]) +@Dependencies( + dependencies = [MicroGResourcePatch::class, HideCastButtonPatch::class] +) @Name("microg-support") @Description("Patch to allow YouTube ReVanced to run without root and under a different package name.") @MicroGPatchCompatibility @@ -56,17 +58,6 @@ class MicroGBytecodePatch : BytecodePatch( var proxiedImplementation: MutableMethodImplementation? = null - // disable cast button since it is unsupported by microg and causes battery issues - // the code is here instead of the fixCastIssues method because we do not need a signature this way - if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") { - proxiedClass = data.proxy(classDef).resolve() - proxiedImplementation = proxiedClass!!.methods.first { it.name == "setVisibility" }.implementation - - proxiedImplementation!!.replaceInstruction( - 0, BuilderInstruction21s(Opcode.CONST_16, 1, 8) // 8 == HIDDEN - ) - } - implementation.instructions.forEachIndexed { i, instruction -> if (instruction.opcode != Opcode.CONST_STRING) return@forEachIndexed