fix(android): point foreign ANR refusals to alert, and read ANR buttons by id

Merged
KD
4h ago
+253-42

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) and alert accept (Wait).
  • alert also finds the dialog by its android:id/aerr_close and aerr_wait buttons, 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:

CallBase 24f8181c3Head 6b57b4245
press @e2 hintwait, restart, or rebootalert dismiss or alert accept
alert acceptrefusedpresses 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