From 1a3db77c21b5795220fbac1ec36827fc521fface Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 21 Jun 2022 18:30:10 +0200 Subject: [PATCH] feat: use `install` mode by default --- .../app/revanced/cli/command/MainCommand.kt | 19 ++++++++----------- .../app/revanced/cli/patcher/Patcher.kt | 2 +- .../app/revanced/utils/patcher/Patcher.kt | 6 +++--- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt index 40094df..2da2ecc 100644 --- a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt @@ -41,11 +41,8 @@ internal object MainCommand : Runnable { @Option(names = ["-o", "--out"], description = ["Output file path"], required = true) lateinit var outputPath: String - @Option( - names = ["-i", "--include"], - description = ["Which patches to include. If none is specified, all compatible default patches will be included"] - ) - var includedPatches = arrayOf() + @Option(names = ["-e", "--exclude"], description = ["Explicitly exclude patches"]) + var excludedPatches = arrayOf() @Option(names = ["-r", "--resource-patcher"], description = ["Disable patching resources"]) var disableResourcePatching: Boolean = false @@ -56,8 +53,8 @@ internal object MainCommand : Runnable { @Option(names = ["-m", "--merge"], description = ["One or more dex file containers to merge"]) var mergeFiles = listOf() - @Option(names = ["--install"], description = ["If specified, instead of mounting, install"]) - var install: Boolean = false + @Option(names = ["--mount"], description = ["If specified, instead of installing, mount"]) + var mount: Boolean = false @Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"]) var cn = "ReVanced" @@ -86,7 +83,7 @@ internal object MainCommand : Runnable { return } - val args = args.pArgs?: return + val args = args.pArgs ?: return val patcher = app.revanced.patcher.Patcher( PatcherOptions( @@ -97,17 +94,17 @@ internal object MainCommand : Runnable { val outputFile = File(args.outputPath) val adb: Adb? = args.deploy?.let { - Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, args.install) + Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, !args.mount) } val patchedFile = - if (args.install) File(args.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk") else outputFile + if (args.mount) outputFile else File(args.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk") Patcher.start(patcher, patchedFile) println("[aligning & signing]") - if (args.install) { + if (args.mount) { Signing.start( patchedFile, outputFile, diff --git a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt index 5d44415..d3489ff 100644 --- a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt @@ -15,7 +15,7 @@ internal object Patcher { // merge files like necessary integrations patcher.mergeFiles() // add patches, but filter incompatible or excluded patches - patcher.addPatchesFiltered(includeFilter = args.includedPatches.isNotEmpty()) + patcher.addPatchesFiltered(excludePatches = args.excludedPatches.isNotEmpty()) // apply patches patcher.applyPatchesVerbose() diff --git a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt index e322a20..1b61781 100644 --- a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.base.Patch import app.revanced.patcher.util.patch.implementation.JarPatchBundle fun Patcher.addPatchesFiltered( - includeFilter: Boolean = false + excludePatches: Boolean = false ) { val packageName = this.data.packageMetadata.packageName val packageVersion = this.data.packageMetadata.packageVersion @@ -26,8 +26,8 @@ fun Patcher.addPatchesFiltered( val args = MainCommand.args.pArgs!! - if (includeFilter) { - if (!args.includedPatches.contains(patchName)) { + if (excludePatches) { + if (args.excludedPatches.contains(patchName)) { println("$prefix: Explicitly excluded.") return@patch }