fix(android): point foreign ANR refusals to alert, and read ANR buttons by id
Merged
KD
4h ago+253+253+012345678901234567890123456789-42-42-01234567890123456789
Summary
While another package's "isn't responding" dialog has focus, the guard refuses screen commands, and its hint named only wait, restart, or reboot. alert passes the guard, but nothing pointed there, and it found the dialog by English text only.
- The refusal hint names
alert dismiss(Close app) andalert accept(Wait). alertalso finds the dialog by itsandroid:id/aerr_closeandaerr_waitbuttons, mapped to dismiss and accept, in any language.- The daemon finds the dialog and Close app by the same ids; its English patterns are removed.
Before / after
System UI frozen with SIGSTOP until its ANR dialog has focus, API 36 emulator:
| Call | Base 24f8181c3 | Head 6b57b4245 |
|---|---|---|
press @e2 hint | wait, restart, or reboot | alert dismiss or alert accept |
alert accept | refused | presses Wait |
Validation
Emulator run at 6b57b4245:
# agent-device 6b57b4245, e2e_api36_anr (API 36), System UI stopped with SIGSTOP
$ adb shell dumpsys window | grep mCurrentFocus
mCurrentFocus=Window{3f1f281 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 @e2
Error (COMMAND_FAILED): Android system dialog is blocking press: Application Not Responding: com.android.systemui (package com.android.systemui). May have reached the device. Next: Run snapshot to check the screen before you retry. Run alert dismiss to close the app that is not responding, or alert accept to wait for it, then retry.
$ agent-device alert dismiss
Alert dismissed
$ adb shell dumpsys window | grep mCurrentFocus
mCurrentFocus=Window{72304c4 u0 com.android.settings/com.android.settings.Settings}
A second ANR:
$ agent-device alert get --json # data.alert
{"title": "System UI isn't responding", "buttons": ["Close app", "Wait"], "platform": "android", "source": "system-dialog", "packageName": "android"}
$ agent-device alert accept
Alert accepted
$ adb shell dumpsys window | grep mCurrentFocus
mCurrentFocus=Window{40a3a4c u0 com.android.settings/com.android.settings.Settings}
pnpm check:affected --run --head 6b57b4245, 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
- As on main, a refusal still says "May have reached the device".
- The daemon needs Wait to call a dialog an ANR: the crash dialog also has Close app.
- Not run on a device: another language (unit tests only), and Android below 7.0 (no
aerr_ids).
š¤ Generated with Claude Code