mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-13 18:17:06 +02:00
refactor: cleanup SignatureResolver.kt
This commit is contained in:
parent
45303f66ec
commit
eef448cc39
@ -59,28 +59,33 @@ internal class SignatureResolver(
|
|||||||
signature: MethodSignature,
|
signature: MethodSignature,
|
||||||
method: Method
|
method: Method
|
||||||
): PatternScanResult? {
|
): PatternScanResult? {
|
||||||
signature.returnType?.let { _ ->
|
signature.returnType?.let {
|
||||||
if (!method.returnType.startsWith(signature.returnType)) return@compareSignatureToMethod null
|
if (!method.returnType.startsWith(signature.returnType)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signature.accessFlags?.let { _ ->
|
signature.accessFlags?.let {
|
||||||
if (signature.accessFlags != method.accessFlags) {
|
if (signature.accessFlags != method.accessFlags) {
|
||||||
return@compareSignatureToMethod null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signature.methodParameters?.let { _ ->
|
signature.methodParameters?.let {
|
||||||
if (signature.methodParameters.count() != method.parameterTypes.count() || !signature.methodParameters.all { signatureMethodParameter ->
|
if (compareParameterTypes(signature.methodParameters, method.parameterTypes)) {
|
||||||
method.parameterTypes.any { methodParameter ->
|
return null
|
||||||
methodParameter.startsWith(signatureMethodParameter)
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
return@compareSignatureToMethod null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (signature.opcodes == null) null
|
return if (signature.opcodes == null) {
|
||||||
else method.implementation?.instructions?.scanFor(signature.opcodes)!!
|
null
|
||||||
|
} else {
|
||||||
|
method.implementation?.instructions?.scanFor(signature.opcodes)!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compareParameterTypes(signature: Array<String>, original: MutableList<out CharSequence>): Boolean {
|
||||||
|
return signature.size != original.size || !(signature.all { a -> original.any { it.startsWith(a) } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user