fix(android): let press reach a foreign ANR dialog's own buttons
Summary
While another package's Android "isn't responding" dialog has focus, the blocking-dialog guard refuses every input, including the dialog's own Close app and Wait, so an agent cannot dismiss it. #592 recovers only app-owned ANRs.
Now one plain press or click (count 1, no double tap, hold, or jitter) passes when it aims at the dialog's android:id/aerr_close or android:id/aerr_wait in a fresh capture: a ref's node in the tree the runtime taps from, or a raw point inside either button. Focus is then confirmed again. Selectors and other inputs refuse with dispatched: no.
App-owned recovery now finds Close app by the same id, in any device language.
Before / after
System UI frozen with SIGSTOP until its ANR dialog has focus, API 36 emulator:
| Call | Base 24f8181c3 | Head 0f047ad15 |
|---|---|---|
press @e2 (Close app) | Android system dialog is blocking press | Tapped @e2, Settings gets focus |
press 540 1600 (outside) | refused | Not dispatched, hint names Close app or Wait |
Validation
Emulator run at 0f047ad15, android-helper backend 0.21.44-dev:
# agent-device 0f047ad15, e2e_api36_anr
(API 36), System UI stopped with SIGSTOP
$ adb shell dumpsys window | grep mCurrentFocus
mCurrentFocus=Window{d56e672 u0 Application Not Responding: com.android.systemui}
$ agent-device snapshot -i
@e1 [text] "System UI isn't responding"
@e2 [button] "Close app"
@e3 [button] "Wait"
$ agent-device press 540 1600
Error (COMMAND_FAILED): Android system dialog is blocking press: Application Not Responding: com.android.systemui (package com.android.systemui). Not dispatched. Next: Take a new snapshot -i, then press the ref of one of the dialog's buttons (Close app or Wait). Every other input is refused while the dialog has focus.
$ agent-device press 'id="android:id/aerr_close"'
Error (COMMAND_FAILED): Android system dialog is blocking press: Application Not Responding: com.android.systemui (package com.android.systemui). Not dispatched. Next: Take a new snapshot -i, then press the ref of one of the dialog's buttons (Close app or Wait). Every other input is refused while the dialog has focus.
$ agent-device fill 540 900 hello
Error (COMMAND_FAILED): Android system dialog is blocking fill: Application Not Responding: com.android.systemui (package com.android.systemui). Not dispatched. Next: Wait for Android to recover, close the dialog, restart the app, or reboot the emulator, then retry.
$ agent-device snapshot -i
@e1 [text] "System UI isn't responding"
@e2 [button] "Close app"
@e3 [button] "Wait"
$ agent-device press @e2
Tapped @e2 (540, 1273)
$ adb shell dumpsys window | grep mCurrentFocus
mCurrentFocus=Window{521a11c u0 com.android.settings/com.android.settings.Settings}
$ agent-device press 'label="Network & internet"'
Tapped label="Network & internet" (540, 739)
pnpm check:affected --run --head 0f047ad15, exactCommit: true:
[passed] format; exit=0
[passed] lint; exit=0
[passed] typecheck; exit=0
[passed] layering; exit=0
[passed] fallow; exit=0
[passed] build; exit=0
[passed] vitest-related; exit=0
[passed] unit; exit=0
[passed] command-docs; exit=0
[passed] docs-links; exit=0
[passed] docs-prose; exit=0
- Unit tests cover stale refs, moved buttons, focus changes, edges, hold, jitter, and selectors.
- Risk: when a swipe into frozen System UI caused the ANR, Android can reject the first tap as an inconsistent event; the press reports it may have reached the device, and a second press closes the dialog.
- Not run: Android below 7.0, whose dialogs have no
aerr_ids; the guard still refuses there.
🤖 Generated with Claude Code