From d1ceab45c89901f79d46c62f03186502021afb26 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 11 Jun 2022 20:02:37 +0200 Subject: [PATCH] feat: support for `--install` --- src/main/kotlin/app/revanced/utils/adb/Adb.kt | 19 +++++++++---------- .../app/revanced/utils/adb/Constants.kt | 5 +---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/app/revanced/utils/adb/Adb.kt b/src/main/kotlin/app/revanced/utils/adb/Adb.kt index a59d699c..5097956d 100644 --- a/src/main/kotlin/app/revanced/utils/adb/Adb.kt +++ b/src/main/kotlin/app/revanced/utils/adb/Adb.kt @@ -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()) + // relaunch app + device.run(Constants.COMMAND_RESTART.replacePlaceholder()) - // log the app - log() + // log the app + log() + } } private fun log() { diff --git a/src/main/kotlin/app/revanced/utils/adb/Constants.kt b/src/main/kotlin/app/revanced/utils/adb/Constants.kt index 0fc437bb..9554c86a 100644 --- a/src/main/kotlin/app/revanced/utils/adb/Constants.kt +++ b/src/main/kotlin/app/revanced/utils/adb/Constants.kt @@ -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 = """