mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-01 20:15:45 +02:00
feat: Add (WIP) Signature Checker
This commit is contained in:
parent
80276c7e5b
commit
ae4c7b29f2
3
.gitignore
vendored
3
.gitignore
vendored
@ -112,3 +112,6 @@ gradle-app.setting
|
|||||||
|
|
||||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||||
# gradle/wrapper/gradle-wrapper.properties
|
# gradle/wrapper/gradle-wrapper.properties
|
||||||
|
|
||||||
|
# Potentially copyrighted test APK
|
||||||
|
stock.apk
|
39
src/test/kotlin/app/revanced/patches/SignatureChecker.kt
Normal file
39
src/test/kotlin/app/revanced/patches/SignatureChecker.kt
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package app.revanced.patches
|
||||||
|
|
||||||
|
import app.revanced.patcher.Patcher
|
||||||
|
import app.revanced.patcher.signature.MethodSignature
|
||||||
|
import app.revanced.patcher.signature.PatternScanMethod
|
||||||
|
import org.junit.Test
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
internal class SignatureChecker {
|
||||||
|
@Test
|
||||||
|
fun checkSignatures() {
|
||||||
|
val file = File("stock.apk")
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw IllegalStateException("Missing stock.apk! To run this test, please place stock.apk here: ${file.absolutePath}")
|
||||||
|
}
|
||||||
|
val patcher = Patcher(file)
|
||||||
|
patcher.addPatches(Index.patches.map { it() })
|
||||||
|
val unresolved = mutableListOf<MethodSignature>()
|
||||||
|
for (signature in patcher.resolveSignatures()) {
|
||||||
|
if (!signature.resolved) unresolved.add(signature)
|
||||||
|
|
||||||
|
val patternScanMethod = signature.metadata.patternScanMethod
|
||||||
|
if (patternScanMethod is PatternScanMethod.Fuzzy) {
|
||||||
|
val warnings = patternScanMethod.warnings
|
||||||
|
println("Signature ${signature.metadata.name} had ${warnings.size} warnings!")
|
||||||
|
for (warning in warnings) {
|
||||||
|
println(warning.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unresolved.isNotEmpty()) {
|
||||||
|
val base = Exception("${unresolved.size} signatures were not resolved.")
|
||||||
|
for (signature in unresolved) {
|
||||||
|
base.addSuppressed(Exception("Signature ${signature.metadata.name} was not resolved!"))
|
||||||
|
}
|
||||||
|
throw base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user