From c3813c3a0b4b949272ee1901ac4d5efea901f04d Mon Sep 17 00:00:00 2001 From: inotia00 Date: Sat, 25 Feb 2023 07:23:11 +0900 Subject: [PATCH] fix(music): `enable-force-minimized-player` patch is broken --- .../fingerprints/MinimizedPlayerFingerprint.kt | 7 +------ .../minimizedplayer/patch/MinimizedPlayerPatch.kt | 10 +++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/fingerprints/MinimizedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/fingerprints/MinimizedPlayerFingerprint.kt index e765f5649..fe5f804a9 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/fingerprints/MinimizedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/fingerprints/MinimizedPlayerFingerprint.kt @@ -10,15 +10,10 @@ object MinimizedPlayerFingerprint : MethodFingerprint( access = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L", "L"), opcodes = listOf( - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.SGET_OBJECT, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, - Opcode.CONST_4, Opcode.IF_NEZ, - Opcode.SGET_OBJECT, - Opcode.INVOKE_VIRTUAL + Opcode.IF_EQZ ), strings = listOf("w_st") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt index 29874ab50..dfe3bde1a 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt @@ -11,12 +11,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH -import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @@ -35,15 +33,13 @@ class MinimizedPlayerPatch : BytecodePatch( MinimizedPlayerFingerprint.result?.let { with (it.mutableMethod) { val index = it.scanResult.patternScanResult!!.endIndex - val register = (implementation!!.instructions[index - 1] as OneRegisterInstruction).registerA - 1 - val jumpInstruction = implementation!!.instructions[index + 1] as Instruction + val register = (implementation!!.instructions[index] as OneRegisterInstruction).registerA addInstructions( index, """ - invoke-static {}, $MUSIC_SETTINGS_PATH->enableForceMinimizedPlayer()Z + invoke-static {v$register}, $MUSIC_SETTINGS_PATH->enableForceMinimizedPlayer(Z)Z move-result v$register - if-nez v$register, :enforce - """, listOf(ExternalLabel("enforce", jumpInstruction)) + """ ) } } ?: return MinimizedPlayerFingerprint.toErrorResult()