fix(android): refuse close when stop fences expire

Merged
TH
2mo ago
+435-160

Summary

ADB close could report success after either 2s foreground/process fence expired. Both now throw typed COMMAND_FAILED / android-app-close-timeout with phase, packageName and timeoutMs. Relaunch stops before open or observation, both when closing a recorded owner and, since #3600, when force-stopping a package before launch. A probe that completes after the deadline counts as expired, including the 150ms stability recheck. Fences use Deadline; budgets unchanged (2s per phase, 50ms polling, 150ms stable absence).

The shared stop wait reports which fence expired; close and relaunch turn that into the refusal, while killApp (#2749) runs both waits as on main and keeps its own android-kill-process-survived classification. Apps Android restarts at once, such as the launcher, now fail close. help close and commands.md state this. Close tests moved to app-lifecycle-close.test.ts. Related to #3077.

Validation

Head bedf0a066, rebased on main fc224bc1e. pnpm check:affected --base origin/main --run: pass (2,803 tests).

main source, new testsHead
10 failed / 35 passedall pass

Live, API 35 emulator, built CLI through the daemon at 61091d578:

CommandResult
close com.android.settingssuccess, 2.6s
open com.android.settings --relaunchsuccess, PID 3845 → 4159
close com.google.android.apps.nexuslauncher (from mCurrentFocus)android-app-close-timeout, phase foreground, timeoutMs 2000, 3.1s; launcher restarted

šŸ¤– Generated with Claude Code