Skip to content

Commit

Permalink
feat: support for --install
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 11, 2022
1 parent cf1d512 commit d1ceab4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
19 changes: 9 additions & 10 deletions src/main/kotlin/app/revanced/utils/adb/Adb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}")
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/kotlin/app/revanced/utils/adb/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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 =
"""
Expand Down

0 comments on commit d1ceab4

Please sign in to comment.