mirror of
https://github.com/revanced/revanced-patcher
synced 2025-03-21 19:04:21 +01:00
add: addFiles
method to merge additional dex containers
This commit is contained in:
parent
3144ec872a
commit
08253ee010
@ -36,7 +36,24 @@ class Patcher(
|
|||||||
opcodes = dexFile.opcodes
|
opcodes = dexFile.opcodes
|
||||||
cache = Cache(dexFile.classes.toMutableSet(), SignatureResolver(dexFile.classes, signatures).resolve())
|
cache = Cache(dexFile.classes.toMutableSet(), SignatureResolver(dexFile.classes, signatures).resolve())
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Add additional dex file container to the patcher.
|
||||||
|
* @param files The dex file containers to add to the patcher.
|
||||||
|
* @param throwOnDuplicates If this is set to true, the patcher will throw an exception if a duplicate class has been found.
|
||||||
|
*/
|
||||||
|
fun addFiles(vararg files: File, throwOnDuplicates: Boolean = false) {
|
||||||
|
for (file in files) {
|
||||||
|
val dexFile = MultiDexIO.readDexFile(true, files[0], NAMER, null, null)
|
||||||
|
for (classDef in dexFile.classes) {
|
||||||
|
if (cache.classes.any { it.type == classDef.type }) {
|
||||||
|
// TODO: Use logger and warn about duplicate classes
|
||||||
|
if (throwOnDuplicates)
|
||||||
|
throw Exception("Class ${classDef.type} has already been added to the patcher.")
|
||||||
|
}
|
||||||
|
cache.classes.add(classDef)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Save the patched dex file.
|
* Save the patched dex file.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user