mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-19 09:23:58 +00:00
feat: use of java.util.logging.Logger
This commit is contained in:
@@ -10,11 +10,14 @@ import app.revanced.utils.adb.Adb
|
||||
import picocli.CommandLine.*
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.logging.Logger
|
||||
|
||||
@Command(
|
||||
name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true
|
||||
)
|
||||
internal object MainCommand : Runnable {
|
||||
val logger: Logger = Logger.getLogger(MainCommand.javaClass.name)
|
||||
|
||||
@ArgGroup(exclusive = false, multiplicity = "1")
|
||||
lateinit var args: Args
|
||||
|
||||
@@ -76,15 +79,19 @@ internal object MainCommand : Runnable {
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
|
||||
|
||||
if (args.lArgs?.listOnly == true) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
println("[available] ${patch.patchName}: ${patch.description}")
|
||||
logger.info("${patch.patchName}: ${patch.description}")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val args = args.pArgs ?: return
|
||||
|
||||
logger.info("Initialize patcher")
|
||||
|
||||
val patcher = app.revanced.patcher.Patcher(
|
||||
PatcherOptions(
|
||||
args.inputFile, args.cacheDirectory, !args.disableResourcePatching
|
||||
@@ -102,8 +109,6 @@ internal object MainCommand : Runnable {
|
||||
|
||||
Patcher.start(patcher, patchedFile)
|
||||
|
||||
println("[aligning & signing]")
|
||||
|
||||
if (!args.mount) {
|
||||
Signing.start(
|
||||
patchedFile,
|
||||
@@ -115,13 +120,10 @@ internal object MainCommand : Runnable {
|
||||
|
||||
if (args.clean) File(args.cacheDirectory).deleteRecursively()
|
||||
|
||||
adb?.let {
|
||||
println("[deploying]")
|
||||
it.deploy()
|
||||
}
|
||||
adb?.deploy()
|
||||
|
||||
if (args.clean && args.deploy != null) Files.delete(outputFile.toPath())
|
||||
|
||||
println("[done]")
|
||||
logger.info("Done")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package app.revanced.cli.patcher
|
||||
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.utils.filesystem.ZipFileSystemUtils
|
||||
import app.revanced.utils.patcher.addPatchesFiltered
|
||||
import app.revanced.utils.patcher.applyPatchesVerbose
|
||||
@@ -30,9 +31,13 @@ internal object Patcher {
|
||||
ZipFileSystemUtils(inputFile, output).use { fileSystem ->
|
||||
// replace all dex files
|
||||
result.dexFiles.forEach {
|
||||
logger.info("Write ${it.name}")
|
||||
|
||||
fileSystem.write(it.name, it.dexFileInputStream.readAllBytes())
|
||||
}
|
||||
|
||||
logger.info("Write resources")
|
||||
|
||||
// inputFile being null implies resource patching being disabled
|
||||
if (inputFile != null) {
|
||||
// write resources
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package app.revanced.cli.signing
|
||||
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.utils.signing.Signer
|
||||
import app.revanced.utils.signing.align.ZipAligner
|
||||
import java.io.File
|
||||
@@ -11,8 +12,13 @@ object Signing {
|
||||
val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
|
||||
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
|
||||
|
||||
logger.info("Align zip entries")
|
||||
|
||||
// align the inputFile and write to alignedOutput
|
||||
ZipAligner.align(inputFile, alignedOutput)
|
||||
|
||||
logger.info("Sign zip file")
|
||||
|
||||
// sign the alignedOutput and write to signedOutput
|
||||
// the reason is, in case the signer fails
|
||||
// it does not damage the output file
|
||||
|
||||
Reference in New Issue
Block a user