mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-13 02:14:28 +01:00
chore: Fix ReplaceWith
of Deprecated
annotation
This commit is contained in:
parent
a430d3c5a1
commit
8dc0133c0b
1 changed files with 12 additions and 10 deletions
|
@ -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.")
|
||||||
}
|
}
|
||||||
|
@ -76,4 +78,4 @@ abstract class BaseIntegrationsPatch(
|
||||||
private companion object {
|
private companion object {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/shared/Utils;"
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/shared/Utils;"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue