fix: Execute ADB commands sequentially to fix mounting issues (#12)

This commit is contained in:
Riccardo Nava
2023-10-10 01:22:45 +02:00
committed by GitHub
parent d2e367e901
commit fda3eca74f
2 changed files with 6 additions and 6 deletions

View File

@@ -84,14 +84,14 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
device.push(apk.file, TMP_PATH) device.push(apk.file, TMP_PATH)
device.run("$CREATE_DIR $INSTALLATION_PATH") device.run("$CREATE_DIR $INSTALLATION_PATH").waitFor()
device.run(INSTALL_PATCHED_APK, packageName) device.run(INSTALL_PATCHED_APK, packageName).waitFor()
device.createFile(TMP_PATH, MOUNT_SCRIPT.applyReplacement(packageName)) device.createFile(TMP_PATH, MOUNT_SCRIPT.applyReplacement(packageName))
device.run(INSTALL_MOUNT, packageName) device.run(INSTALL_MOUNT, packageName).waitFor()
device.run(UMOUNT, packageName) // Sanity check. device.run(UMOUNT, packageName).waitFor() // Sanity check.
device.run(MOUNT_PATH, packageName) device.run(MOUNT_PATH, packageName).waitFor()
device.run(RESTART, packageName) device.run(RESTART, packageName)
device.run(DELETE, TMP_PATH) device.run(DELETE, TMP_PATH)

View File

@@ -21,7 +21,7 @@ internal fun JadbDevice.run(command: String, su: Boolean = true): ShellProcess {
} }
internal fun JadbDevice.hasSu() = internal fun JadbDevice.hasSu() =
this.startCommand("su -h", false).waitFor() == 0 this.startCommand("which su", false).waitFor() == 0
internal fun JadbDevice.push(file: File, targetFilePath: String) = internal fun JadbDevice.push(file: File, targetFilePath: String) =
push(file, RemoteFile(targetFilePath)) push(file, RemoteFile(targetFilePath))