mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-04 17:32:53 +01:00
fix: Check, if mounting is possible
This commit is contained in:
parent
db50cee12c
commit
3e13fb5d56
@ -47,6 +47,12 @@ public final class app/revanced/lib/adb/AdbManager$Companion {
|
|||||||
public final class app/revanced/lib/adb/AdbManager$DeviceNotFoundException : java/lang/Exception {
|
public final class app/revanced/lib/adb/AdbManager$DeviceNotFoundException : java/lang/Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/lib/adb/AdbManager$FailedToFindInstalledPackageException : java/lang/Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/lib/adb/AdbManager$PackageNameRequiredException : java/lang/Exception {
|
||||||
|
}
|
||||||
|
|
||||||
public final class app/revanced/lib/adb/AdbManager$RootAdbManager : app/revanced/lib/adb/AdbManager {
|
public final class app/revanced/lib/adb/AdbManager$RootAdbManager : app/revanced/lib/adb/AdbManager {
|
||||||
public static final field Utils Lapp/revanced/lib/adb/AdbManager$RootAdbManager$Utils;
|
public static final field Utils Lapp/revanced/lib/adb/AdbManager$RootAdbManager$Utils;
|
||||||
public fun install (Lapp/revanced/lib/adb/AdbManager$Apk;)V
|
public fun install (Lapp/revanced/lib/adb/AdbManager$Apk;)V
|
||||||
|
@ -10,6 +10,7 @@ import app.revanced.lib.adb.Constants.MOUNT_PATH
|
|||||||
import app.revanced.lib.adb.Constants.MOUNT_SCRIPT
|
import app.revanced.lib.adb.Constants.MOUNT_SCRIPT
|
||||||
import app.revanced.lib.adb.Constants.PATCHED_APK_PATH
|
import app.revanced.lib.adb.Constants.PATCHED_APK_PATH
|
||||||
import app.revanced.lib.adb.Constants.PLACEHOLDER
|
import app.revanced.lib.adb.Constants.PLACEHOLDER
|
||||||
|
import app.revanced.lib.adb.Constants.RESOLVE_ACTIVITY
|
||||||
import app.revanced.lib.adb.Constants.RESTART
|
import app.revanced.lib.adb.Constants.RESTART
|
||||||
import app.revanced.lib.adb.Constants.TMP_PATH
|
import app.revanced.lib.adb.Constants.TMP_PATH
|
||||||
import app.revanced.lib.adb.Constants.UMOUNT
|
import app.revanced.lib.adb.Constants.UMOUNT
|
||||||
@ -74,9 +75,14 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
|
|||||||
logger.info("Installing by mounting")
|
logger.info("Installing by mounting")
|
||||||
|
|
||||||
val applyReplacement = getPlaceholderReplacement(
|
val applyReplacement = getPlaceholderReplacement(
|
||||||
apk.packageName ?: throw IllegalArgumentException("Package name is required")
|
apk.packageName ?: throw PackageNameRequiredException()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
device.run(RESOLVE_ACTIVITY.applyReplacement()).inputStream.bufferedReader().readLine().let { line ->
|
||||||
|
if (line != "No activity found") return@let
|
||||||
|
throw throw FailedToFindInstalledPackageException(apk.packageName)
|
||||||
|
}
|
||||||
|
|
||||||
device.push(apk.file, TMP_PATH)
|
device.push(apk.file, TMP_PATH)
|
||||||
|
|
||||||
device.run("$CREATE_DIR $INSTALLATION_PATH")
|
device.run("$CREATE_DIR $INSTALLATION_PATH")
|
||||||
@ -142,4 +148,10 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
|
|||||||
Exception(deviceSerial?.let {
|
Exception(deviceSerial?.let {
|
||||||
"The device with the ADB device serial \"$deviceSerial\" can not be found"
|
"The device with the ADB device serial \"$deviceSerial\" can not be found"
|
||||||
} ?: "No ADB device found")
|
} ?: "No ADB device found")
|
||||||
|
|
||||||
|
class FailedToFindInstalledPackageException internal constructor(packageName: String) :
|
||||||
|
Exception("Failed to find installed package \"$packageName\" because no activity was found")
|
||||||
|
|
||||||
|
class PackageNameRequiredException internal constructor() :
|
||||||
|
Exception("Package name is required")
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package app.revanced.lib.adb
|
|||||||
|
|
||||||
import se.vidstige.jadb.JadbDevice
|
import se.vidstige.jadb.JadbDevice
|
||||||
import se.vidstige.jadb.RemoteFile
|
import se.vidstige.jadb.RemoteFile
|
||||||
|
import se.vidstige.jadb.ShellProcess
|
||||||
import se.vidstige.jadb.ShellProcessBuilder
|
import se.vidstige.jadb.ShellProcessBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -15,8 +16,8 @@ internal fun JadbDevice.buildCommand(command: String, su: Boolean = true): Shell
|
|||||||
return shellProcessBuilder(cmd, *args.toTypedArray())
|
return shellProcessBuilder(cmd, *args.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun JadbDevice.run(command: String, su: Boolean = true): Int {
|
internal fun JadbDevice.run(command: String, su: Boolean = true): ShellProcess {
|
||||||
return this.buildCommand(command, su).start().waitFor()
|
return this.buildCommand(command, su).start()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun JadbDevice.hasSu() =
|
internal fun JadbDevice.hasSu() =
|
||||||
|
@ -10,7 +10,8 @@ internal object Constants {
|
|||||||
|
|
||||||
internal const val DELETE = "rm -rf $PLACEHOLDER"
|
internal const val DELETE = "rm -rf $PLACEHOLDER"
|
||||||
internal const val CREATE_DIR = "mkdir -p"
|
internal const val CREATE_DIR = "mkdir -p"
|
||||||
internal const val RESTART = "pm resolve-activity --brief $PLACEHOLDER | tail -n 1 | " +
|
internal const val RESOLVE_ACTIVITY = "pm resolve-activity --brief $PLACEHOLDER"
|
||||||
|
internal const val RESTART = "$RESOLVE_ACTIVITY | tail -n 1 | " +
|
||||||
"xargs am start -n && kill ${'$'}(pidof -s $PLACEHOLDER)"
|
"xargs am start -n && kill ${'$'}(pidof -s $PLACEHOLDER)"
|
||||||
|
|
||||||
internal const val INSTALL_PATCHED_APK = "base_path=\"$PATCHED_APK_PATH\" && " +
|
internal const val INSTALL_PATCHED_APK = "base_path=\"$PATCHED_APK_PATH\" && " +
|
||||||
|
Loading…
Reference in New Issue
Block a user