mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
fix(music/hide-upgrade-button): not compatible with latest version
This commit is contained in:
parent
b1adb5f584
commit
4eec203126
@ -1,21 +0,0 @@
|
||||
package app.revanced.patches.music.misc.upgradebutton.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isNarrowLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object PivotBarConstructorFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
opcodes = listOf(
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.name == "<init>" && methodDef.isNarrowLiteralExists(
|
||||
117501096
|
||||
)
|
||||
}
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.music.misc.upgradebutton.fingerprints
|
||||
package app.revanced.patches.music.navigation.upgrade.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.music.misc.upgradebutton.patch
|
||||
package app.revanced.patches.music.navigation.upgrade.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
@ -7,18 +7,20 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.music.misc.upgradebutton.fingerprints.NotifierShelfFingerprint
|
||||
import app.revanced.patches.music.misc.upgradebutton.fingerprints.PivotBarConstructorFingerprint
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.music.navigation.upgrade.fingerprints.NotifierShelfFingerprint
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.fingerprints.TabLayoutTextFingerprint
|
||||
import app.revanced.patches.music.utils.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.util.integrations.Constants.MUSIC_NAVIGATION
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@Name("Hide upgrade button")
|
||||
@ -32,36 +34,36 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@MusicCompatibility
|
||||
class UpgradeButtonPatch : BytecodePatch(
|
||||
listOf(
|
||||
PivotBarConstructorFingerprint,
|
||||
NotifierShelfFingerprint
|
||||
NotifierShelfFingerprint,
|
||||
TabLayoutTextFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
PivotBarConstructorFingerprint.result?.let {
|
||||
TabLayoutTextFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetRegisterA = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
val targetRegisterB = getInstruction<TwoRegisterInstruction>(targetIndex).registerB
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 3
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
val replaceReference =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
||||
val insertIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.AND_INT_LIT8
|
||||
} - 2
|
||||
|
||||
replaceInstruction(
|
||||
targetIndex,
|
||||
"invoke-interface {v$targetRegisterA}, Ljava/util/List;->size()I"
|
||||
)
|
||||
addInstructionsWithLabels(
|
||||
targetIndex + 1, """
|
||||
move-result v1
|
||||
const/4 v2, 0x3
|
||||
if-le v1, v2, :dismiss
|
||||
invoke-interface {v$targetRegisterA, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object;
|
||||
:dismiss
|
||||
iput-object v$targetRegisterA, v$targetRegisterB, $replaceReference
|
||||
"""
|
||||
)
|
||||
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.INVOKE_INTERFACE) continue
|
||||
|
||||
if ((getInstruction<Instruction35c>(index).reference as MethodReference).name != "hasNext") continue
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $MUSIC_NAVIGATION->hideUpgradeButton(Ljava/lang/Enum;)Z
|
||||
move-result v$targetRegister
|
||||
if-nez v$targetRegister, :hide
|
||||
""", ExternalLabel("hide", getInstruction(index))
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
} ?: throw PivotBarConstructorFingerprint.exception
|
||||
} ?: throw TabLayoutTextFingerprint.exception
|
||||
|
||||
NotifierShelfFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
Loading…
x
Reference in New Issue
Block a user