diff options
Diffstat (limited to 'tools/android-wait-for-emulator.sh')
-rwxr-xr-x | tools/android-wait-for-emulator.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/android-wait-for-emulator.sh b/tools/android-wait-for-emulator.sh new file mode 100755 index 0000000..0219687 --- /dev/null +++ b/tools/android-wait-for-emulator.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set +e + +bootcomplete="" +failcounter=0 +timeout=600 +sleeptime=10 +maxfail=$((timeout / sleeptime)) + +until [[ "${bootcomplete}" =~ "1" ]]; do + bootcomplete=`adb -e shell getprop dev.bootcomplete 2>&1 &` + if [[ "${bootcomplete}" =~ "" ]]; then + ((failcounter += 1)) + echo "Waiting for emulator to start" + if [[ ${failcounter} -gt ${maxfail} ]]; then + echo "Timeout ($timeout seconds) reached; failed to start emulator" + while pkill -9 "emulator" >/dev/null 2>&1; do + echo "Killing emulator proces...." + pgrep "emulator" + done + echo "Process terminated" + pgrep "emulator" + exit 1 + fi + fi + sleep ${sleeptime} +done + +echo "Emulator is ready" |