From 38ff1232961406d564fb9121f8cf82af5c79d825 Mon Sep 17 00:00:00 2001 From: Jeff Jankowski Date: Wed, 14 May 2025 20:24:58 -0700 Subject: [PATCH 1/3] creating dex file stream on-demand instead of passing it around --- src/commonMain/kotlin/app/revanced/library/ApkUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt index 63bc123..3f22d72 100644 --- a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt +++ b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt @@ -53,7 +53,7 @@ object ApkUtils { fun PatcherResult.applyTo(apkFile: File) { ZFile.openReadWrite(apkFile, zFileOptions).use { targetApkZFile -> dexFiles.forEach { dexFile -> - targetApkZFile.add(dexFile.name, dexFile.stream) + targetApkZFile.add(dexFile.name, dexFile.file.inputStream()) } resources?.let { resources -> From 2a3408599b6f1f19ed637423bf36cffe66795b7c Mon Sep 17 00:00:00 2001 From: Jeff Jankowski Date: Tue, 27 May 2025 13:12:51 -0700 Subject: [PATCH 2/3] Wrap dex file stream with `use` block --- src/commonMain/kotlin/app/revanced/library/ApkUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt index 3f22d72..2ab66cb 100644 --- a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt +++ b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt @@ -53,7 +53,7 @@ object ApkUtils { fun PatcherResult.applyTo(apkFile: File) { ZFile.openReadWrite(apkFile, zFileOptions).use { targetApkZFile -> dexFiles.forEach { dexFile -> - targetApkZFile.add(dexFile.name, dexFile.file.inputStream()) + dexFile.stream.use { targetApkZFile.add(dexFile.name, it) } } resources?.let { resources -> From d97e792d81cf4c0f221d2b919bddfc6091bf064b Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 28 May 2025 21:34:56 +0200 Subject: [PATCH 3/3] Apply suggestions from code review --- src/commonMain/kotlin/app/revanced/library/ApkUtils.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt index 2ab66cb..7fd077f 100644 --- a/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt +++ b/src/commonMain/kotlin/app/revanced/library/ApkUtils.kt @@ -53,7 +53,8 @@ object ApkUtils { fun PatcherResult.applyTo(apkFile: File) { ZFile.openReadWrite(apkFile, zFileOptions).use { targetApkZFile -> dexFiles.forEach { dexFile -> - dexFile.stream.use { targetApkZFile.add(dexFile.name, it) } + targetApkZFile.add(dexFile.name, dexFile.stream) + dexFile.stream.close() } resources?.let { resources ->