sdmaid-se/app-e2e
darken a064dcc1d8 General: Close launcher and System UI ANR dialogs in emulator tests
Run 39167104593 failed two API 36 tests behind a "Quickstep isn't
responding" dialog although the job sets hide_error_dialogs=1. The
dialog held focus until the job ended, after the launcher had already
recovered: back presses went to the dialog, and UI Automator never saw
the Settings switch. Why the setting didn't suppress it is unknown. On a
local API 36 emulator the setting does suppress a fresh ANR (the
launcher is killed and restarted), but a dialog that is already showing
survives the setting being turned on.

BaseAppFlowTest and app-e2e's SdmApp now register a UI Automator watcher
that taps "Close app" when exactly one ANR dialog is up and the focused
window is the dialog of com.android.launcher3,
com.google.android.apps.nexuslauncher (HOME on the API 28 google_apis
image) or com.android.systemui. Closing kills and restarts that process,
which is what hide_error_dialogs would have done. An ANR in any other
process, SD Maid included, stays on screen and fails the test. This
replaces SdmApp's fallback that tapped "Wait" on any ANR dialog.

The victim comes from the last "mCurrentFocus=" line of `dumpsys window`:
on API 36 that line is in the displays section and `dumpsys window
windows` has none; the dump opens with the state saved at the last ANR.

UiAutomator 2.4.0 runs watchers only from a BySelector lookup that finds
nothing, so pressBackUntilResumed, which only checks lifecycle state,
calls runWatchers() itself. Recoveries log the victim, both dialog
settings and the recent am_anr events, and failures carry the same, so
the next occurrence shows whether the setting was in effect.

The upgrade-test job now sets hide_error_dialogs too; it was the one
emulator job without it.

Verified on local emulators with a process SIGSTOPped behind its live
ANR dialog: API 36 launcher (StorageCleanupFlowTest, the SetupDetectionTest
accessibility test and app-e2e DashboardCleanupTest pass), API 36 Clock
app (left alone, StorageCleanupFlowTest fails as intended), API 28
google_apis NexusLauncher (StorageCleanupFlowTest passes).
2026-10-19 17:10:54 +02:00
..
src/main General: Close launcher and System UI ANR dialogs in emulator tests 2026-10-19 17:10:54 +02:00
build.gradle.kts General: Test in-place updates from the latest release on emulators 2026-09-29 16:30:46 +02:00