mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-10 15:59:23 +01:00
fix(hide-premium-navbar): remove the correct instructions (#591)
This commit is contained in:
parent
301e72e816
commit
368b36cb48
@ -5,10 +5,9 @@ import app.revanced.patcher.annotation.Version
|
|||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
|
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
|
||||||
|
|
||||||
@Name("debug-menu-activity-fingerprint")
|
@Name("add-premium-navbar-tab-parent-fingerprint")
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
@PremiumNavbarTabCompatibility
|
@PremiumNavbarTabCompatibility
|
||||||
object DebugMenuActivityFingerprint : MethodFingerprint(
|
object AddPremiumNavbarTabParentFingerprint : MethodFingerprint(
|
||||||
strings = listOf("com.spotify.app.music.debugtools.menu.DebugMenuActivity"),
|
strings = listOf("com.samsung.android.samsungaccount.action.REQUEST_AUTHCODE")
|
||||||
parameters = listOf("L", "L"),
|
|
||||||
)
|
)
|
@ -13,40 +13,48 @@ import app.revanced.patcher.patch.annotations.Patch
|
|||||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
|
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
|
||||||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabFingerprint
|
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabFingerprint
|
||||||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.DebugMenuActivityFingerprint
|
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabParentFingerprint
|
||||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch
|
import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-premium-nav-bar")
|
@Name("hide-premium-navbar")
|
||||||
@Description("Removes the premium tab from the navbar.")
|
@Description("Removes the premium tab from the navbar.")
|
||||||
@PremiumNavbarTabCompatibility
|
@PremiumNavbarTabCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
@DependsOn([ResourceIdMappingProviderResourcePatch::class])
|
@DependsOn([ResourceIdMappingProviderResourcePatch::class])
|
||||||
class PremiumNavbarTabPatch : BytecodePatch(
|
class PremiumNavbarTabPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
DebugMenuActivityFingerprint
|
AddPremiumNavbarTabParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(data: BytecodeData): PatchResult {
|
override fun execute(data: BytecodeData): PatchResult {
|
||||||
val parentResult = DebugMenuActivityFingerprint.result!!
|
val parentResult = AddPremiumNavbarTabParentFingerprint.result!!
|
||||||
AddPremiumNavbarTabFingerprint.resolve(data, parentResult.classDef)
|
AddPremiumNavbarTabFingerprint.resolve(data, parentResult.classDef)
|
||||||
|
|
||||||
val result = AddPremiumNavbarTabFingerprint.result!!
|
val result = AddPremiumNavbarTabFingerprint.result!!
|
||||||
|
|
||||||
val method = result.mutableMethod
|
val method = result.mutableMethod
|
||||||
|
|
||||||
val premiumTabId = ResourceIdMappingProviderResourcePatch.resourceMappings.single{it.type == "id" && it.name == "premium_tab"}.id.toInt()
|
|
||||||
|
|
||||||
val methodInstructions = method.implementation!!.instructions
|
val methodInstructions = method.implementation!!.instructions
|
||||||
|
val lastInstructionIdx = methodInstructions.size - 1
|
||||||
|
|
||||||
|
val premiumTabId = ResourceIdMappingProviderResourcePatch.resourceMappings.single{it.type == "id" && it.name == "premium_tab"}.id
|
||||||
|
|
||||||
|
var removeAmount = 2
|
||||||
|
// 2nd const remove method
|
||||||
for ((i, instruction) in methodInstructions.asReversed().withIndex()) {
|
for ((i, instruction) in methodInstructions.asReversed().withIndex()) {
|
||||||
if (instruction.opcode.ordinal != Opcode.CONST.ordinal) continue
|
if (instruction.opcode.ordinal != Opcode.CONST.ordinal) continue
|
||||||
if ((instruction as OneRegisterInstruction).registerA != premiumTabId) continue
|
if ((instruction as WideLiteralInstruction).wideLiteral != premiumTabId) continue
|
||||||
val constIdx = methodInstructions.size - i
|
|
||||||
val methodIdx = constIdx + 8
|
val findThreshold = 10
|
||||||
method.removeInstruction(methodIdx)
|
val constIndex = lastInstructionIdx - i
|
||||||
break
|
val invokeInstruction = methodInstructions.subList(constIndex, constIndex + findThreshold).first {
|
||||||
|
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL_RANGE.ordinal
|
||||||
|
}
|
||||||
|
method.removeInstruction(methodInstructions.indexOf(invokeInstruction))
|
||||||
|
|
||||||
|
if (--removeAmount == 0) break
|
||||||
}
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
|
Loading…
Reference in New Issue
Block a user