mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-17 21:38:29 +00:00
56 lines
1.2 KiB
Bash
Executable file
56 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set +e
|
|
|
|
bootanim=""
|
|
failcounter=0
|
|
|
|
adb="${ANDROID_HOME}/platform-tools/adb"
|
|
device="emulator-5554"
|
|
mode="start"
|
|
timeout_in_sec=360
|
|
|
|
while getopts a:d:m:t flag; do
|
|
case "${flag}" in
|
|
a) adb=${OPTARG};;
|
|
d) device=${OPTARG};;
|
|
m) mode=${OPTARG};;
|
|
t) timeout_in_sec=${OPTARG};;
|
|
esac
|
|
done
|
|
|
|
case "${mode}" in
|
|
|
|
start)
|
|
until [[ "$bootanim" =~ "stopped" ]]; do
|
|
bootanim=$($adb -s $device -e shell getprop init.svc.bootanim 2>&1 &)
|
|
if [[ "$bootanim" =~ "device '$device' not found" || "$bootanim" =~ "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"
|
|
;;
|
|
|
|
stop)
|
|
while $adb devices | grep -q "$device"; do
|
|
let "failcounter += 1"
|
|
if [[ $failcounter = 1 ]]; then
|
|
echo -n "Waiting for $device to stop."; else
|
|
echo -n "."
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "$device is off"
|
|
;;
|
|
|
|
esac
|