mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-11 12:04:39 +02:00
fix: bypass-ambient-mode-restrictions
patch is broken
This commit is contained in:
parent
2ccafc6b4b
commit
032cea651a
@ -4,16 +4,22 @@ import app.revanced.patcher.extensions.or
|
|||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
|
||||||
|
|
||||||
object PowerSaveModeFingerprint : MethodFingerprint(
|
object PowerSaveModeFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L"),
|
parameters = listOf("L"),
|
||||||
opcodes = listOf(Opcode.SUB_INT_2ADDR),
|
opcodes = listOf(
|
||||||
customFingerprint = { methodDef ->
|
Opcode.IGET_OBJECT,
|
||||||
methodDef.implementation!!.instructions.any {
|
Opcode.CHECK_CAST,
|
||||||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 107243)
|
Opcode.CHECK_CAST,
|
||||||
}
|
Opcode.IGET_OBJECT,
|
||||||
}
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
),
|
||||||
|
customFingerprint = { it.name == "accept" }
|
||||||
)
|
)
|
@ -8,6 +8,7 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
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.PatchResultError
|
||||||
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
|
||||||
@ -31,25 +32,28 @@ class PowerSaveModePatch : BytecodePatch(
|
|||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
PowerSaveModeFingerprint.result?.mutableMethod?.let {
|
PowerSaveModeFingerprint.result?.mutableMethod?.let { method ->
|
||||||
val instructions = it.implementation!!.instructions
|
val instructions = method.implementation!!.instructions
|
||||||
|
var powerManagerIndex = -1
|
||||||
|
|
||||||
for ((index, instruction) in instructions.withIndex()) {
|
for ((index, instruction) in instructions.withIndex()) {
|
||||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue
|
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||||
|
|
||||||
val invokeInstruction = instruction as Instruction35c
|
val invokeInstruction = instruction as Instruction35c
|
||||||
if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode") continue
|
if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode") continue
|
||||||
|
|
||||||
val targetIndex = index + 1
|
powerManagerIndex = index + 1
|
||||||
|
|
||||||
val targetRegister = (instructions.elementAt(targetIndex) as OneRegisterInstruction).registerA
|
val targetRegister = (instructions.elementAt(powerManagerIndex) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
it.addInstructions(
|
method.addInstructions(
|
||||||
targetIndex + 1, """
|
powerManagerIndex + 1, """
|
||||||
invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z
|
invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z
|
||||||
move-result v$targetRegister
|
move-result v$targetRegister
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (powerManagerIndex == -1) return PatchResultError("Couldn't find PowerManager reference")
|
||||||
} ?: return PowerSaveModeFingerprint.toErrorResult()
|
} ?: return PowerSaveModeFingerprint.toErrorResult()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user