feat(lock-screen): lock and unlock the screen on Android and iOS simulators

Merged
IM
4d ago
+2092-97

Summary

Closes #4798. The iOS side follows the reviewed design of #3001.

agent-device lock-screen <lock|unlock> and client.command.lockScreen({ action }) return { action: 'lock-screen', state: 'locked' | 'unlocked', message } once the device reports that state. No app is activated and there is no --settle.

  • Android: KEYCODE_SLEEP, or KEYCODE_WAKEUP then wm dismiss-keyguard, verified by isKeyguardShowing. A screen lock set to None refuses lock with lock-screen-disabled; a PIN, pattern, or password refuses unlock with lock-screen-secure. Both send nothing. A deferred keyguard ("Power button instantly locks" off) is awaited for lock_screen_lock_after_timeout, 5–60 s.
  • iOS simulator: pressLockButton after responds(to:); unlock swipes up from the bottom edge, back to the app in front. A dark screen is woken first. Success needs com.apple.springboard.lockstate, a lock surface for lock, and a lit screen for unlock. A passcode prompt gives lock-screen-secure.
  • Other targets, including physical iPhones and Android TV: UNSUPPORTED_OPERATION.

lock-screen names the surface it shows, like app-switcher. Two system-button cells are picked by the positional, as in hardware-button.

Before / after

Base has no lock-screen. Head, Settings in front:

Pixel 9 AVD, Android 16:
lock (None)       -> lock-screen-disabled, dispatched no; no sleep in logcat
lock (swipe)      -> locked (0.81 s); repeat sends nothing (0.19 s)
unlock            -> unlocked (0.90 s), Settings in front
unlock (PIN)      -> lock-screen-secure, dispatched no; keyguard stays up
lock (PIN, instant lock off, lock after 15 s) -> locked (15.7 s)
iPhone 17 Pro simulator, iOS 27.2:
lock -> locked; repeat presses nothing (0.22 s)
unlock on a dark lock screen -> unlocked (2.61 s), screen on, Settings in front

Validation

  • Head e55a5d4d7: check:affected --run --head passed format, lint, typecheck, layering, Fallow, build, package, integration-node, and vitest-related; pnpm gate passed provider-integration, command-docs, capabilities-matrix, xctest-selection, runner-error-codes, and daemon-wire-compat.
  • Runner lock-screen tests: 18/18 on the simulator. Each Swift and TypeScript mutant fails a test.
  • The chore(gates) commit adds system/lock-screen.ts to APPROVED_CLOSURE_ADDITIONS, because the system family keeps one module per command. Please approve or reject that row; its owner is a placeholder.