Skip to content

Commit bf478ad

Browse files
authored
adb: Pass -W (wait for app start) to am start before getting pidof (#118)
Sometimes the app hasn't started yet, and `xbuild` fails with: Error: failed to get pid: because `pidof` could not find any process with that name, and exits with a non-zero error code (and stderr is left empty). Simply passing `-W` to make `am start` block a little while longer until the app is actually running seems to resolve this issue in the common case.
1 parent f2dc194 commit bf478ad

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

xbuild/src/devices/adb.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ impl Adb {
9797
.shell(device, None)
9898
.arg("am")
9999
.arg("start")
100+
.arg("-W")
100101
.arg("-a")
101102
.arg("android.intent.action.MAIN")
102103
.arg("-n")
@@ -184,7 +185,7 @@ impl Adb {
184185
);
185186
let pid = std::str::from_utf8(&output.stdout)?.trim();
186187
// may return multiple space separated pids if the old process hasn't exited yet.
187-
if pid.is_empty() || pid.split_once(' ').is_some() {
188+
if pid.is_empty() || pid.contains(' ') {
188189
std::thread::sleep(std::time::Duration::from_millis(100));
189190
continue;
190191
}

0 commit comments

Comments
 (0)