From 8eb4a8f87ae7679a272f3224273a37a31d4bb121 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Sat, 11 Jun 2022 20:08:00 +0200 Subject: [PATCH] feat: allow custom aapt path to be specified --- src/main/kotlin/app/revanced/patcher/Patcher.kt | 16 ++++++---------- .../app/revanced/patcher/PatcherOptions.kt | 5 +++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index aa4c1009..4653a99e 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -41,11 +41,8 @@ val NAMER = BasicDexFileNamer() * The ReVanced Patcher. * @param options The options for the patcher. */ -class Patcher( - private val options: PatcherOptions -) { +class Patcher(private val options: PatcherOptions) { val data: PatcherData - private val opcodes: Opcodes init { @@ -145,12 +142,11 @@ class Patcher( val cacheDirectory = ExtFile(options.resourceCacheDirectory) val androlibResources = AndrolibResources().also { resources -> - resources.buildOptions = BuildOptions().also { options -> - // TODO: options.useAapt2 = true - // TODO: options.aaptPath = "" - options.isFramework = metaInfo.isFrameworkApk - options.resourcesAreCompressed = metaInfo.compressionType - options.doNotCompress = metaInfo.doNotCompress + resources.buildOptions = BuildOptions().also { buildOptions -> + buildOptions.aaptPath = options.aaptPath + buildOptions.isFramework = metaInfo.isFrameworkApk + buildOptions.resourcesAreCompressed = metaInfo.compressionType + buildOptions.doNotCompress = metaInfo.doNotCompress } resources.setSdkInfo(metaInfo.sdkInfo) diff --git a/src/main/kotlin/app/revanced/patcher/PatcherOptions.kt b/src/main/kotlin/app/revanced/patcher/PatcherOptions.kt index 2e36a28d..a371037d 100644 --- a/src/main/kotlin/app/revanced/patcher/PatcherOptions.kt +++ b/src/main/kotlin/app/revanced/patcher/PatcherOptions.kt @@ -7,10 +7,11 @@ import java.io.File * @param inputFile The input file (usually an apk file). * @param resourceCacheDirectory Directory to cache resources. * @param patchResources Weather to use the resource patcher. Resources will still need to be decoded. + * @param aaptPath Optional path to a custom aapt binary. */ data class PatcherOptions( internal val inputFile: File, - // TODO: maybe a file system in memory is better. Could cause high memory usage. internal val resourceCacheDirectory: String, - internal val patchResources: Boolean = false + internal val patchResources: Boolean = false, + internal val aaptPath: String = "" )