1515
1616# If there is an emulator already started, just use that one
1717
18- echo " run: started=$( adb get-state 1 || true ) "
19- started=$( adb get-state 1 || true )
20- if [[ ${ started} == " device" ] ]; then
21- exit 0
18+ echo " run: started=$( adb get-state 1) "
19+ started=$( adb get-state 1)
20+ if [ " $ started" = " device" ]; then
21+ exit 0
2222fi
2323
2424# Set PATH variable so we can find sdkmanager and avdmanager
2525echo " Setting Path (emulator before tools hack)"
26- export ANDROID_SDK=" ${ HOME} /Library/Android/sdk"
27- export PATH=" ${ ANDROID_SDK} /emulator:${ ANDROID_SDK} /tools/:${ ANDROID_HOME} /tools/bin:${ PATH} "
26+ export ANDROID_SDK=$ HOME /Library/Android/sdk
27+ export PATH=$ ANDROID_SDK /emulator:$ANDROID_SDK /tools/:$ANDROID_HOME /tools/bin:$PATH
2828# echo "run: sdkmanager tools"
2929# sdkmanager tools
3030# echo "run: kill-server"
@@ -37,34 +37,34 @@ export PATH="${ANDROID_SDK}/emulator:${ANDROID_SDK}/tools/:${ANDROID_HOME}/tools
3737# echo "run: adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done &"
3838# adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done &
3939echo " starting emulator"
40- echo ' run: echo yes | sdkmanager --install "system-images;android-28;default;x86" '
40+ echo " run: echo yes | sdkmanager --install \ " system-images;android-28;default;x86\" "
4141echo yes | sdkmanager --install " system-images;android-29;default;x86"
4242
4343# create new Emulator
44- echo ' run: echo no | avdmanager create avd --force -n test -k "system-images;android-29;default;x86" -c 10M'
44+ echo " run: echo no | avdmanager create avd --force -n test -k \ " system-images;android-29;default;x86\ " -c 10M"
4545echo no | avdmanager create avd --force -n test -k " system-images;android-29;default;x86" -c 10M
4646
4747# sanity check, make sure new Emulator was created
4848echo " run: emulator -list-avds"
4949emulator -list-avds
5050
5151# start Emulator (not sure if we actually have to run this as sudo or not
52- echo " run: sudo -E sudo -u ${ USER} -E bash -c \" ./emulator -avd test -verbose -no-snapshot -no-window -camera-back none -camera-front none -selinux permissive -qemu -m 2048 &\" "
53- sudo -E sudo -u " ${ USER} " -E bash -c " ${ANDROID_HOME} /emulator/emulator -avd test -verbose -no-snapshot -no-window -camera-back none -camera-front none -selinux permissive -qemu -m 2048 &"
52+ echo " run: sudo -E sudo -u $USER -E bash -c \" ./emulator -avd test -verbose -no-snapshot -no-window -camera-back none -camera-front none -selinux permissive -qemu -m 2048 &\" "
53+ sudo -E sudo -u " $USER " -E bash -c " ${ANDROID_HOME} /emulator/emulator -avd test -verbose -no-snapshot -no-window -camera-back none -camera-front none -selinux permissive -qemu -m 2048 &"
5454
5555echo " run: adb shell input keyevent 82 &"
5656adb shell input keyevent 82 &
5757
5858# block until emulator is ready to run tests
5959echo " Waiting for Emulator to start"
60- until [[ ${ bootanim} =~ " stopped" ]]; do
61- echo " run: adb reconnect offline"
62- adb reconnect offline
63- adb devices
64- bootanim=" $( adb -e shell getprop init.svc.bootanim 2>&1 ) "
65- echo " Waiting for emulator, status is: ${ bootanim} "
66- sleep 1
67- echo
60+ until [[ " $ bootanim" =~ " stopped" ]]; do
61+ echo " run: adb reconnect offline"
62+ adb reconnect offline
63+ adb devices
64+ bootanim=` adb -e shell getprop init.svc.bootanim 2>&1 & `
65+ echo " Waiting for emulator, status is: $bootanim "
66+ sleep 1
67+ echo
6868done
6969
7070echo " Emulator has started - dismissing keyboard and sleeping for 1 second."
0 commit comments