From 5227e98abfaa2ff1204eb20a0f2671f58c489930 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 31 Jul 2024 01:12:21 +0200 Subject: [PATCH] fix: Downgrade smali to fix dex compilation issue --- api/revanced-patcher.api | 6 ++++-- gradle/libs.versions.toml | 4 +++- src/main/kotlin/app/revanced/patcher/Patcher.kt | 2 +- src/main/kotlin/app/revanced/patcher/PatcherContext.kt | 5 ++++- src/test/kotlin/app/revanced/patcher/PatcherTest.kt | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/revanced-patcher.api b/api/revanced-patcher.api index 77c31d3..694b29f 100644 --- a/api/revanced-patcher.api +++ b/api/revanced-patcher.api @@ -67,7 +67,8 @@ public final class app/revanced/patcher/PatcherConfig { public synthetic fun (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V } -public final class app/revanced/patcher/PatcherContext { +public final class app/revanced/patcher/PatcherContext : java/io/Closeable { + public fun close ()V public final fun getPackageMetadata ()Lapp/revanced/patcher/PackageMetadata; } @@ -152,9 +153,10 @@ public final class app/revanced/patcher/patch/BytecodePatchBuilder$InvokedFinger public final fun getValue (Ljava/lang/Void;Lkotlin/reflect/KProperty;)Lapp/revanced/patcher/Match; } -public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext { +public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext, java/io/Closeable { public final fun classBy (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/proxy/ClassProxy; public final fun classByType (Ljava/lang/String;)Lapp/revanced/patcher/util/proxy/ClassProxy; + public fun close ()V public synthetic fun get ()Ljava/lang/Object; public fun get ()Ljava/util/Set; public final fun getClasses ()Lapp/revanced/patcher/util/ProxyClassList; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 198669d..9a2acaa 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,9 @@ kotlin = "2.0.0" kotlinx-coroutines-core = "1.8.1" mockk = "1.13.10" multidexlib2 = "3.0.3.r3" -smali = "3.0.7" +# Tracking https://github.com/google/smali/issues/64. +#noinspection GradleDependency +smali = "3.0.5" binary-compatibility-validator = "0.15.1" xpp3 = "1.1.4c" diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 5c020ed..367a67d 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -154,7 +154,7 @@ class Patcher(private val config: PatcherConfig) : Closeable { } } - override fun close() = context.bytecodeContext.close() + override fun close() = context.close() /** * Compile and save patched APK files. diff --git a/src/main/kotlin/app/revanced/patcher/PatcherContext.kt b/src/main/kotlin/app/revanced/patcher/PatcherContext.kt index 54e6ddc..e09ea0e 100644 --- a/src/main/kotlin/app/revanced/patcher/PatcherContext.kt +++ b/src/main/kotlin/app/revanced/patcher/PatcherContext.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.ResourcePatchContext import brut.androlib.apk.ApkInfo import brut.directory.ExtFile +import java.io.Closeable /** * A context for the patcher containing the current state of the patcher. @@ -12,7 +13,7 @@ import brut.directory.ExtFile * @param config The configuration for the patcher. */ @Suppress("MemberVisibilityCanBePrivate") -class PatcherContext internal constructor(config: PatcherConfig) { +class PatcherContext internal constructor(config: PatcherConfig): Closeable { /** * [PackageMetadata] of the supplied [PatcherConfig.apkFile]. */ @@ -37,4 +38,6 @@ class PatcherContext internal constructor(config: PatcherConfig) { * The context for patches containing the current state of the bytecode. */ internal val bytecodeContext = BytecodePatchContext(config) + + override fun close() = bytecodeContext.close() } diff --git a/src/test/kotlin/app/revanced/patcher/PatcherTest.kt b/src/test/kotlin/app/revanced/patcher/PatcherTest.kt index 4ebf1f0..92895b4 100644 --- a/src/test/kotlin/app/revanced/patcher/PatcherTest.kt +++ b/src/test/kotlin/app/revanced/patcher/PatcherTest.kt @@ -192,6 +192,7 @@ internal object PatcherTest { private operator fun Set>.invoke(): List { every { patcher.context.executablePatches } returns toMutableSet() + every { patcher.context.bytecodeContext.lookupMaps } returns LookupMaps(patcher.context.bytecodeContext.classes) return runBlocking { patcher().toList() } }