revert: "feat: use of java.util.logging.Logger"

This reverts commit 07f6bdf330.
This reverts commit 6c4c1924ee.
This commit is contained in:
Lucaskyy
2022-06-22 14:36:38 +02:00
parent ea7efd2afc
commit 2c8a106151
6 changed files with 21 additions and 51 deletions

View File

@@ -2,26 +2,19 @@ package app.revanced.cli.command
import app.revanced.cli.patcher.Patcher
import app.revanced.cli.signing.Signing
import app.revanced.cli.signing.SigningOptions
import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
import app.revanced.utils.adb.Adb
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import picocli.CommandLine.*
import java.io.File
import java.nio.file.Files
import kotlin.io.path.Path
import kotlin.io.path.name
@Command(
name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true
)
internal object MainCommand : Runnable {
val logger: Logger = LoggerFactory.getLogger(MainCommand::class.java)
@ArgGroup(exclusive = false, multiplicity = "1")
lateinit var args: Args
@@ -66,9 +59,6 @@ internal object MainCommand : Runnable {
@Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"])
var cn = "ReVanced"
@Option(names = ["--keystore"], description = ["File path to your keystore"])
var keystorePath: String? = null
@Option(names = ["-p", "--password"], description = ["Overwrite the default password for the signed file"])
var password = "ReVanced"
@@ -88,15 +78,13 @@ internal object MainCommand : Runnable {
override fun run() {
if (args.lArgs?.listOnly == true) {
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
logger.info("${patch.patchName}: ${patch.description}")
println("[available] ${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
@@ -114,23 +102,26 @@ internal object MainCommand : Runnable {
Patcher.start(patcher, patchedFile)
println("[aligning & signing]")
if (!args.mount) {
Signing.start(
patchedFile, outputFile, SigningOptions(
args.cn,
args.password,
args.keystorePath
?: Path(outputFile.parent).resolve("${outputFile.nameWithoutExtension}.keystore").name
)
patchedFile,
outputFile,
args.cn,
args.password,
)
}
if (args.clean) File(args.cacheDirectory).deleteRecursively()
adb?.deploy()
adb?.let {
println("[deploying]")
it.deploy()
}
if (args.clean && args.deploy != null) Files.delete(outputFile.toPath())
logger.info("Done")
println("[done]")
}
}

View File

@@ -1,7 +1,6 @@
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
@@ -31,13 +30,9 @@ 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

View File

@@ -1,7 +1,6 @@
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
@@ -12,13 +11,8 @@ 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