Skip to content

Commit

Permalink
feat: use install mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 21, 2022
1 parent 430de23 commit 1a3db77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
19 changes: 8 additions & 11 deletions src/main/kotlin/app/revanced/cli/command/MainCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>()
@Option(names = ["-e", "--exclude"], description = ["Explicitly exclude patches"])
var excludedPatches = arrayOf<String>()

@Option(names = ["-r", "--resource-patcher"], description = ["Disable patching resources"])
var disableResourcePatching: Boolean = false
Expand All @@ -56,8 +53,8 @@ internal object MainCommand : Runnable {
@Option(names = ["-m", "--merge"], description = ["One or more dex file containers to merge"])
var mergeFiles = listOf<File>()

@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"
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/app/revanced/cli/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/app/revanced/utils/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 1a3db77

Please sign in to comment.