Skip to content

Commit

Permalink
fix: Make it work on Android 12 and lower by using existing APIs (#312)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <[email protected]>
  • Loading branch information
LisoUseInAIKyrios and oSumAtrIX authored Oct 15, 2024
1 parent 4c1c34a commit a44802e
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
* Merge the extensions for this set of patches.
*/
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 {
classes.forEach { classDef -> put(classDef.type, classDef) }
}

forEachRecursively { patch ->
if (patch is BytecodePatch && patch.extension != null) {
if (patch !is BytecodePatch) return@forEachRecursively

val extension = patch.extension.readAllBytes()

RawDexIO.readRawDexFile(extension, 0, null).classes.forEach { classDef ->
patch.extension?.use { extensionStream ->
RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef ->
val existingClass = classesByType[classDef.type] ?: run {
logger.fine("Adding class \"$classDef\"")

Expand Down

0 comments on commit a44802e

Please sign in to comment.