mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 13:20:19 +02:00
fix: hide-get-premium
patch breaks account popup layout in tablet
This commit is contained in:
parent
7d4d34a206
commit
3bd503da8e
@ -6,31 +6,28 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.data.toMethodWalker
|
||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint
|
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint
|
||||||
import app.revanced.patches.music.misc.integrations.patch.MusicIntegrationsPatch
|
|
||||||
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
||||||
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
|
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
|
||||||
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
|
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||||
|
import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-get-premium")
|
@Name("hide-get-premium")
|
||||||
@Description("Removes all \"Get Premium\" evidences from the avatar menu.")
|
@Description("Removes all \"Get Premium\" evidences from the avatar menu.")
|
||||||
@DependsOn(
|
@DependsOn([ResourceMappingPatch::class])
|
||||||
[
|
|
||||||
ResourceMappingPatch::class,
|
|
||||||
MusicIntegrationsPatch::class
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@YouTubeMusicCompatibility
|
@YouTubeMusicCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class HideGetPremiumPatch : BytecodePatch(
|
class HideGetPremiumPatch : BytecodePatch(
|
||||||
@ -40,9 +37,11 @@ class HideGetPremiumPatch : BytecodePatch(
|
|||||||
) {
|
) {
|
||||||
// list of resource names to get the id of
|
// list of resource names to get the id of
|
||||||
private val resourceIds = arrayOf(
|
private val resourceIds = arrayOf(
|
||||||
"unlimited_panel"
|
"id" to "privacy_tos_footer"
|
||||||
).map { name ->
|
).map { (type, name) ->
|
||||||
ResourceMappingPatch.resourceMappings.single { it.name == name }.id
|
ResourceMappingPatch
|
||||||
|
.resourceMappings
|
||||||
|
.single { it.type == type && it.name == name }.id
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
@ -67,18 +66,36 @@ class HideGetPremiumPatch : BytecodePatch(
|
|||||||
Opcode.CONST -> {
|
Opcode.CONST -> {
|
||||||
when ((instruction as Instruction31i).wideLiteral) {
|
when ((instruction as Instruction31i).wideLiteral) {
|
||||||
resourceIds[0] -> {
|
resourceIds[0] -> {
|
||||||
val insertIndex = index + 3
|
val viewIndex = index + 5
|
||||||
val iPutInstruction = instructions.elementAt(insertIndex)
|
val viewInstruction = instructions.elementAt(viewIndex)
|
||||||
if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed
|
if (viewInstruction.opcode != Opcode.IGET_OBJECT) return@forEachIndexed
|
||||||
|
|
||||||
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
|
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
|
||||||
|
|
||||||
val viewRegister = (iPutInstruction as Instruction22c).registerA
|
val viewReference = (viewInstruction as? ReferenceInstruction)?.reference as? FieldReference
|
||||||
|
|
||||||
mutableMethod.addInstruction(
|
with (context
|
||||||
insertIndex,
|
.toMethodWalker(mutableMethod)
|
||||||
"invoke-static {v$viewRegister}, $INTEGRATIONS_PATH/adremover/AdRemoverAPI;->HideViewWithLayout1dp(Landroid/view/View;)V"
|
.nextMethod(viewIndex - 1, true)
|
||||||
)
|
.getMethod() as MutableMethod
|
||||||
|
) {
|
||||||
|
val viewInstructions = implementation!!.instructions
|
||||||
|
|
||||||
|
for ((targetIndex, targetInstruction) in viewInstructions.withIndex()) {
|
||||||
|
if (targetInstruction.opcode != Opcode.IGET_OBJECT) continue
|
||||||
|
|
||||||
|
val indexReference = (targetInstruction as ReferenceInstruction).reference as FieldReference
|
||||||
|
|
||||||
|
if (indexReference == viewReference) {
|
||||||
|
val targetRegister = (viewInstructions.elementAt(targetIndex + 2) as OneRegisterInstruction).registerA
|
||||||
|
addInstruction(
|
||||||
|
targetIndex,
|
||||||
|
"const/16 v$targetRegister, 0x8"
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user