From 3c31e55b13d9495e857f068f8cd2b4320112d763 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 8 Jun 2024 11:35:44 +0300 Subject: [PATCH] fix(YouTube Music): Rename `Minimized playback` to `Remove background playback restrictions` (#3315) --- api/revanced-patches.api | 6 +++ .../MinimizedPlaybackPatch.kt | 45 ++--------------- .../BackgroundPlaybackPatch.kt | 50 +++++++++++++++++++ .../BackgroundPlaybackDisableFingerprint.kt | 2 +- ...undPlaybackPolicyControllerFingerprint.kt} | 4 +- .../backgroundplay/BackgroundPlayPatch.kt | 7 +-- 6 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt rename src/main/kotlin/app/revanced/patches/music/{layout/minimizedplayback => misc/backgroundplayback}/fingerprints/BackgroundPlaybackDisableFingerprint.kt (88%) rename src/main/kotlin/app/revanced/patches/music/{layout/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt => misc/backgroundplayback/fingerprints/KidsBackgroundPlaybackPolicyControllerFingerprint.kt} (78%) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 4b276044..e0a49a1e 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -403,6 +403,12 @@ public final class app/revanced/patches/music/misc/androidauto/BypassCertificate public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/music/misc/gms/Constants { public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/Constants; } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch.kt index 918e08f2..8d497d9b 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch.kt @@ -1,50 +1,13 @@ package app.revanced.patches.music.layout.minimizedplayback import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.music.layout.minimizedplayback.fingerprints.BackgroundPlaybackDisableFingerprint -import app.revanced.patches.music.layout.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint -import app.revanced.util.exception +import app.revanced.patches.music.misc.backgroundplayback.BackgroundPlaybackPatch -@Patch( - name = "Minimized playback", - description = "Unlocks options for picture-in-picture and background playback.", - compatiblePackages = [ - CompatiblePackage( - "com.google.android.apps.youtube.music", - [ - "6.45.54", - "6.51.53", - "7.01.53", - "7.02.52", - "7.03.52", - ] - ) - ] -) -@Suppress("unused") +@Deprecated("This patch has been merged into BackgroundPlaybackPatch.") object MinimizedPlaybackPatch : BytecodePatch( - setOf( - KidsMinimizedPlaybackPolicyControllerFingerprint, - BackgroundPlaybackDisableFingerprint, - ), + dependencies = setOf(BackgroundPlaybackPatch::class), ) { override fun execute(context: BytecodeContext) { - KidsMinimizedPlaybackPolicyControllerFingerprint.result?.mutableMethod?.addInstruction( - 0, - "return-void", - ) ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.exception - - BackgroundPlaybackDisableFingerprint.result?.mutableMethod?.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) ?: throw BackgroundPlaybackDisableFingerprint.exception } -} +} \ No newline at end of file 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 new file mode 100644 index 00000000..51608bc5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -0,0 +1,50 @@ +package app.revanced.patches.music.misc.backgroundplayback + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.music.misc.backgroundplayback.fingerprints.BackgroundPlaybackDisableFingerprint +import app.revanced.patches.music.misc.backgroundplayback.fingerprints.KidsBackgroundPlaybackPolicyControllerFingerprint +import app.revanced.util.resultOrThrow + +@Patch( + name = "Remove background playback restrictions", + description = "Removes restrictions on background playback.", + compatiblePackages = [ + CompatiblePackage( + "com.google.android.apps.youtube.music", + [ + "6.45.54", + "6.51.53", + "7.01.53", + "7.02.52", + "7.03.52", + ] + ) + ] +) +@Suppress("unused") +object BackgroundPlaybackPatch : BytecodePatch( + setOf( + KidsBackgroundPlaybackPolicyControllerFingerprint, + BackgroundPlaybackDisableFingerprint, + ), +) { + override fun execute(context: BytecodeContext) { + KidsBackgroundPlaybackPolicyControllerFingerprint.resultOrThrow().mutableMethod.addInstruction( + 0, + "return-void", + ) + + BackgroundPlaybackDisableFingerprint.resultOrThrow().mutableMethod.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """, + ) + } +} diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt index d1341028..bf5f2119 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/BackgroundPlaybackDisableFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.layout.minimizedplayback.fingerprints +package app.revanced.patches.music.misc.backgroundplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/KidsBackgroundPlaybackPolicyControllerFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/KidsBackgroundPlaybackPolicyControllerFingerprint.kt index da6823c8..45374d40 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/fingerprints/KidsBackgroundPlaybackPolicyControllerFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.music.layout.minimizedplayback.fingerprints +package app.revanced.patches.music.misc.backgroundplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint( +internal object KidsBackgroundPlaybackPolicyControllerFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("I", "L", "Z"), diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch.kt index a17903a2..da245e89 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch.kt @@ -2,10 +2,11 @@ package app.revanced.patches.music.premium.backgroundplay import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patches.music.layout.minimizedplayback.MinimizedPlaybackPatch -@Deprecated("This patch has been merged into MinimizedPlaybackPatch.") +import app.revanced.patches.music.misc.backgroundplayback.BackgroundPlaybackPatch + +@Deprecated("This patch has been merged into BackgroundPlaybackPatch.") object BackgroundPlayPatch : BytecodePatch( - dependencies = setOf(MinimizedPlaybackPatch::class), + dependencies = setOf(BackgroundPlaybackPatch::class), ) { override fun execute(context: BytecodeContext) { }