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,
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")
)

View File

@ -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()