File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,10 +26,20 @@ until [[ "$bootanim" =~ "stopped" ]]; do
2626done
2727echo " ($checkcounter ) Done"
2828
29+ # The bootanim service can stop before the system is fully booted; wait for it so the
30+ # settings below actually stick.
31+ until [[ " $( adb -e shell getprop sys.boot_completed 2>&1 | tr -d ' [:space:]' ) " == " 1" ]]; do
32+ sleep 2
33+ done
34+
2935# Keep the screen awake and unlocked for the whole run. On a headless emulator the
3036# screen can sleep or keep the keyguard up, which leaves the app window without focus
3137# and makes Espresso fail with RootViewWithoutFocusException.
38+ # stayon only prevents future sleep, so we also wake the screen and drop the keyguard.
39+ adb -e shell settings put system screen_off_timeout 2147483647
3240adb -e shell svc power stayon true
41+ adb -e shell input keyevent 224 # KEYCODE_WAKEUP: turn a sleeping screen back on
42+ adb -e shell locksettings set-disabled true
3343adb -e shell wm dismiss-keyguard
3444adb -e shell input keyevent 82
3545
You can’t perform that action at this time.
0 commit comments