From 056a7b722b1f7dbf6dd08ca841e7fbacbaf9c9b0 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Mon, 28 Dec 2020 21:17:35 -0600 Subject: [PATCH] build.sh: Replace wait by repeated checks --- android/build.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/android/build.sh b/android/build.sh index c31bd89cd..0e506ecf6 100755 --- a/android/build.sh +++ b/android/build.sh @@ -236,20 +236,22 @@ create_avd() { --device pixel_xl || fail } +wait_for_device() { + log_info "Waiting for device..." + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82' +} + run_avd() { log_info "Launching emulator" $EMULATOR @$AVDNAME & - - log_info "Waiting for device..." - $ADB wait-for-device - sleep 5 + wait_for_device } stop_avd() { log_info "Stopping emulator..." # https://stackoverflow.com/a/38652520 adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done - sleep 15 + while [[ ! -z $(pgrep emulator) ]]; do sleep 1; done } case "$1" in