feat: support for --install

This commit is contained in:
oSumAtrIX 2022-06-11 20:02:37 +02:00
parent cf1d512f4b
commit d1ceab45c8
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 11 additions and 15 deletions

View File

@ -2,11 +2,12 @@ package app.revanced.utils.adb
import se.vidstige.jadb.JadbConnection
import se.vidstige.jadb.JadbDevice
import se.vidstige.jadb.managers.PackageManager
import java.io.File
import java.util.concurrent.Executors
internal class Adb(
private val apk: File,
private val file: File,
private val packageName: String,
deviceName: String,
private val install: Boolean = false,
@ -27,13 +28,11 @@ internal class Adb(
}
internal fun deploy() {
if (install) {
TODO("support installing the apk")
device.run(Constants.COMMAND_INSTALL_APK.replacePlaceholder("\"$apk\""))
PackageManager(device).install(file)
} else {
// push patched file
device.copy(Constants.PATH_INIT_PUSH, apk)
device.copy(Constants.PATH_INIT_PUSH, file)
// create revanced path
device.run("${Constants.COMMAND_CREATE_DIR} ${Constants.PATH_REVANCED}")
@ -61,13 +60,13 @@ internal class Adb(
device.run(Constants.PATH_UMOUNT.replacePlaceholder())
// mount the apk
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() {

View File

@ -15,7 +15,7 @@ internal object Constants {
private const val NAME_MOUNT_SCRIPT = "mount_revanced_$PLACEHOLDER.sh"
// 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
internal const val PATH_REVANCED = "/data/adb/revanced/"
@ -37,9 +37,6 @@ internal object Constants {
// install umount script & set permissions
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
internal val CONTENT_UMOUNT_SCRIPT =
"""