From 276af1415a4d354c62fe6259b6559bca1fa84f08 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 19 Jun 2023 03:14:48 +0200 Subject: [PATCH] feat(youtube-music): remove version compatibility constraints --- .../ad/video/patch/MusicVideoAdsPatch.kt | 8 +- .../MusicCompatibility.kt} | 4 +- .../annotations/CodecsUnlockCompatibility.kt | 8 -- .../audio/codecs/patch/CodecsUnlockPatch.kt | 4 +- .../ExclusiveAudioCompatibility.kt | 8 -- .../patch/ExclusiveAudioPatch.kt | 8 +- .../annotations/CompactHeaderCompatibility.kt | 8 -- .../compactheader/patch/CompactHeaderPatch.kt | 8 +- .../MinimizedPlaybackCompatibility.kt | 8 -- .../patch/MinimizedPlaybackPatch.kt | 8 +- .../HideGetPremiumCompatibility.kt | 31 ----- .../premium/patch/HideGetPremiumPatch.kt | 15 +- .../RemoveTasteBuilderCompatibility.kt | 13 -- .../TasteBuilderConstructorFingerprint.kt | 34 ----- .../patch/RemoveTasteBuilderPatch.kt | 42 ------ .../RemoveUpgradeButtonCompatibility.kt | 8 -- .../patch/RemoveUpgradeButtonPatch.kt | 8 +- .../BypassCertificateChecksCompatibility.kt | 35 ----- .../patch/BypassCertificateChecksPatch.kt | 8 +- .../MusicMicroGPatchCompatibility.kt | 8 -- ...ytecodePatch.kt => MicroGBytecodePatch.kt} | 130 +++++++++--------- ...esourcePatch.kt => MicroGResourcePatch.kt} | 8 +- .../BackgroundPlayCompatibility.kt | 8 -- .../patch/BackgroundPlayPatch.kt | 8 +- 24 files changed, 101 insertions(+), 327 deletions(-) rename src/main/kotlin/app/revanced/patches/music/{ad/video/annotations/MusicVideoAdsCompatibility.kt => annotations/MusicCompatibility.kt} (64%) delete mode 100644 src/main/kotlin/app/revanced/patches/music/audio/codecs/annotations/CodecsUnlockCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/annotations/ExclusiveAudioCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/compactheader/annotations/CompactHeaderCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/premium/annotations/HideGetPremiumCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/annotations/RemoveTasteBuilderCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/annotations/RemoveUpgradeButtonCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/misc/microg/annotations/MusicMicroGPatchCompatibility.kt rename src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/{MusicMicroGBytecodePatch.kt => MicroGBytecodePatch.kt} (86%) rename src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/{MusicMicroGResourcePatch.kt => MicroGResourcePatch.kt} (88%) delete mode 100644 src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/annotations/BackgroundPlayCompatibility.kt diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt index bd4d911078..5d5ae990ad 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt @@ -10,19 +10,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.ad.video.annotations.MusicVideoAdsCompatibility import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsConstructorFingerprint import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsFingerprint +import app.revanced.patches.music.annotations.MusicCompatibility @Patch @Name("music-video-ads") @Description("Removes ads in the music player.") -@MusicVideoAdsCompatibility +@MusicCompatibility @Version("0.0.1") class MusicVideoAdsPatch : BytecodePatch( - listOf( - ShowMusicVideoAdsConstructorFingerprint - ) + listOf(ShowMusicVideoAdsConstructorFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { ShowMusicVideoAdsFingerprint.resolve(context, ShowMusicVideoAdsConstructorFingerprint.result!!.classDef) diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/annotations/MusicVideoAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/annotations/MusicCompatibility.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/music/ad/video/annotations/MusicVideoAdsCompatibility.kt rename to src/main/kotlin/app/revanced/patches/music/annotations/MusicCompatibility.kt index 0910b502d4..5cd3b494ca 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/annotations/MusicVideoAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/music/annotations/MusicCompatibility.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.music.ad.video.annotations +package app.revanced.patches.music.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package @Compatibility([Package("com.google.android.apps.youtube.music")]) @Target(AnnotationTarget.CLASS) -internal annotation class MusicVideoAdsCompatibility +internal annotation class MusicCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/annotations/CodecsUnlockCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/annotations/CodecsUnlockCompatibility.kt deleted file mode 100644 index cefdb77981..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/annotations/CodecsUnlockCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.audio.codecs.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class CodecsUnlockCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt index 9ff6916b83..29de5e3b95 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.toInstruction -import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.audio.codecs.fingerprints.AllCodecsReferenceFingerprint import app.revanced.patches.music.audio.codecs.fingerprints.CodecsLockFingerprint import org.jf.dexlib2.Opcode @@ -18,7 +18,7 @@ import org.jf.dexlib2.Opcode @Patch @Name("codecs-unlock") @Description("Adds more audio codec options. The new audio codecs usually result in better audio quality.") -@CodecsUnlockCompatibility +@MusicCompatibility @Version("0.0.1") class CodecsUnlockPatch : BytecodePatch( listOf( diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/annotations/ExclusiveAudioCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/annotations/ExclusiveAudioCompatibility.kt deleted file mode 100644 index ac0ec5ba3a..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/annotations/ExclusiveAudioCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.audio.exclusiveaudio.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class ExclusiveAudioCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt index 4579235e0a..531790c653 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt @@ -10,18 +10,16 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint @Patch @Name("exclusive-audio-playback") @Description("Enables the option to play music without video.") -@ExclusiveAudioCompatibility +@MusicCompatibility @Version("0.0.1") class ExclusiveAudioPatch : BytecodePatch( - listOf( - AudioOnlyEnablerFingerprint - ) + listOf(AudioOnlyEnablerFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { val method = AudioOnlyEnablerFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/annotations/CompactHeaderCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/annotations/CompactHeaderCompatibility.kt deleted file mode 100644 index 573e6452e9..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/annotations/CompactHeaderCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.layout.compactheader.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class CompactHeaderCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt index 843c7e46f1..d3a59bdb51 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt @@ -9,19 +9,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.layout.compactheader.annotations.CompactHeaderCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.layout.compactheader.fingerprints.CompactHeaderConstructorFingerprint import org.jf.dexlib2.builder.instruction.BuilderInstruction11x @Patch(false) @Name("compact-header") @Description("Hides the music category bar at the top of the homepage.") -@CompactHeaderCompatibility +@MusicCompatibility @Version("0.0.1") class CompactHeaderPatch : BytecodePatch( - listOf( - CompactHeaderConstructorFingerprint - ) + listOf(CompactHeaderConstructorFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { val result = CompactHeaderConstructorFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt deleted file mode 100644 index 7045f279e6..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.layout.minimizedplayback.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class MinimizedPlaybackCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt index e6239db7f9..8e0b07d0cc 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -9,18 +9,16 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.layout.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint @Patch @Name("minimized-playback-music") @Description("Enables minimized playback on Kids music.") -@MinimizedPlaybackCompatibility +@MusicCompatibility @Version("0.0.1") class MinimizedPlaybackPatch : BytecodePatch( - listOf( - MinimizedPlaybackManagerFingerprint - ) + listOf(MinimizedPlaybackManagerFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/annotations/HideGetPremiumCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/annotations/HideGetPremiumCompatibility.kt deleted file mode 100644 index 1347202116..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/annotations/HideGetPremiumCompatibility.kt +++ /dev/null @@ -1,31 +0,0 @@ -package app.revanced.patches.music.layout.premium.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility( - [Package( - "com.google.android.apps.youtube.music", - arrayOf( - "5.14.53", - "5.16.51", - "5.17.51", - "5.21.52", - "5.22.54", - "5.23.50", - "5.25.51", - "5.25.52", - "5.26.52", - "5.27.51", - "5.28.52", - "5.29.52", - "5.31.50", - "5.34.51", - "5.36.51", - "5.38.53", - "5.39.52" - ) - )] -) -@Target(AnnotationTarget.CLASS) -internal annotation class HideGetPremiumCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt index b4f8c1a9d6..d25a455246 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt @@ -11,19 +11,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumParentFingerprint @Patch @Name("hide-get-premium") @Description("Removes all \"Get Premium\" evidences from the avatar menu.") -@HideGetPremiumCompatibility +@MusicCompatibility @Version("0.0.1") class HideGetPremiumPatch : BytecodePatch( - listOf( - HideGetPremiumParentFingerprint - ) + listOf(HideGetPremiumParentFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { val parentResult = HideGetPremiumParentFingerprint.result!! @@ -33,9 +31,10 @@ class HideGetPremiumPatch : BytecodePatch( val parentMethod = parentResult.mutableMethod parentMethod.replaceInstruction( - startIndex, """ - const/4 v1, 0x0 - """ + startIndex, + """ + const/4 v1, 0x0 + """ ) val result = HideGetPremiumFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/annotations/RemoveTasteBuilderCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/annotations/RemoveTasteBuilderCompatibility.kt deleted file mode 100644 index ce2b14d874..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/annotations/RemoveTasteBuilderCompatibility.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.music.layout.tastebuilder.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -/** - * -- Note 2022-08-05 -- - * Since 5.17.xx the tastebuilder component is dismissible, so this patch is less useful - * also it is partly litho now - */ -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class RemoveTasteBuilderCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt deleted file mode 100644 index e72193c6f5..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.music.layout.tastebuilder.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - - -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. -object TasteBuilderConstructorFingerprint : MethodFingerprint( - "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf( - Opcode.INVOKE_DIRECT, - Opcode.INVOKE_VIRTUAL, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST, - Opcode.CONST_4, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IPUT_OBJECT, - Opcode.CONST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.CONST - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt deleted file mode 100644 index 5f1ef34b80..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt +++ /dev/null @@ -1,42 +0,0 @@ -package app.revanced.patches.music.layout.tastebuilder.patch - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility -import app.revanced.patches.music.layout.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint -import org.jf.dexlib2.iface.instruction.formats.Instruction22c - -@Patch -@Name("tasteBuilder-remover") -@Description("Removes the \"Tell us which artists you like\" card from the home screen.") -@RemoveTasteBuilderCompatibility -@Version("0.0.1") -class RemoveTasteBuilderPatch : BytecodePatch( - listOf( - TasteBuilderConstructorFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - val result = TasteBuilderConstructorFingerprint.result!! - val method = result.mutableMethod - - val insertIndex = result.scanResult.patternScanResult!!.endIndex - 8 - val register = (method.implementation!!.instructions[insertIndex] as Instruction22c).registerA - method.addInstructions( - insertIndex, - """ - const/16 v1, 0x8 - invoke-virtual {v${register}, v1}, Landroid/view/View;->setVisibility(I)V - """ - ) - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/annotations/RemoveUpgradeButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/annotations/RemoveUpgradeButtonCompatibility.kt deleted file mode 100644 index e683030614..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/annotations/RemoveUpgradeButtonCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.layout.upgradebutton.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class RemoveUpgradeButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt index 1a134862dc..111197d2a1 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.toInstructions -import app.revanced.patches.music.layout.upgradebutton.annotations.RemoveUpgradeButtonCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.layout.upgradebutton.fingerprints.PivotBarConstructorFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction22t @@ -21,12 +21,10 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Patch @Name("upgrade-button-remover") @Description("Removes the upgrade tab from the pivot bar.") -@RemoveUpgradeButtonCompatibility +@MusicCompatibility @Version("0.0.1") class RemoveUpgradeButtonPatch : BytecodePatch( - listOf( - PivotBarConstructorFingerprint - ) + listOf(PivotBarConstructorFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { val result = PivotBarConstructorFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt deleted file mode 100644 index dbbd319926..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt +++ /dev/null @@ -1,35 +0,0 @@ -package app.revanced.patches.music.misc.androidauto.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility( - [Package( - "com.google.android.apps.youtube.music", - arrayOf( - "5.14.53", - "5.16.51", - "5.17.51", - "5.21.52", - "5.22.54", - "5.23.50", - "5.25.51", - "5.25.52", - "5.26.52", - "5.27.51", - "5.28.52", - "5.29.52", - "5.31.50", - "5.34.51", - "5.36.51", - "5.38.53", - "5.39.52", - "5.40.51", - "5.41.50", - "5.48.52" - ) - )] -) -@Target(AnnotationTarget.CLASS) -@Retention(AnnotationRetention.RUNTIME) -internal annotation class BypassCertificateChecksCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt index e429b11878..69a93a8723 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt @@ -11,18 +11,16 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.misc.androidauto.annotations.BypassCertificateChecksCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.misc.androidauto.fingerprints.CheckCertificateFingerprint @Patch @Name("bypass-certificate-checks") @Description("Bypasses certificate checks which prevent YouTube Music from working on Android Auto.") -@BypassCertificateChecksCompatibility +@MusicCompatibility @Version("0.0.1") class BypassCertificateChecksPatch : BytecodePatch( - listOf( - CheckCertificateFingerprint - ) + listOf(CheckCertificateFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { CheckCertificateFingerprint.result?.let { result -> diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/annotations/MusicMicroGPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/annotations/MusicMicroGPatchCompatibility.kt deleted file mode 100644 index 8128a9af67..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/annotations/MusicMicroGPatchCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.misc.microg.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class MusicMicroGPatchCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MicroGBytecodePatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index 7fca848f83..f34afb9b48 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -1,65 +1,65 @@ -package app.revanced.patches.music.misc.microg.patch.bytecode - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility -import app.revanced.patches.music.misc.microg.fingerprints.* -import app.revanced.patches.music.misc.microg.patch.resource.MusicMicroGResourcePatch -import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME -import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_PACKAGE_NAME -import app.revanced.patches.youtube.misc.microg.shared.Constants -import app.revanced.util.microg.MicroGBytecodeHelper - -@Patch -@DependsOn([MusicMicroGResourcePatch::class]) -@Name("music-microg-support") -@Description("Allows YouTube Music ReVanced to run without root and under a different package name.") -@MusicMicroGPatchCompatibility -@Version("0.0.2") -class MusicMicroGBytecodePatch : BytecodePatch( - listOf( - ServiceCheckFingerprint, - GooglePlayUtilityFingerprint, - CastDynamiteModuleFingerprint, - CastDynamiteModuleV2Fingerprint, - CastContextFetchFingerprint, - PrimeFingerprint, - ) -) { - // NOTE: the previous patch also replaced the following strings, but it seems like they are not needed: - // - "com.google.android.gms.chimera.GmsIntentOperationService", - // - "com.google.android.gms.phenotype.internal.IPhenotypeCallbacks", - // - "com.google.android.gms.phenotype.internal.IPhenotypeService", - // - "com.google.android.gms.phenotype.PACKAGE_NAME", - // - "com.google.android.gms.phenotype.UPDATE", - // - "com.google.android.gms.phenotype", - override fun execute(context: BytecodeContext) = - // apply common microG patch - MicroGBytecodeHelper.patchBytecode( - context, - arrayOf( - MicroGBytecodeHelper.packageNameTransform( - Constants.PACKAGE_NAME, - Constants.REVANCED_PACKAGE_NAME - ) - ), - MicroGBytecodeHelper.PrimeMethodTransformationData( - PrimeFingerprint, - MUSIC_PACKAGE_NAME, - REVANCED_MUSIC_PACKAGE_NAME - ), - listOf( - ServiceCheckFingerprint, - GooglePlayUtilityFingerprint, - CastDynamiteModuleFingerprint, - CastDynamiteModuleV2Fingerprint, - CastContextFetchFingerprint - ) - ).let { PatchResultSuccess() } -} +package app.revanced.patches.music.misc.microg.patch.bytecode + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.annotations.MusicCompatibility +import app.revanced.patches.music.misc.microg.fingerprints.* +import app.revanced.patches.music.misc.microg.patch.resource.MicroGResourcePatch +import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME +import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_PACKAGE_NAME +import app.revanced.patches.youtube.misc.microg.shared.Constants +import app.revanced.util.microg.MicroGBytecodeHelper + +@Patch +@DependsOn([MicroGResourcePatch::class]) +@Name("vanced-microg-support") +@Description("Allows YouTube Music ReVanced to run without root and under a different package name.") +@MusicCompatibility +@Version("0.0.2") +class MicroGBytecodePatch : BytecodePatch( + listOf( + ServiceCheckFingerprint, + GooglePlayUtilityFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, + CastContextFetchFingerprint, + PrimeFingerprint, + ) +) { + // NOTE: the previous patch also replaced the following strings, but it seems like they are not needed: + // - "com.google.android.gms.chimera.GmsIntentOperationService", + // - "com.google.android.gms.phenotype.internal.IPhenotypeCallbacks", + // - "com.google.android.gms.phenotype.internal.IPhenotypeService", + // - "com.google.android.gms.phenotype.PACKAGE_NAME", + // - "com.google.android.gms.phenotype.UPDATE", + // - "com.google.android.gms.phenotype", + override fun execute(context: BytecodeContext) = + // apply common microG patch + MicroGBytecodeHelper.patchBytecode( + context, + arrayOf( + MicroGBytecodeHelper.packageNameTransform( + Constants.PACKAGE_NAME, + Constants.REVANCED_PACKAGE_NAME + ) + ), + MicroGBytecodeHelper.PrimeMethodTransformationData( + PrimeFingerprint, + MUSIC_PACKAGE_NAME, + REVANCED_MUSIC_PACKAGE_NAME + ), + listOf( + ServiceCheckFingerprint, + GooglePlayUtilityFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, + CastContextFetchFingerprint + ) + ).let { PatchResultSuccess() } +} diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MicroGResourcePatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MicroGResourcePatch.kt index 19daba368e..0644160e85 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MicroGResourcePatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_APP_NAME import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_PACKAGE_NAME @@ -16,11 +16,11 @@ import app.revanced.patches.music.misc.microg.shared.Constants.SPOOFED_PACKAGE_S import app.revanced.util.microg.MicroGManifestHelper import app.revanced.util.microg.MicroGResourceHelper -@Name("music-microg-resource-patch") +@Name("microg-resource-patch") @Description("Resource patch to allow YouTube Music ReVanced to run without root and under a different package name.") -@MusicMicroGPatchCompatibility +@MusicCompatibility @Version("0.0.2") -class MusicMicroGResourcePatch : ResourcePatch { +class MicroGResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { // update manifest MicroGResourceHelper.patchManifest( diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/annotations/BackgroundPlayCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/annotations/BackgroundPlayCompatibility.kt deleted file mode 100644 index 31dd505f39..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/annotations/BackgroundPlayCompatibility.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.music.premium.backgroundplay.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility([Package("com.google.android.apps.youtube.music")]) -@Target(AnnotationTarget.CLASS) -internal annotation class BackgroundPlayCompatibility diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt index c1f39c9b5c..868175eaa0 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt @@ -9,18 +9,16 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility +import app.revanced.patches.music.annotations.MusicCompatibility import app.revanced.patches.music.premium.backgroundplay.fingerprints.BackgroundPlaybackDisableFingerprint @Patch @Name("background-play") @Description("Enables playing music in the background.") -@BackgroundPlayCompatibility +@MusicCompatibility @Version("0.0.1") class BackgroundPlayPatch : BytecodePatch( - listOf( - BackgroundPlaybackDisableFingerprint - ) + listOf(BackgroundPlaybackDisableFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { BackgroundPlaybackDisableFingerprint.result!!.mutableMethod.addInstructions(