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
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89
6 changed files with 21 additions and 51 deletions

View File

@ -33,7 +33,6 @@ dependencies {
implementation(kotlin("reflect")) implementation(kotlin("reflect"))
implementation("app.revanced:revanced-patcher:1.6.0") implementation("app.revanced:revanced-patcher:1.6.0")
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("info.picocli:picocli:4.6.3") implementation("info.picocli:picocli:4.6.3")
implementation("com.android.tools.build:apksig:7.2.1") implementation("com.android.tools.build:apksig:7.2.1")
implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork

View File

@ -2,26 +2,19 @@ package app.revanced.cli.command
import app.revanced.cli.patcher.Patcher import app.revanced.cli.patcher.Patcher
import app.revanced.cli.signing.Signing import app.revanced.cli.signing.Signing
import app.revanced.cli.signing.SigningOptions
import app.revanced.patcher.PatcherOptions import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.util.patch.implementation.JarPatchBundle import app.revanced.patcher.util.patch.implementation.JarPatchBundle
import app.revanced.utils.adb.Adb import app.revanced.utils.adb.Adb
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import picocli.CommandLine.* import picocli.CommandLine.*
import java.io.File import java.io.File
import java.nio.file.Files import java.nio.file.Files
import kotlin.io.path.Path
import kotlin.io.path.name
@Command( @Command(
name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true
) )
internal object MainCommand : Runnable { internal object MainCommand : Runnable {
val logger: Logger = LoggerFactory.getLogger(MainCommand::class.java)
@ArgGroup(exclusive = false, multiplicity = "1") @ArgGroup(exclusive = false, multiplicity = "1")
lateinit var args: Args lateinit var args: Args
@ -66,9 +59,6 @@ internal object MainCommand : Runnable {
@Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"]) @Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"])
var cn = "ReVanced" 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"]) @Option(names = ["-p", "--password"], description = ["Overwrite the default password for the signed file"])
var password = "ReVanced" var password = "ReVanced"
@ -88,15 +78,13 @@ internal object MainCommand : Runnable {
override fun run() { override fun run() {
if (args.lArgs?.listOnly == true) { if (args.lArgs?.listOnly == true) {
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) { for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
logger.info("${patch.patchName}: ${patch.description}") println("[available] ${patch.patchName}: ${patch.description}")
} }
return return
} }
val args = args.pArgs ?: return val args = args.pArgs ?: return
logger.info("Initialize patcher")
val patcher = app.revanced.patcher.Patcher( val patcher = app.revanced.patcher.Patcher(
PatcherOptions( PatcherOptions(
args.inputFile, args.cacheDirectory, !args.disableResourcePatching args.inputFile, args.cacheDirectory, !args.disableResourcePatching
@ -114,23 +102,26 @@ internal object MainCommand : Runnable {
Patcher.start(patcher, patchedFile) Patcher.start(patcher, patchedFile)
println("[aligning & signing]")
if (!args.mount) { if (!args.mount) {
Signing.start( Signing.start(
patchedFile, outputFile, SigningOptions( patchedFile,
args.cn, outputFile,
args.password, args.cn,
args.keystorePath args.password,
?: Path(outputFile.parent).resolve("${outputFile.nameWithoutExtension}.keystore").name
)
) )
} }
if (args.clean) File(args.cacheDirectory).deleteRecursively() 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()) 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 package app.revanced.cli.patcher
import app.revanced.cli.command.MainCommand.args import app.revanced.cli.command.MainCommand.args
import app.revanced.cli.command.MainCommand.logger
import app.revanced.utils.filesystem.ZipFileSystemUtils import app.revanced.utils.filesystem.ZipFileSystemUtils
import app.revanced.utils.patcher.addPatchesFiltered import app.revanced.utils.patcher.addPatchesFiltered
import app.revanced.utils.patcher.applyPatchesVerbose import app.revanced.utils.patcher.applyPatchesVerbose
@ -31,13 +30,9 @@ internal object Patcher {
ZipFileSystemUtils(inputFile, output).use { fileSystem -> ZipFileSystemUtils(inputFile, output).use { fileSystem ->
// replace all dex files // replace all dex files
result.dexFiles.forEach { result.dexFiles.forEach {
logger.info("Write ${it.name}")
fileSystem.write(it.name, it.dexFileInputStream.readAllBytes()) fileSystem.write(it.name, it.dexFileInputStream.readAllBytes())
} }
logger.info("Write resources")
// inputFile being null implies resource patching being disabled // inputFile being null implies resource patching being disabled
if (inputFile != null) { if (inputFile != null) {
// write resources // write resources

View File

@ -1,7 +1,6 @@
package app.revanced.cli.signing package app.revanced.cli.signing
import app.revanced.cli.command.MainCommand.args 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.Signer
import app.revanced.utils.signing.align.ZipAligner import app.revanced.utils.signing.align.ZipAligner
import java.io.File import java.io.File
@ -12,13 +11,8 @@ object Signing {
val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk") val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk") val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
logger.info("Align zip entries")
// align the inputFile and write to alignedOutput // align the inputFile and write to alignedOutput
ZipAligner.align(inputFile, alignedOutput) ZipAligner.align(inputFile, alignedOutput)
logger.info("Sign zip file")
// sign the alignedOutput and write to signedOutput // sign the alignedOutput and write to signedOutput
// the reason is, in case the signer fails // the reason is, in case the signer fails
// it does not damage the output file // it does not damage the output file

View File

@ -1,6 +1,5 @@
package app.revanced.utils.adb package app.revanced.utils.adb
import app.revanced.cli.command.MainCommand.logger
import se.vidstige.jadb.JadbConnection import se.vidstige.jadb.JadbConnection
import se.vidstige.jadb.JadbDevice import se.vidstige.jadb.JadbDevice
import se.vidstige.jadb.managers.PackageManager import se.vidstige.jadb.managers.PackageManager
@ -30,12 +29,8 @@ internal class Adb(
internal fun deploy() { internal fun deploy() {
if (modeInstall) { if (modeInstall) {
logger.info("Install without mount")
PackageManager(device).install(file) PackageManager(device).install(file)
} else { } else {
logger.info("Install by mount")
// push patched file // push patched file
device.copy(Constants.PATH_INIT_PUSH, file) device.copy(Constants.PATH_INIT_PUSH, file)

View File

@ -2,7 +2,6 @@ package app.revanced.utils.patcher
import app.revanced.cli.command.MainCommand import app.revanced.cli.command.MainCommand
import app.revanced.cli.command.MainCommand.args import app.revanced.cli.command.MainCommand.args
import app.revanced.cli.command.MainCommand.logger
import app.revanced.patcher.Patcher import app.revanced.patcher.Patcher
import app.revanced.patcher.data.base.Data import app.revanced.patcher.data.base.Data
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
@ -23,34 +22,33 @@ fun Patcher.addPatchesFiltered(
val compatiblePackages = patch.compatiblePackages val compatiblePackages = patch.compatiblePackages
val patchName = patch.patchName val patchName = patch.patchName
val prefix = "Skip $patchName" val prefix = "[skipped] $patchName"
val args = MainCommand.args.pArgs!! val args = MainCommand.args.pArgs!!
if (excludePatches && args.excludedPatches.contains(patchName)) { if (excludePatches && args.excludedPatches.contains(patchName)) {
logger.info("$prefix: Explicitly excluded") println("$prefix: Explicitly excluded.")
return@patch return@patch
} else if (!patch.include) { } else if (!patch.include) {
logger.info("$prefix: Implicitly excluded") println("$prefix: Implicitly excluded.")
return@patch return@patch
} }
if (compatiblePackages == null) logger.warn("$prefix: Missing compatibility annotation. Continuing.") if (compatiblePackages == null) println("$prefix: Missing compatibility annotation. Continuing.")
else { else {
if (!compatiblePackages.any { it.name == packageName }) { if (!compatiblePackages.any { it.name == packageName }) {
logger.info("$prefix: Incompatible package") println("$prefix: Incompatible package.")
return@patch return@patch
} }
if (!(args.experimental || compatiblePackages.any { it.versions.isEmpty() || it.versions.any { version -> version == packageVersion } })) { if (!(args.experimental || compatiblePackages.any { it.versions.isEmpty() || it.versions.any { version -> version == packageVersion } })) {
logger.info("$prefix: The package version is $packageVersion and is incompatible") println("$prefix: The package version is $packageVersion and is incompatible.")
return@patch return@patch
} }
} }
logger.info("Add $patchName")
includedPatches.add(patch) includedPatches.add(patch)
println("[added] $patchName")
} }
this.addPatches(includedPatches) this.addPatches(includedPatches)
} }
@ -59,12 +57,10 @@ fun Patcher.addPatchesFiltered(
fun Patcher.applyPatchesVerbose() { fun Patcher.applyPatchesVerbose() {
this.applyPatches().forEach { (patch, result) -> this.applyPatches().forEach { (patch, result) ->
if (result.isSuccess) { if (result.isSuccess) {
logger.info("Success: $patch") println("[success] $patch")
return@forEach return@forEach
} }
logger.error("Error: $patch") println("[error] $patch:")
result.exceptionOrNull()!!.printStackTrace() result.exceptionOrNull()!!.printStackTrace()
} }
} }