fix(android): let open --relaunch accept a package Android restarts at once
Summary
open --relaunch com.android.settings failed with android-app-close-timeout (phase process) on Android 17. A system client of the Settings slice provider restarts Settings right after am force-stop, so the close fence saw a new pid. A relaunch needs only the foreground and exit fences: the process fence runs after them, so once they pass, every process that ran before the stop is gone, and the launch reuses the new one. Both relaunch routes — the session-owner close and the in-open stop — accept a refusal from the process fence alone, through one predicate (passedAndroidRelaunchStopFences). Plain close still refuses a restarted process. help close and commands.md say so.
6 files touched. Fixes #4482.
Validation
- Tested SHA
753e5a2bd7, base9676eedac5.- Round 1: no CLI syntax in the
closedescription, which MCP shares. - Round 2: one shared catch replaces the
purposeparameter.
- Round 1: no CLI syntax in the
- New tests fail on base with
process remained running after closeand pass at head:lifecycle.test.ts(owner-close relaunch) andapp-lifecycle-close.test.ts(in-open relaunch). The existingexit/foregroundrefusals still pass. pnpm exec vitest run --project unit-core packages/platform-android/src packages/command-surface/src/__tests__/command-surface-metadata.test.ts: 137 files, 1413 tests passed.pnpm check:quick: pass.- Live: Pixel 9a API 37 emulator (Android 17, Google APIs arm64), T3 device command against a source daemon. Six looping shell clients call
content://android.settings.slices, standing in for the system client. Each run reads the Settingsam_kill/am_proc_startevents from logcat.
| Build | open com.android.settings --relaunch --foreground (session-owner close) |
|---|---|
base 9676eedac5 | 2/4 failed, android-app-close-timeout, phase process |
| head | 10/10 succeeded. In 8 runs Settings restarted for its content provider 83–233 ms after am_kill; those took 3.1–3.4 s (the 2 s process fence expired and its refusal was accepted). The other 2 had no restart and took 1.7–1.9 s. |
Without the stand-in clients, base succeeds on this emulator: the restart depends on timing. open settings --relaunch resolves to an intent and relaunches through am start, so it never reaches the in-open stop. For package targets, open resolution supplies an app id, so relaunches take the owner route. The in-open stop has only its unit test.
🤖 Generated with Claude Code