fix(android): honor boot --timeout as the emulator boot deadline

Merged
TH
2mo ago
+135-26

Summary

boot --timeout <ms> now bounds Android emulator boot, matching the iOS Simulator behavior from #3008. Expiry fails with COMMAND_FAILED, details.reason: boot_timeout, and a retry hint. The emulator keeps booting.

Follow-up to #3008 (#3004).

Design: the deadline stays one platform-neutral input, EnsureReadyInput.deadlineAtMs. Android's emulator-appearance wait and sys.boot_completed wait both read it; the default 120s applies when it is absent. prepareApplicationOpen now forwards the startup deadline. The iOS-only wording in the contract, help, and docs is now neutral. BOOT_TIMEOUT_REASON moved to contracts and is shared by Apple and Android. HarmonyOS, Vega, and Linux have no boot wait, so they need no deadline. Rejected: a new deadline wrapper or per-platform field (passing the existing value is enough).

#3055 touches adb failure/provider scope only. It shares no file with this PR, and a device-offline retry runs inside a single adb call, so this deadline still bounds the outer poll loops.

10 files changed.

Validation

  • SHA a0975dbfa7; pnpm format and pnpm check:affected --run pass (533 files, 3976 tests).
  • Live, cold-booted Pixel_9_Pro_XL_API_37 (port 5584, -no-window -no-snapshot-load):
    • boot --platform android --device Pixel_9_Pro_XL_API_37 --timeout 2000 --json failed in 3.7s: COMMAND_FAILED 'Android emulator did not appear in time', reason: boot_timeout.
    • With --timeout 240000 it succeeded in 42.5s (booted: true, id: emulator-5584).
    • The emulator was killed afterwards.
  • Unresolved risk: the sys.boot_completed timeout was covered by unit tests only, not live. Deadline checks run between polls, so one adb call can overrun by up to about 1s. classifyBootFailure still does not map these messages to ANDROID_BOOT_TIMEOUT; that gap predates this PR.