mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-04-29 21:04:26 +02:00
fix: Make it work on Android 12 and lower by using existing APIs (#312)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
4c1c34ad01
commit
a44802ef4e
@ -62,17 +62,16 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
|
|||||||
* Merge the extensions for this set of patches.
|
* Merge the extensions for this set of patches.
|
||||||
*/
|
*/
|
||||||
internal fun Set<Patch<*>>.mergeExtensions() {
|
internal fun Set<Patch<*>>.mergeExtensions() {
|
||||||
// Lookup map for fast checking if a class exists by its type.
|
// Lookup map to check if a class exists by its type quickly.
|
||||||
val classesByType = mutableMapOf<String, ClassDef>().apply {
|
val classesByType = mutableMapOf<String, ClassDef>().apply {
|
||||||
classes.forEach { classDef -> put(classDef.type, classDef) }
|
classes.forEach { classDef -> put(classDef.type, classDef) }
|
||||||
}
|
}
|
||||||
|
|
||||||
forEachRecursively { patch ->
|
forEachRecursively { patch ->
|
||||||
if (patch is BytecodePatch && patch.extension != null) {
|
if (patch !is BytecodePatch) return@forEachRecursively
|
||||||
|
|
||||||
val extension = patch.extension.readAllBytes()
|
patch.extension?.use { extensionStream ->
|
||||||
|
RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef ->
|
||||||
RawDexIO.readRawDexFile(extension, 0, null).classes.forEach { classDef ->
|
|
||||||
val existingClass = classesByType[classDef.type] ?: run {
|
val existingClass = classesByType[classDef.type] ?: run {
|
||||||
logger.fine("Adding class \"$classDef\"")
|
logger.fine("Adding class \"$classDef\"")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user