From bfa379a398bce8d635043eb2d4f81c4ed7440101 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 26 Aug 2023 16:21:58 +0200 Subject: [PATCH] feat(YouTube Music - Exclusive audio playback): Support latest version --- ...AllowExclusiveAudioPlaybackFingerprint.kt} | 13 ++++------ .../patch/ExclusiveAudioPatch.kt | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) rename src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/{AudioOnlyEnablerFingerprint.kt => AllowExclusiveAudioPlaybackFingerprint.kt} (65%) diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AllowExclusiveAudioPlaybackFingerprint.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AllowExclusiveAudioPlaybackFingerprint.kt index 64dc94453..bf604d04c 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AllowExclusiveAudioPlaybackFingerprint.kt @@ -5,14 +5,11 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -object AudioOnlyEnablerFingerprint: MethodFingerprint( - "Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, +object AllowExclusiveAudioPlaybackFingerprint: MethodFingerprint( + "Z", + AccessFlags.PUBLIC or AccessFlags.FINAL, + listOf(), + listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, 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 512268113..e5801e64d 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 @@ -1,25 +1,31 @@ package app.revanced.patches.music.audio.exclusiveaudio.patch +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.annotations.MusicCompatibility -import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint +import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AllowExclusiveAudioPlaybackFingerprint @Patch @Name("Exclusive audio playback") -@Description("Enables the option to play music without video.") +@Description("Enables the option to play audio without video.") @MusicCompatibility class ExclusiveAudioPatch : BytecodePatch( - listOf(AudioOnlyEnablerFingerprint) + listOf(AllowExclusiveAudioPlaybackFingerprint) ) { override fun execute(context: BytecodeContext) { - val method = AudioOnlyEnablerFingerprint.result!!.mutableMethod - method.replaceInstruction(method.implementation!!.instructions.count() - 1, "const/4 v0, 0x1") - method.addInstruction("return v0") + AllowExclusiveAudioPlaybackFingerprint.result?.mutableMethod?.apply { + addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + } ?: throw AllowExclusiveAudioPlaybackFingerprint.exception } -} +} \ No newline at end of file