generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} |