mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-01-10 19:25:51 +01:00
feat: support for --install
This commit is contained in:
parent
cf1d512f4b
commit
d1ceab45c8
@ -2,11 +2,12 @@ package app.revanced.utils.adb
|
|||||||
|
|
||||||
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 java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
internal class Adb(
|
internal class Adb(
|
||||||
private val apk: File,
|
private val file: File,
|
||||||
private val packageName: String,
|
private val packageName: String,
|
||||||
deviceName: String,
|
deviceName: String,
|
||||||
private val install: Boolean = false,
|
private val install: Boolean = false,
|
||||||
@ -27,13 +28,11 @@ internal class Adb(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun deploy() {
|
internal fun deploy() {
|
||||||
|
|
||||||
if (install) {
|
if (install) {
|
||||||
TODO("support installing the apk")
|
PackageManager(device).install(file)
|
||||||
device.run(Constants.COMMAND_INSTALL_APK.replacePlaceholder("\"$apk\""))
|
|
||||||
} else {
|
} else {
|
||||||
// push patched file
|
// push patched file
|
||||||
device.copy(Constants.PATH_INIT_PUSH, apk)
|
device.copy(Constants.PATH_INIT_PUSH, file)
|
||||||
|
|
||||||
// create revanced path
|
// create revanced path
|
||||||
device.run("${Constants.COMMAND_CREATE_DIR} ${Constants.PATH_REVANCED}")
|
device.run("${Constants.COMMAND_CREATE_DIR} ${Constants.PATH_REVANCED}")
|
||||||
@ -61,13 +60,13 @@ internal class Adb(
|
|||||||
device.run(Constants.PATH_UMOUNT.replacePlaceholder())
|
device.run(Constants.PATH_UMOUNT.replacePlaceholder())
|
||||||
// mount the apk
|
// mount the apk
|
||||||
device.run(Constants.PATH_MOUNT.replacePlaceholder())
|
device.run(Constants.PATH_MOUNT.replacePlaceholder())
|
||||||
|
|
||||||
|
// relaunch app
|
||||||
|
device.run(Constants.COMMAND_RESTART.replacePlaceholder())
|
||||||
|
|
||||||
|
// log the app
|
||||||
|
log()
|
||||||
}
|
}
|
||||||
|
|
||||||
// relaunch app
|
|
||||||
device.run(Constants.COMMAND_RESTART.replacePlaceholder())
|
|
||||||
|
|
||||||
// log the app
|
|
||||||
log()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun log() {
|
private fun log() {
|
||||||
|
@ -15,7 +15,7 @@ internal object Constants {
|
|||||||
private const val NAME_MOUNT_SCRIPT = "mount_revanced_$PLACEHOLDER.sh"
|
private const val NAME_MOUNT_SCRIPT = "mount_revanced_$PLACEHOLDER.sh"
|
||||||
|
|
||||||
// initial directory to push files to via adb push
|
// initial directory to push files to via adb push
|
||||||
internal const val PATH_INIT_PUSH = "/sdcard/revanced.delete"
|
internal const val PATH_INIT_PUSH = "/data/local/tmp/revanced.delete"
|
||||||
|
|
||||||
// revanced path
|
// revanced path
|
||||||
internal const val PATH_REVANCED = "/data/adb/revanced/"
|
internal const val PATH_REVANCED = "/data/adb/revanced/"
|
||||||
@ -37,9 +37,6 @@ internal object Constants {
|
|||||||
// install umount script & set permissions
|
// install umount script & set permissions
|
||||||
internal const val COMMAND_INSTALL_UMOUNT = "mv $PATH_INIT_PUSH $PATH_UMOUNT && $COMMAND_CHMOD_MOUNT $PATH_UMOUNT"
|
internal const val COMMAND_INSTALL_UMOUNT = "mv $PATH_INIT_PUSH $PATH_UMOUNT && $COMMAND_CHMOD_MOUNT $PATH_UMOUNT"
|
||||||
|
|
||||||
// install apk & cleanup
|
|
||||||
internal const val COMMAND_INSTALL_APK = "install $PLACEHOLDER"
|
|
||||||
|
|
||||||
// unmount script
|
// unmount script
|
||||||
internal val CONTENT_UMOUNT_SCRIPT =
|
internal val CONTENT_UMOUNT_SCRIPT =
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user