diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/Fingerprints.kt index 535739e61..d3d59619c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/Fingerprints.kt @@ -1,8 +1,11 @@ package app.revanced.patches.music.layout.castbutton -import com.android.tools.smali.dexlib2.AccessFlags import app.revanced.patcher.fingerprint -import app.revanced.util.literal +import app.revanced.patcher.opcode +import app.revanced.patches.shared.misc.mapping.ResourceType +import app.revanced.patches.shared.misc.mapping.resourceLiteral +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode internal val mediaRouteButtonFingerprint by fingerprint { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) @@ -13,5 +16,8 @@ internal val mediaRouteButtonFingerprint by fingerprint { internal val playerOverlayChipFingerprint by fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("L") - literal { playerOverlayChip } + instructions( + resourceLiteral(ResourceType.ID, "player_overlay_chip"), + opcode(Opcode.MOVE_RESULT) + ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/HideCastButton.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/HideCastButton.kt index 03b621813..89bc0fe88 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/HideCastButton.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/castbutton/HideCastButton.kt @@ -9,18 +9,10 @@ import app.revanced.patches.all.misc.resources.addResourcesPatch import app.revanced.patches.music.misc.extension.sharedExtensionPatch import app.revanced.patches.music.misc.settings.PreferenceScreen import app.revanced.patches.music.misc.settings.settingsPatch -import app.revanced.patches.shared.misc.mapping.get import app.revanced.patches.shared.misc.mapping.resourceMappingPatch -import app.revanced.patches.shared.misc.mapping.resourceMappings import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.util.indexOfFirstInstructionOrThrow -import app.revanced.util.indexOfFirstLiteralInstructionOrThrow -import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -internal var playerOverlayChip = -1L - private set - private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/patches/HideCastButtonPatch;" @Suppress("unused") @@ -43,8 +35,6 @@ val hideCastButton = bytecodePatch( ) execute { - playerOverlayChip = resourceMappings["id", "player_overlay_chip"] - addResources("music", "layout.castbutton.hideCastButton") PreferenceScreen.GENERAL.addPreferences( @@ -64,13 +54,12 @@ val hideCastButton = bytecodePatch( } playerOverlayChipFingerprint.method.apply { - val resourceIndex = indexOfFirstLiteralInstructionOrThrow(playerOverlayChip) - val targetIndex = indexOfFirstInstructionOrThrow(resourceIndex, Opcode.MOVE_RESULT) - val targetRegister = getInstruction(targetIndex).registerA + val index = playerOverlayChipFingerprint.instructionMatches.last().index + val register = getInstruction(index).registerA addInstruction( - targetIndex + 1, - "invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideCastButton(Landroid/view/View;)V" + index + 1, + "invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->hideCastButton(Landroid/view/View;)V" ) } }