Created
February 10, 2015 02:09
-
-
Save DeuceTheCoder/f0715465806c7e2e754d to your computer and use it in GitHub Desktop.
Starts an existing android emulator and waits for it to be ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEVICE_WAIT_TIMEOUT='3m' | |
function start_emulator_and_unlock_screen { | |
emulator_name=$1 | |
shift | |
emulator_options=$* | |
check_emu_name $emulator_name | |
$ANDROID_HOME/tools/emulator @$emulator_name $emulator_options & | |
EMULATOR_ID=$! | |
wait_for_device | |
echo "Android emulator is started with PID $EMULATOR_ID" | |
#uncomment if device has a lockscreen enabled | |
#$ANDROID_HOME/platform-tools/adb shell input keyevent 82 | |
} | |
#TODO: use android list avd to check that the name is an existing AVD | |
function check_emu_name { | |
if [ -z "$1" ] | |
then | |
echo "The first parameter must be the name of an existing AVD" | |
exit | |
fi | |
} | |
function wait_for_device { | |
echo 'Waiting for Android device to be started/connected' | |
timeout $DEVICE_WAIT_TIMEOUT $ANDROID_HOME/platform-tools/adb wait-for-device | |
} | |
start_emulator_and_unlock_screen $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment