mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-11-03 18:33:55 +01: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 picocli.CommandLine
|
||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
import picocli.CommandLine.ITypeConverter
|
||||
import picocli.CommandLine.Model.CommandSpec
|
||||
import picocli.CommandLine.Spec
|
||||
import java.io.File
|
||||
@ -228,6 +229,14 @@ internal object PatchCommand : Runnable {
|
||||
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() {
|
||||
// region Setup
|
||||
|
||||
@ -318,6 +327,9 @@ internal object PatchCommand : Runnable {
|
||||
patcherResult.applyTo(this)
|
||||
}.let { patchedApkFile ->
|
||||
if (!mount) {
|
||||
val signingLevels = signingLevels.ifEmpty {
|
||||
ApkUtils.readSigningLevels(apk)
|
||||
}
|
||||
ApkUtils.signApk(
|
||||
patchedApkFile,
|
||||
outputFilePath,
|
||||
@ -328,6 +340,7 @@ internal object PatchCommand : Runnable {
|
||||
keyStoreEntryAlias,
|
||||
keyStoreEntryPassword,
|
||||
),
|
||||
signingLevels,
|
||||
)
|
||||
} else {
|
||||
patchedApkFile.copyTo(outputFilePath, overwrite = true)
|
||||
@ -418,4 +431,10 @@ internal object PatchCommand : Runnable {
|
||||
}
|
||||
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