Skip to content

Commit a44802e

Browse files
fix: Make it work on Android 12 and lower by using existing APIs (#312)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent 4c1c34a commit a44802e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
6262
* Merge the extensions for this set of patches.
6363
*/
6464
internal fun Set<Patch<*>>.mergeExtensions() {
65-
// Lookup map for fast checking if a class exists by its type.
65+
// Lookup map to check if a class exists by its type quickly.
6666
val classesByType = mutableMapOf<String, ClassDef>().apply {
6767
classes.forEach { classDef -> put(classDef.type, classDef) }
6868
}
6969

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

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

0 commit comments

Comments
 (0)