chore: Fix ReplaceWith of Deprecated annotation

This commit is contained in:
oSumAtrIX 2024-02-13 03:27:03 +01:00
parent a430d3c5a1
commit 8dc0133c0b
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -11,23 +11,25 @@ import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.Method
abstract class BaseIntegrationsPatch( abstract class BaseIntegrationsPatch(
private val hooks: Set<IntegrationsFingerprint> private val hooks: Set<IntegrationsFingerprint>,
) : BytecodePatch(hooks) { ) : BytecodePatch(hooks) {
@Deprecated( @Deprecated(
"Use the constructor without the integrationsDescriptor parameter", "Use the constructor without the integrationsDescriptor parameter",
ReplaceWith("AbstractIntegrationsPatch(hooks)") ReplaceWith("BaseIntegrationsPatch(hooks)"),
) )
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
constructor( constructor(
integrationsDescriptor: String, integrationsDescriptor: String,
hooks: Set<IntegrationsFingerprint> hooks: Set<IntegrationsFingerprint>,
) : this(hooks) ) : this(hooks)
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
if (context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR) == null) throw PatchException( if (context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR) == null) {
"Integrations have not been merged yet. This patch can not succeed without merging the integrations." throw PatchException(
"Integrations have not been merged yet. This patch can not succeed without merging the integrations.",
) )
}
hooks.forEach { hook -> hooks.forEach { hook ->
hook.invoke(INTEGRATIONS_CLASS_DESCRIPTOR) hook.invoke(INTEGRATIONS_CLASS_DESCRIPTOR)
@ -47,14 +49,14 @@ abstract class BaseIntegrationsPatch(
opcodes: Iterable<Opcode?>? = null, opcodes: Iterable<Opcode?>? = null,
strings: Iterable<String>? = null, strings: Iterable<String>? = null,
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {} private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {},
) : MethodFingerprint( ) : MethodFingerprint(
returnType, returnType,
accessFlags, accessFlags,
parameters, parameters,
opcodes, opcodes,
strings, strings,
customFingerprint customFingerprint,
) { ) {
fun invoke(integrationsDescriptor: String) { fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method -> result?.mutableMethod?.let { method ->
@ -63,7 +65,7 @@ abstract class BaseIntegrationsPatch(
method.addInstruction( method.addInstruction(
0, 0,
"sput-object v$contextRegister, " + "sput-object v$contextRegister, " +
"$integrationsDescriptor->context:Landroid/content/Context;" "$integrationsDescriptor->context:Landroid/content/Context;",
) )
} ?: throw PatchException("Could not find hook target fingerprint.") } ?: throw PatchException("Could not find hook target fingerprint.")
} }