fix(ci): verify Android emulator readiness before mobile suites

Merged
TH
1d ago
+168-9

What

Prepare and verify the Android CI emulator before starting either mobile benchmark suite. Keep Swipe enabled for the deterministic lock test.

Why

The Android job in #2319 reaches its first fixture behind SystemUI keyguard. Enabling Swipe happens after emulator-runner's boot preparation, but the workflow never dismisses or verifies keyguard afterwards. This fixes that preparation gap without changing agent-device or test assertions. The captured failure does not establish which SDK or emulator change first exposed it.

How it works

  1. mobile.yml pins emulator port 5554 and calls .github/scripts/prepare-android-emulator.mjs before the suite. The helper targets only an explicit emulator-<port> serial, keeps the display awake, enables Swipe only for the deterministic suite, and sends one wake and dismiss request.
  2. The helper observes the API 36 KeyguardServiceDelegate dump with one five-second readiness budget. It waits for known non-secure state before dismissal, then starts the suite only after showing=false and screenState=SCREEN_STATE_ON. Unknown state fails immediately, persistent secure state fails without dismissal, and dismissal is never retried. It never enters credentials.
  3. Stateful ADB tests execute the workflow's preparation command and a suite-start sentinel. They cover initial dismissal, settling and persistent secure state, still-locked, missing and ambiguous state, ADB failure, agentic settings, and physical-device refusal. The path filter and Fallow entry register the new workflow script; adb is supplied by the Android runner.

Issue

Fixes #2392.

Verified

Ran it locally: yes, the real preparation script and workflow command against a stateful mocked ADB boundary.

mainthis PR
Preparation enables Swipe, leaves keyguard showing, and starts the suitePreparation dismisses and verifies keyguard before the suite starts
Still-locked or unreadable state reaches the suiteReadiness fails before the suite sentinel
node --test scripts/android-emulator-readiness.test.ts: 10 passed
pnpm test:scripts: 279 passed
pnpm build: passed
pnpm check: passed

Fresh-context review found no remaining code issues. No local emulator, video, or benchmark run was performed because device ownership was not provisioned. This is CI-only, with no published-package or performance change.

Hosted verification at 71c23839e: Android API 36 deterministic passed on its first suite invocation, with 68 tests passed and one existing skip. The helper logged Android emulator emulator-5554: awake, non-secure keyguard dismissed before the suite. iOS deterministic and the mobile gate passed too. The fork's read-only token could not post the benchmark reporter comment; this did not fail the suite or job.

The PR is not merge-ready. The unrelated Node 22 packages job fails packages/web/tests/unit/host-libraries.test.ts:110: its timeout probe still considers the ldd loader child alive. The spec gate propagates that failure. That source/test is unchanged here, and refreshed upstream has no relevant fix to inherit. No assertion, retry, or timeout was changed, and /ready was not requested. All other hosted checks finished green or skipped; no review threads remain unresolved.