fix(music): enable-force-minimized-player patch is broken

This commit is contained in:
inotia00 2023-02-25 07:23:11 +09:00
parent 956eaa34c9
commit c3813c3a0b
2 changed files with 4 additions and 13 deletions

View File

@ -10,15 +10,10 @@ object MinimizedPlayerFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.FINAL, access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "L"), parameters = listOf("L", "L"),
opcodes = listOf( opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL, Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT, Opcode.MOVE_RESULT,
Opcode.CONST_4,
Opcode.IF_NEZ, Opcode.IF_NEZ,
Opcode.SGET_OBJECT, Opcode.IF_EQZ
Opcode.INVOKE_VIRTUAL
), ),
strings = listOf("w_st") strings = listOf("w_st")
) )

View File

@ -11,12 +11,10 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch 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.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch @Patch
@ -35,15 +33,13 @@ class MinimizedPlayerPatch : BytecodePatch(
MinimizedPlayerFingerprint.result?.let { MinimizedPlayerFingerprint.result?.let {
with (it.mutableMethod) { with (it.mutableMethod) {
val index = it.scanResult.patternScanResult!!.endIndex val index = it.scanResult.patternScanResult!!.endIndex
val register = (implementation!!.instructions[index - 1] as OneRegisterInstruction).registerA - 1 val register = (implementation!!.instructions[index] as OneRegisterInstruction).registerA
val jumpInstruction = implementation!!.instructions[index + 1] as Instruction
addInstructions( addInstructions(
index, """ index, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableForceMinimizedPlayer()Z invoke-static {v$register}, $MUSIC_SETTINGS_PATH->enableForceMinimizedPlayer(Z)Z
move-result v$register move-result v$register
if-nez v$register, :enforce """
""", listOf(ExternalLabel("enforce", jumpInstruction))
) )
} }
} ?: return MinimizedPlayerFingerprint.toErrorResult() } ?: return MinimizedPlayerFingerprint.toErrorResult()