Skip to content

Commit 7f2e184

Browse files
committed
Handle emulator bootcomplete fallbacks
1 parent 68a8c9a commit 7f2e184

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

scripts/build-android-app.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ wait_for_emulator() {
387387
local boot_completed="0"
388388
local dev_boot_completed="0"
389389
local bootanim=""
390+
local bootanim_exit=""
390391
local device_state=""
392+
local boot_ready=0
391393

392394
while [ $SECONDS -lt $deadline ]; do
393395
device_state="$($ADB_BIN -s "$serial" get-state 2>/dev/null | tr -d '\r')"
@@ -403,21 +405,31 @@ wait_for_emulator() {
403405
boot_completed="$($ADB_BIN -s "$serial" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')"
404406
dev_boot_completed="$($ADB_BIN -s "$serial" shell getprop dev.bootcomplete 2>/dev/null | tr -d '\r')"
405407
bootanim="$($ADB_BIN -s "$serial" shell getprop init.svc.bootanim 2>/dev/null | tr -d '\r')"
408+
bootanim_exit="$($ADB_BIN -s "$serial" shell getprop service.bootanim.exit 2>/dev/null | tr -d '\r')"
406409

407-
if [ "$boot_completed" = "1" ] && [ "$dev_boot_completed" = "1" ]; then
410+
if { [ "$boot_completed" = "1" ] || [ "$boot_completed" = "true" ]; } \
411+
&& { [ -z "$dev_boot_completed" ] || [ "$dev_boot_completed" = "1" ] || [ "$dev_boot_completed" = "true" ]; }; then
412+
boot_ready=1
413+
break
414+
fi
415+
416+
if [ "$bootanim" = "stopped" ] || [ "$bootanim_exit" = "1" ]; then
417+
boot_ready=2
408418
break
409419
fi
410420

411421
if [ $((SECONDS - last_log)) -ge $status_log_interval ]; then
412-
ba_log "Waiting for emulator $serial to boot (sys.boot_completed=${boot_completed:-<unset>} dev.bootcomplete=${dev_boot_completed:-<unset>} bootanim=${bootanim:-<unset>})"
422+
ba_log "Waiting for emulator $serial to boot (sys.boot_completed=${boot_completed:-<unset>} dev.bootcomplete=${dev_boot_completed:-<unset>} bootanim=${bootanim:-<unset>} bootanim_exit=${bootanim_exit:-<unset>})"
413423
last_log=$SECONDS
414424
fi
415425
sleep "$poll_interval"
416426
done
417427

418-
if [ "$boot_completed" != "1" ] || [ "$dev_boot_completed" != "1" ]; then
419-
ba_log "Emulator $serial failed to boot within ${boot_timeout}s (sys.boot_completed=${boot_completed:-<unset>} dev.bootcomplete=${dev_boot_completed:-<unset>} bootanim=${bootanim:-<unset>} state=${device_state:-<unset>})" >&2
428+
if [ $boot_ready -eq 0 ]; then
429+
ba_log "Emulator $serial failed to boot within ${boot_timeout}s (sys.boot_completed=${boot_completed:-<unset>} dev.bootcomplete=${dev_boot_completed:-<unset>} bootanim=${bootanim:-<unset>} bootanim_exit=${bootanim_exit:-<unset>} state=${device_state:-<unset>})" >&2
420430
return 1
431+
elif [ $boot_ready -eq 2 ]; then
432+
ba_log "Emulator $serial reported boot animation stopped; proceeding without bootcomplete properties"
421433
fi
422434

423435
"$ADB_BIN" -s "$serial" shell settings put global window_animation_scale 0 >/dev/null 2>&1 || true

0 commit comments

Comments
 (0)