fix(enable-black-navbar): cannot switch off when amoled patch is included

This commit is contained in:
inotia00 2023-05-03 19:41:53 +09:00
parent c93e3ce789
commit 59d465a8ef

View File

@ -12,7 +12,6 @@ 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.blacknavbar.fingerprints.TabLayoutFingerprint
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
@ -20,7 +19,6 @@ import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@Patch
@Name("enable-black-navbar")
@ -42,20 +40,16 @@ class BlackNavbarPatch : BytecodePatch(
TabLayoutFingerprint.result?.let {
with (it.mutableMethod) {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val endIndex = it.scanResult.patternScanResult!!.endIndex
val insertIndex = endIndex + 1
val dummyRegister = (instruction(startIndex) as Instruction31i).registerA
val targetRegister = (instruction(endIndex) as Instruction11x).registerA
addInstructions(
insertIndex, """
invoke-static {}, $MUSIC_LAYOUT->enableBlackNavbar()Z
move-result v$dummyRegister
if-eqz v$dummyRegister, :default
const/high16 v$targetRegister, -0x1000000
""", listOf(ExternalLabel("default", instruction(insertIndex)))
invoke-static {}, $MUSIC_LAYOUT->enableBlackNavbar()I
move-result v$targetRegister
"""
)
}
} ?: return TabLayoutFingerprint.toErrorResult()