linphone-android/.gitlab-ci-files/wait-for-android-emulator
2023-04-03 16:02:13 +02:00

37 lines
869 B
Bash
Executable file

#!/bin/bash
set +e
bootanim=""
failcounter=0
adb="${ANDROID_HOME}/platform-tools/adb"
device="emulator-5554"
timeout_in_sec=360
while getopts a:d:t flag; do
case "${flag}" in
a) adb=${OPTARG};;
d) device=${OPTARG};;
t) timeout_in_sec=${OPTARG};;
esac
done
until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`$adb -s $device -e shell getprop init.svc.bootanim 2>&1 &`
if [[ "$bootanim" =~ "device '$device' not found" || "$bootanim" =~ "device '$device' offline"
|| "$bootanim" =~ "running" ]]; then
let "failcounter += 1"
if [[ $failcounter = 1 ]]; then
echo -n "Waiting for $device to start"; else
echo -n "."
fi
if [[ $failcounter -gt timeout_in_sec ]]; then
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
exit 1
fi
fi
sleep 1
done
echo "$device is ready"