mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-11 22:06:20 +00:00
Compare commits
10 Commits
v3.0.0-dev
...
v3.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93f338a731 | ||
|
|
7dcf15e03b | ||
|
|
41898d7547 | ||
|
|
45dd15f679 | ||
|
|
c2da04a834 | ||
|
|
f556909b9e | ||
|
|
1fa3dd7b8c | ||
|
|
1fcc591222 | ||
|
|
1fd3b83d46 | ||
|
|
7ec9040d41 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
||||
- name: Build with Gradle
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew clean --no-daemon
|
||||
run: ./gradlew build --no-daemon
|
||||
- name: Setup semantic-release
|
||||
run: npm install
|
||||
- name: Release
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,3 +1,19 @@
|
||||
# [3.0.0-dev.4](https://github.com/ReVanced/revanced-cli/compare/v3.0.0-dev.3...v3.0.0-dev.4) (2023-08-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* properly make use of logging facade ([41898d7](https://github.com/ReVanced/revanced-cli/commit/41898d7547690e3130372414515c5645e5dc2634))
|
||||
|
||||
# [3.0.0-dev.3](https://github.com/ReVanced/revanced-cli/compare/v3.0.0-dev.2...v3.0.0-dev.3) (2023-08-23)
|
||||
|
||||
# [3.0.0-dev.2](https://github.com/ReVanced/revanced-cli/compare/v3.0.0-dev.1...v3.0.0-dev.2) (2023-08-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* specify correct class containing entry-point ([1fcc591](https://github.com/ReVanced/revanced-cli/commit/1fcc591222ab67112f2b78174a8b94106846838c))
|
||||
|
||||
# [3.0.0-dev.1](https://github.com/ReVanced/revanced-cli/compare/v2.23.0-dev.5...v3.0.0-dev.1) (2023-08-23)
|
||||
|
||||
|
||||
|
||||
@@ -31,13 +31,9 @@ tasks {
|
||||
expand("projectVersion" to project.version)
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
manifest {
|
||||
attributes("Main-Class" to "app.revanced.cli.main.MainKt")
|
||||
attributes("Main-Class" to "app.revanced.cli.command.MainCommandKt")
|
||||
}
|
||||
minimize {
|
||||
exclude(dependency("org.jetbrains.kotlin:.*"))
|
||||
@@ -46,6 +42,10 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
// Dummy task to fix the Gradle semantic-release plugin.
|
||||
// Remove this if you forked it to support building only.
|
||||
// Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
|
||||
|
||||
@@ -17,7 +17,7 @@ Learn how to ReVanced CLI.
|
||||
adb shell su -c exit
|
||||
```
|
||||
|
||||
2. Get your device serial
|
||||
2. Get your device's serial
|
||||
|
||||
```bash
|
||||
adb devices
|
||||
@@ -54,9 +54,7 @@ Learn how to ReVanced CLI.
|
||||
```
|
||||
|
||||
> **Note**: A default `options.json` file will be automatically generated, if it does not exist
|
||||
without any need of intervention when using the `patch` command.
|
||||
|
||||
```bash
|
||||
without any need for intervention when using the `patch` command.
|
||||
|
||||
- ### 💉 Use ReVanced CLI to patch an APK file but install without root permissions
|
||||
|
||||
@@ -91,7 +89,7 @@ Learn how to ReVanced CLI.
|
||||
Supply them with the option `-m`. If any patches accepted by ReVanced Patcher require ReVanced Integrations,
|
||||
they will be merged into the APK file automatically.
|
||||
|
||||
- ### 🗑️ Uninstall a patched
|
||||
- ### 🗑️ Uninstall a patched APK file
|
||||
```bash
|
||||
java -jar revanced-cli.jar uninstall \
|
||||
--package-name <package-name> \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.parallel = true
|
||||
org.gradle.caching = true
|
||||
kotlin.code.style = official
|
||||
version = 3.0.0-dev.1
|
||||
version = 3.0.0-dev.4
|
||||
|
||||
@@ -8,7 +8,7 @@ kotlin-reflect = "1.9.0"
|
||||
kotlin-test = "1.8.20-RC"
|
||||
kotlinx-coroutines-core = "1.7.1"
|
||||
picocli = "4.7.3"
|
||||
revanced-patcher = "14.0.0"
|
||||
revanced-patcher = "14.1.0"
|
||||
|
||||
[libraries]
|
||||
apksig = { module = "com.android.tools.build:apksig", version.ref = "apksig" }
|
||||
|
||||
@@ -11,10 +11,13 @@ import app.revanced.patcher.patch.PatchOption
|
||||
import picocli.CommandLine.*
|
||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
|
||||
@Command(name = "list-patches", description = ["List patches from supplied patch bundles"])
|
||||
internal object ListPatchesCommand : Runnable {
|
||||
private val logger = Logger.getLogger(ListPatchesCommand::class.java.name)
|
||||
|
||||
@Parameters(
|
||||
description = ["Paths to patch bundles"],
|
||||
arity = "1..*"
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package app.revanced.cli.command
|
||||
|
||||
import app.revanced.cli.logging.impl.DefaultCliLogger
|
||||
import app.revanced.patcher.patch.PatchClass
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.Command
|
||||
import picocli.CommandLine.IVersionProvider
|
||||
import java.util.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
CommandLine(Main).execute(*args)
|
||||
}
|
||||
|
||||
internal typealias PatchList = List<PatchClass>
|
||||
|
||||
internal val logger = DefaultCliLogger()
|
||||
|
||||
object CLIVersionProvider : IVersionProvider {
|
||||
override fun getVersion(): Array<String> {
|
||||
Properties().apply {
|
||||
load(Main::class.java.getResourceAsStream("/app/revanced/cli/version.properties"))
|
||||
}.let {
|
||||
return arrayOf("ReVanced CLI v${it.getProperty("version")}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "revanced-cli",
|
||||
description = ["Command line application to use ReVanced"],
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = CLIVersionProvider::class,
|
||||
subcommands = [
|
||||
ListPatchesCommand::class,
|
||||
PatchCommand::class,
|
||||
UninstallCommand::class,
|
||||
OptionsCommand::class,
|
||||
]
|
||||
)
|
||||
internal object Main
|
||||
67
src/main/kotlin/app/revanced/cli/command/MainCommand.kt
Normal file
67
src/main/kotlin/app/revanced/cli/command/MainCommand.kt
Normal file
@@ -0,0 +1,67 @@
|
||||
package app.revanced.cli.command
|
||||
|
||||
import app.revanced.patcher.patch.PatchClass
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.Command
|
||||
import picocli.CommandLine.IVersionProvider
|
||||
import java.util.*
|
||||
import java.util.logging.*
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
|
||||
Logger.getLogger("").apply {
|
||||
handlers.forEach {
|
||||
it.close()
|
||||
removeHandler(it)
|
||||
}
|
||||
|
||||
object : Handler() {
|
||||
override fun publish(record: LogRecord) = formatter.format(record).let {
|
||||
if (record.level.intValue() > Level.INFO.intValue()) {
|
||||
System.err.write(it.toByteArray())
|
||||
} else {
|
||||
System.out.write(it.toByteArray())
|
||||
}
|
||||
}
|
||||
|
||||
override fun flush() {
|
||||
System.out.flush()
|
||||
System.err.flush()
|
||||
}
|
||||
|
||||
override fun close() = flush()
|
||||
}.also {
|
||||
it.level = Level.ALL
|
||||
it.formatter = SimpleFormatter()
|
||||
}.let(::addHandler)
|
||||
}
|
||||
|
||||
CommandLine(MainCommand).execute(*args)
|
||||
}
|
||||
|
||||
internal typealias PatchList = List<PatchClass>
|
||||
|
||||
object CLIVersionProvider : IVersionProvider {
|
||||
override fun getVersion(): Array<String> {
|
||||
Properties().apply {
|
||||
load(MainCommand::class.java.getResourceAsStream("/app/revanced/cli/version.properties"))
|
||||
}.let {
|
||||
return arrayOf("ReVanced CLI v${it.getProperty("version")}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "revanced-cli",
|
||||
description = ["Command line application to use ReVanced"],
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = CLIVersionProvider::class,
|
||||
subcommands = [
|
||||
ListPatchesCommand::class,
|
||||
PatchCommand::class,
|
||||
UninstallCommand::class,
|
||||
OptionsCommand::class,
|
||||
]
|
||||
)
|
||||
internal object MainCommand
|
||||
@@ -6,12 +6,15 @@ import app.revanced.utils.Options.setOptions
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "options",
|
||||
description = ["Generate options file from patches"],
|
||||
)
|
||||
internal object OptionsCommand : Runnable {
|
||||
private val logger = Logger.getLogger(OptionsCommand::class.java.name)
|
||||
|
||||
@CommandLine.Parameters(
|
||||
description = ["Paths to patch bundles"],
|
||||
arity = "1..*"
|
||||
@@ -41,10 +44,10 @@ internal object OptionsCommand : Runnable {
|
||||
|
||||
override fun run() = if (!path.exists() || overwrite)
|
||||
with(PatchBundleLoader.Jar(*patchBundles)) {
|
||||
if (update) setOptions(path, logger)
|
||||
if (update) setOptions(path)
|
||||
|
||||
Options.serialize(this, prettyPrint = true)
|
||||
.let(path::writeText)
|
||||
}
|
||||
else logger.error("Options file already exists, use --override to override it")
|
||||
else logger.severe("Options file already exists, use --override to override it")
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.cli.command
|
||||
|
||||
import app.revanced.cli.patcher.logging.impl.PatcherLogger
|
||||
import app.revanced.patcher.PatchBundleLoader
|
||||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.PatcherOptions
|
||||
@@ -20,6 +19,7 @@ import kotlinx.coroutines.runBlocking
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
|
||||
@CommandLine.Command(
|
||||
@@ -27,6 +27,8 @@ import java.io.File
|
||||
description = ["Patch the supplied APK file with the supplied patches and integrations"]
|
||||
)
|
||||
internal object PatchCommand: Runnable {
|
||||
private val logger = Logger.getLogger(PatchCommand::class.java.name)
|
||||
|
||||
@CommandLine.Parameters(
|
||||
description = ["APK file to be patched"],
|
||||
arity = "1..1"
|
||||
@@ -144,15 +146,13 @@ internal object PatchCommand: Runnable {
|
||||
// region Prepare
|
||||
|
||||
if (!apk.exists()) {
|
||||
logger.error("Input file ${apk.name} does not exist")
|
||||
logger.severe("Input file ${apk.name} does not exist")
|
||||
return
|
||||
}
|
||||
|
||||
val adbManager = deviceSerial?.let { serial ->
|
||||
if (mount) AdbManager.RootAdbManager(serial, logger) else AdbManager.UserAdbManager(
|
||||
serial,
|
||||
logger
|
||||
)
|
||||
if (mount) AdbManager.RootAdbManager(serial)
|
||||
else AdbManager.UserAdbManager(serial)
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -167,7 +167,7 @@ internal object PatchCommand: Runnable {
|
||||
logger.info("Setting patch options")
|
||||
|
||||
optionsFile.let {
|
||||
if (it.exists()) patches.setOptions(it, logger)
|
||||
if (it.exists()) patches.setOptions(it)
|
||||
else Options.serialize(patches, prettyPrint = true).let(it::writeText)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,6 @@ internal object PatchCommand: Runnable {
|
||||
resourceCachePath,
|
||||
aaptBinaryPath.path,
|
||||
resourceCachePath.absolutePath,
|
||||
PatcherLogger
|
||||
)
|
||||
)
|
||||
|
||||
@@ -193,7 +192,7 @@ internal object PatchCommand: Runnable {
|
||||
runBlocking {
|
||||
apply(false).collect { patchResult ->
|
||||
patchResult.exception?.let {
|
||||
logger.error("${patchResult.patchName} failed:\n${patchResult.exception}")
|
||||
logger.severe("${patchResult.patchName} failed:\n${patchResult.exception}")
|
||||
} ?: logger.info("${patchResult.patchName} succeeded")
|
||||
}
|
||||
}
|
||||
@@ -288,7 +287,7 @@ internal object PatchCommand: Runnable {
|
||||
it.isEmpty() || it.any { version -> version == packageVersion }
|
||||
}
|
||||
|
||||
if (!matchesVersion) return@patch logger.warn(
|
||||
if (!matchesVersion) return@patch logger.warning(
|
||||
"${patch.patchName} is incompatible with version $packageVersion. " +
|
||||
"This patch is only compatible with version " +
|
||||
packages.joinToString(";") { pkg ->
|
||||
@@ -296,14 +295,14 @@ internal object PatchCommand: Runnable {
|
||||
}
|
||||
)
|
||||
|
||||
} ?: return@patch logger.trace(
|
||||
} ?: return@patch logger.fine(
|
||||
"${patch.patchName} is incompatible with $packageName. " +
|
||||
"This patch is only compatible with " +
|
||||
packages.joinToString(", ") { `package` -> `package`.name }
|
||||
)
|
||||
|
||||
return@let
|
||||
} ?: logger.trace("$formattedPatchName: No constraint on packages.")
|
||||
} ?: logger.fine("$formattedPatchName: No constraint on packages.")
|
||||
|
||||
/**
|
||||
* Check if the patch is explicitly included.
|
||||
@@ -329,7 +328,7 @@ internal object PatchCommand: Runnable {
|
||||
val included = implicitlyIncluded || exclusivelyIncluded
|
||||
if (!included) return@patch logger.info("${patch.patchName} excluded by default") // Case 1.
|
||||
|
||||
logger.trace("Adding $formattedPatchName")
|
||||
logger.fine("Adding $formattedPatchName")
|
||||
|
||||
add(patch)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.revanced.cli.command
|
||||
import app.revanced.utils.adb.AdbManager
|
||||
import picocli.CommandLine.*
|
||||
import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
import java.util.logging.Logger
|
||||
|
||||
|
||||
@Command(
|
||||
@@ -10,6 +11,8 @@ import picocli.CommandLine.Help.Visibility.ALWAYS
|
||||
description = ["Uninstall a patched APK file from the devices with the supplied ADB device serials"]
|
||||
)
|
||||
internal object UninstallCommand : Runnable {
|
||||
private val logger = Logger.getLogger(UninstallCommand::class.java.name)
|
||||
|
||||
@Parameters(
|
||||
description = ["ADB device serials"],
|
||||
arity = "1..*"
|
||||
@@ -33,12 +36,12 @@ internal object UninstallCommand : Runnable {
|
||||
override fun run() = try {
|
||||
deviceSerials.forEach {deviceSerial ->
|
||||
if (unmount) {
|
||||
AdbManager.RootAdbManager(deviceSerial, logger)
|
||||
AdbManager.RootAdbManager(deviceSerial)
|
||||
} else {
|
||||
AdbManager.UserAdbManager(deviceSerial, logger)
|
||||
AdbManager.UserAdbManager(deviceSerial)
|
||||
}.uninstall(packageName)
|
||||
}
|
||||
} catch (e: AdbManager.DeviceNotFoundException) {
|
||||
logger.error(e.toString())
|
||||
logger.severe(e.toString())
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package app.revanced.cli.logging
|
||||
|
||||
internal interface CliLogger {
|
||||
fun error(msg: String)
|
||||
fun info(msg: String)
|
||||
fun trace(msg: String)
|
||||
fun warn(msg: String)
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.revanced.cli.logging.impl
|
||||
|
||||
import app.revanced.cli.command.Main
|
||||
import app.revanced.cli.logging.CliLogger
|
||||
import java.util.logging.Logger
|
||||
import java.util.logging.SimpleFormatter
|
||||
|
||||
internal class DefaultCliLogger(
|
||||
private val logger: Logger = Logger.getLogger(Main::class.java.name),
|
||||
private val errorLogger: Logger = Logger.getLogger(logger.name + "Err")
|
||||
) : CliLogger {
|
||||
|
||||
init {
|
||||
logger.useParentHandlers = false
|
||||
if (logger.handlers.isEmpty()) {
|
||||
logger.addHandler(FlushingStreamHandler(System.out, SimpleFormatter()))
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
|
||||
}
|
||||
}
|
||||
|
||||
override fun error(msg: String) = errorLogger.severe(msg)
|
||||
override fun info(msg: String) = logger.info(msg)
|
||||
override fun trace(msg: String) = logger.finest(msg)
|
||||
override fun warn(msg: String) = errorLogger.warning(msg)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package app.revanced.cli.logging.impl
|
||||
|
||||
import java.io.OutputStream
|
||||
import java.util.logging.Formatter
|
||||
import java.util.logging.LogRecord
|
||||
import java.util.logging.StreamHandler
|
||||
|
||||
internal class FlushingStreamHandler(out: OutputStream, format: Formatter) : StreamHandler(out, format) {
|
||||
override fun publish(record: LogRecord) {
|
||||
super.publish(record)
|
||||
flush()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package app.revanced.cli.patcher.logging.impl
|
||||
|
||||
import app.revanced.cli.logging.impl.DefaultCliLogger
|
||||
import java.util.logging.Logger
|
||||
|
||||
internal object PatcherLogger : app.revanced.patcher.logging.Logger{
|
||||
private val logger = DefaultCliLogger(Logger.getLogger(app.revanced.patcher.Patcher::class.java.name))
|
||||
|
||||
override fun error(msg: String) = logger.error(msg)
|
||||
override fun info(msg: String) = logger.info(msg)
|
||||
override fun warn(msg: String)= logger.warn(msg)
|
||||
override fun trace(msg: String)= logger.trace(msg)
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
package app.revanced.utils
|
||||
|
||||
import app.revanced.cli.command.PatchList
|
||||
import app.revanced.cli.logging.CliLogger
|
||||
import app.revanced.patcher.extensions.PatchExtensions.options
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.patch.NoSuchOptionException
|
||||
import app.revanced.utils.Options.PatchOption.Option
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
|
||||
internal object Options {
|
||||
private val logger = Logger.getLogger(Options::class.java.name)
|
||||
|
||||
private var mapper = jacksonObjectMapper()
|
||||
|
||||
/**
|
||||
@@ -53,9 +55,8 @@ internal object Options {
|
||||
* Sets the options for the patches in the list.
|
||||
*
|
||||
* @param json The JSON string containing the options.
|
||||
* @param logger The logger to use for logging.
|
||||
*/
|
||||
fun PatchList.setOptions(json: String, logger: CliLogger? = null) {
|
||||
fun PatchList.setOptions(json: String) {
|
||||
filter { it.options?.any() == true }.let { patches ->
|
||||
if (patches.isEmpty()) return
|
||||
|
||||
@@ -66,9 +67,9 @@ internal object Options {
|
||||
it.options.forEach { option ->
|
||||
try {
|
||||
patch.options?.set(option.key, option.value)
|
||||
?: logger?.warn("${patch.patchName} has no options")
|
||||
?: logger.warning("${patch.patchName} has no options")
|
||||
} catch (e: NoSuchOptionException) {
|
||||
logger?.error(e.message ?: "Unknown error")
|
||||
logger.info(e.message ?: "Unknown error")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,10 +81,9 @@ internal object Options {
|
||||
* Sets the options for the patches in the list.
|
||||
*
|
||||
* @param file The file containing the JSON string containing the options.
|
||||
* @param logger The logger to use for logging.
|
||||
* @see setOptions
|
||||
*/
|
||||
fun PatchList.setOptions(file: File, logger: CliLogger? = null) = setOptions(file.readText(), logger)
|
||||
fun PatchList.setOptions(file: File) = setOptions(file.readText())
|
||||
|
||||
/**
|
||||
* Data class for a patch and its [Option]s.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.utils.adb
|
||||
|
||||
import app.revanced.cli.logging.CliLogger
|
||||
import app.revanced.utils.adb.AdbManager.Apk
|
||||
import app.revanced.utils.adb.Constants.COMMAND_CREATE_DIR
|
||||
import app.revanced.utils.adb.Constants.COMMAND_DELETE
|
||||
@@ -19,18 +18,21 @@ import se.vidstige.jadb.managers.Package
|
||||
import se.vidstige.jadb.managers.PackageManager
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
/**
|
||||
* Adb manager. Used to install and uninstall [Apk] files.
|
||||
*
|
||||
* @param deviceSerial The serial of the device.
|
||||
*/
|
||||
internal sealed class AdbManager(deviceSerial: String? = null, protected val logger: CliLogger? = null) : Closeable {
|
||||
internal sealed class AdbManager(deviceSerial: String? = null) : Closeable {
|
||||
protected val logger: Logger = Logger.getLogger(AdbManager::class.java.name)
|
||||
|
||||
protected val device = JadbConnection().devices.find { device -> device.serial == deviceSerial }
|
||||
?: throw DeviceNotFoundException(deviceSerial)
|
||||
|
||||
init {
|
||||
logger?.trace("Established connection to $deviceSerial")
|
||||
logger.fine("Established connection to $deviceSerial")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +41,7 @@ internal sealed class AdbManager(deviceSerial: String? = null, protected val log
|
||||
* @param apk The [Apk] file.
|
||||
*/
|
||||
open fun install(apk: Apk) {
|
||||
logger?.info("Finished installing ${apk.file.name}")
|
||||
logger.info("Finished installing ${apk.file.name}")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,23 +50,23 @@ internal sealed class AdbManager(deviceSerial: String? = null, protected val log
|
||||
* @param packageName The package name.
|
||||
*/
|
||||
open fun uninstall(packageName: String) {
|
||||
logger?.info("Finished uninstalling $packageName")
|
||||
logger.info("Finished uninstalling $packageName")
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the [AdbManager] instance.
|
||||
*/
|
||||
override fun close() {
|
||||
logger?.trace("Closed")
|
||||
logger.fine("Closed")
|
||||
}
|
||||
|
||||
class RootAdbManager(deviceSerial: String, logger: CliLogger? = null) : AdbManager(deviceSerial, logger) {
|
||||
class RootAdbManager(deviceSerial: String) : AdbManager(deviceSerial) {
|
||||
init {
|
||||
if (!device.hasSu()) throw IllegalArgumentException("Root required on $deviceSerial. Task failed")
|
||||
}
|
||||
|
||||
override fun install(apk: Apk) {
|
||||
logger?.info("Installing by mounting")
|
||||
logger.info("Installing by mounting")
|
||||
|
||||
val applyReplacement = getPlaceholderReplacement(
|
||||
apk.packageName ?: throw IllegalArgumentException("Package name is required")
|
||||
@@ -86,7 +88,7 @@ internal sealed class AdbManager(deviceSerial: String? = null, protected val log
|
||||
}
|
||||
|
||||
override fun uninstall(packageName: String) {
|
||||
logger?.info("Uninstalling $packageName by unmounting and deleting the package")
|
||||
logger.info("Uninstalling $packageName by unmounting and deleting the package")
|
||||
|
||||
val applyReplacement = getPlaceholderReplacement(packageName)
|
||||
|
||||
@@ -103,7 +105,7 @@ internal sealed class AdbManager(deviceSerial: String? = null, protected val log
|
||||
}
|
||||
}
|
||||
|
||||
class UserAdbManager(deviceSerial: String, logger: CliLogger? = null) : AdbManager(deviceSerial, logger) {
|
||||
class UserAdbManager(deviceSerial: String) : AdbManager(deviceSerial) {
|
||||
private val packageManager = PackageManager(device)
|
||||
|
||||
override fun install(apk: Apk) {
|
||||
@@ -113,7 +115,7 @@ internal sealed class AdbManager(deviceSerial: String? = null, protected val log
|
||||
}
|
||||
|
||||
override fun uninstall(packageName: String) {
|
||||
logger?.info("Uninstalling $packageName")
|
||||
logger.info("Uninstalling $packageName")
|
||||
|
||||
packageManager.uninstall(Package(packageName))
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.utils.signing
|
||||
|
||||
import app.revanced.cli.command.logger
|
||||
import com.android.apksig.ApkSigner
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo
|
||||
@@ -16,10 +15,13 @@ import java.math.BigInteger
|
||||
import java.security.*
|
||||
import java.security.cert.X509Certificate
|
||||
import java.util.*
|
||||
import java.util.logging.Logger
|
||||
|
||||
internal class ApkSigner(
|
||||
private val signingOptions: SigningOptions
|
||||
) {
|
||||
private val logger = Logger.getLogger(ApkSigner::class.java.name)
|
||||
|
||||
private val signer: ApkSigner.Builder
|
||||
private val passwordCharArray = signingOptions.password.toCharArray()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user