Skip to content

Commit b01b75f

Browse files
committed
Keep the launcher's not-responding dialog off the emulator and out of the tests' way
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent 51035be commit b01b75f

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎android-shell/app/src/androidTest/java/ai/openbot/shell/test/ShellTestBase.kt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,20 @@ abstract class ShellTestBase {
6464
fun baseSetUp() {
6565
device.wakeUp()
6666
shell("input keyevent KEYCODE_MENU")
67+
dismissSystemDialogs()
6768
note("variant: $variant ($pkg)")
6869
}
6970

71+
/** "<app> isn't responding" (a slow emulator's launcher): Wait. Never over our own app. */
72+
fun dismissSystemDialogs() {
73+
repeat(3) {
74+
val anr = device.findObject(By.textContains("isn't responding")) ?: device.findObject(By.textContains("isn\u2019t responding")) ?: return
75+
note("system dialog: ${anr.text}; tapping Wait")
76+
(device.findObject(By.text("Wait")) ?: device.findObject(By.text("Close app")))?.click()
77+
sleep(1_000)
78+
}
79+
}
80+
7081
@After
7182
fun baseTearDown() {
7283
if (softFailures.isNotEmpty()) {
@@ -124,6 +135,7 @@ abstract class ShellTestBase {
124135
instrumentation.targetContext.startActivity(intent)
125136
device.wait(Until.hasObject(By.pkg(pkg).depth(0)), 15_000)
126137
sleep(800)
138+
dismissSystemDialogs()
127139
}
128140

129141
/** Back from the background: the launcher's intent, no extras, the existing task. */

‎android-shell/ci/emulator.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ boot() {
5050
}
5151

5252
prepare() {
53+
# A freshly booted emulator's launcher often answers slowly: no "isn't responding" dialogs over the
54+
# tests (Settings.Global.HIDE_ERROR_DIALOGS), and a moment for the system to settle.
55+
adb shell settings put global hide_error_dialogs 1
56+
adb shell settings put global anr_show_background 0
57+
sleep 20
58+
adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS > /dev/null 2>&1 || true
5359
adb shell settings put global window_animation_scale 0
5460
adb shell settings put global transition_animation_scale 0
5561
adb shell settings put global animator_duration_scale "${ANIMATOR_SCALE:-0}"

0 commit comments

Comments
 (0)