mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-06-02 11:26:06 +02:00
feat: Support customize output apk signing levels
This commit is contained in:
parent
6558aafbf1
commit
cd01494874
|
@ -12,6 +12,7 @@ import app.revanced.patcher.PatcherConfig
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import picocli.CommandLine
|
import picocli.CommandLine
|
||||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||||
|
import picocli.CommandLine.ITypeConverter
|
||||||
import picocli.CommandLine.Model.CommandSpec
|
import picocli.CommandLine.Model.CommandSpec
|
||||||
import picocli.CommandLine.Spec
|
import picocli.CommandLine.Spec
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -228,6 +229,14 @@ internal object PatchCommand : Runnable {
|
||||||
this.aaptBinaryPath = aaptBinaryPath
|
this.aaptBinaryPath = aaptBinaryPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CommandLine.Option(
|
||||||
|
names = ["--signing-levels"],
|
||||||
|
description = ["Output apk signing levels, eg. \"1,2,3\", empty as default."],
|
||||||
|
converter = [SigningLevelsConverter::class],
|
||||||
|
arity = "0..1",
|
||||||
|
)
|
||||||
|
private var signingLevels = setOf<Int>()
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
// region Setup
|
// region Setup
|
||||||
|
|
||||||
|
@ -318,6 +327,9 @@ internal object PatchCommand : Runnable {
|
||||||
patcherResult.applyTo(this)
|
patcherResult.applyTo(this)
|
||||||
}.let { patchedApkFile ->
|
}.let { patchedApkFile ->
|
||||||
if (!mount) {
|
if (!mount) {
|
||||||
|
val signingLevels = signingLevels.ifEmpty {
|
||||||
|
ApkUtils.readSigningLevels(apk)
|
||||||
|
}
|
||||||
ApkUtils.signApk(
|
ApkUtils.signApk(
|
||||||
patchedApkFile,
|
patchedApkFile,
|
||||||
outputFilePath,
|
outputFilePath,
|
||||||
|
@ -328,6 +340,7 @@ internal object PatchCommand : Runnable {
|
||||||
keyStoreEntryAlias,
|
keyStoreEntryAlias,
|
||||||
keyStoreEntryPassword,
|
keyStoreEntryPassword,
|
||||||
),
|
),
|
||||||
|
signingLevels,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
patchedApkFile.copyTo(outputFilePath, overwrite = true)
|
patchedApkFile.copyTo(outputFilePath, overwrite = true)
|
||||||
|
@ -418,4 +431,10 @@ internal object PatchCommand : Runnable {
|
||||||
}
|
}
|
||||||
logger.info(result)
|
logger.info(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SigningLevelsConverter : ITypeConverter<Set<Int>> {
|
||||||
|
override fun convert(value: String): Set<Int> {
|
||||||
|
return value.split(',').map { it.trim().toInt() }.toSet()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user