mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-08 15:07:00 +01:00
refactor: Simplify implementation
This commit is contained in:
parent
284a7f0b1a
commit
a928c8c441
@ -13,9 +13,11 @@ import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch.Constant
|
|||||||
import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint
|
import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint
|
||||||
import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint.GET_GMS_CORE_VENDOR_METHOD_NAME
|
import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint.GET_GMS_CORE_VENDOR_METHOD_NAME
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.returnEarly
|
import app.revanced.util.returnEarly
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||||
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference
|
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference
|
||||||
@ -169,23 +171,20 @@ abstract class AbstractGmsCoreSupportPatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun transformPrimeMethod(packageName: String) = primeMethodFingerprint.result?.mutableMethod?.apply {
|
private fun transformPrimeMethod(packageName: String) {
|
||||||
var register = 2
|
primeMethodFingerprint.result?.mutableMethod?.apply {
|
||||||
val index = getInstructions().indexOfFirst {
|
var register = 2
|
||||||
if (it.opcode != Opcode.CONST_STRING) return@indexOfFirst false
|
|
||||||
|
|
||||||
val instructionString = ((it as Instruction21c).reference as StringReference).string
|
val index = getInstructions().indexOfFirst {
|
||||||
if (instructionString != fromPackageName) return@indexOfFirst false
|
if (it.getReference<StringReference>()?.string != fromPackageName) return@indexOfFirst false
|
||||||
|
|
||||||
register = it.registerA
|
register = (it as OneRegisterInstruction).registerA
|
||||||
return@indexOfFirst true
|
return@indexOfFirst true
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceInstruction(
|
replaceInstruction(index, "const-string v$register, \"$packageName\"")
|
||||||
index, "const-string v$register, \"$packageName\""
|
} ?: throw primeMethodFingerprint.exception
|
||||||
)
|
|
||||||
}
|
}
|
||||||
?: throw primeMethodFingerprint.exception
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of permissions, intents and content provider authorities
|
* A collection of permissions, intents and content provider authorities
|
||||||
|
Loading…
Reference in New Issue
Block a user