diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt index c5ea82bde..7393304c7 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt @@ -143,7 +143,7 @@ object AgentHost { val shell = listOf( "/bin/sh", "-c", // proot ends the adb server with the command, so each command that needs adb connects it. - (if (connectAdb) "adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " else "") + + (if (connectAdb) "adb start-server >/dev/null 2>&1; adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " else "") + "cd \"$1\" 2>/dev/null; shift; exec \"$@\"", "sh", workdir, ) val proot = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), env + shell + command) diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt index f16a984de..03bd53f0f 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt @@ -50,7 +50,9 @@ object AgentSetup { Step.INSTALL -> set(step, if (AgentHost.guestFileExists(app, harness.binary)) Status.DONE else Status.TODO) Step.BUILD_TOOLS -> set(step, if (AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git")) Status.DONE else Status.TODO) - Step.CONNECTION -> probes += step to listOf("sh", "-c", "adb -s \"\$ADB_SERIAL\" get-state 2>&1 | tee /dev/stderr | grep -q device") + Step.CONNECTION -> probes += step to listOf("sh", "-c", + "for i in 1 2 3; do adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " + + "adb -s \"\$ADB_SERIAL\" get-state 2>&1 | tee /dev/stderr | grep -q device && exit 0; sleep 1; done; exit 1") Step.SIGN_IN -> if (AgentHost.guestFileExists(app, harness.binary)) probes += step to harness.signedIn else set(step, Status.TODO) Step.GITHUB -> probes += step to listOf("gh", "auth", "status") }