Skip to content

Commit 98417da

Browse files
committed
chore: ci android x86 and more reliable emulator boot
1 parent c4cf16d commit 98417da

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

.github/workflows/android.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424

2525
- name: Setup Android emulator
2626
run: |
27-
echo y | sudo $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-28;google_apis;x86_64" > /dev/null
28-
$ANDROID_HOME/tools/bin/avdmanager -s create avd -n emu -k "system-images;android-28;google_apis;x86_64" -b "x86_64" -c 1G -d 7 -f
27+
echo y | sudo $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-27;google_apis;x86" > /dev/null
28+
$ANDROID_HOME/tools/bin/avdmanager -s create avd -n emu -k "system-images;android-27;google_apis;x86" -b "x86" -c 1G -d 7 -f
2929
3030
- name: Install node_modules
3131
working-directory: example/RNBackgroundExample/
@@ -43,7 +43,12 @@ jobs:
4343
run: |
4444
export PATH=$PATH:$ANDROID_HOME/platform-tools
4545
$ANDROID_HOME/emulator/emulator @emu -noaudio -no-boot-anim -netdelay none -accel on -no-snapshot &
46-
adb wait-for-device; adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; adb shell wm dismiss-keyguard
46+
47+
- name: Wait for emulator to be ready
48+
working-directory: example/RNBackgroundExample/
49+
timeout-minutes: 15
50+
run: |
51+
sh ./wait-for-emulator.sh
4752
4853
- name: Android test
4954
working-directory: example/RNBackgroundExample/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# wait for emulator to be ready
3+
# thanks to https://gist.github.com/d4vidi/7862d60375b38f8970f824c4ce0ad2a9
4+
5+
echo ""
6+
echo "[Waiting for launcher to start]"
7+
LAUNCHER_READY=
8+
while [[ -z ${LAUNCHER_READY} ]]; do
9+
UI_FOCUS=`adb shell dumpsys window windows 2>/dev/null | grep -i mCurrentFocus`
10+
echo "(DEBUG) Current focus: ${UI_FOCUS}"
11+
12+
case $UI_FOCUS in
13+
*"Launcher"*)
14+
LAUNCHER_READY=true
15+
;;
16+
"")
17+
echo "Waiting for window service..."
18+
sleep 3
19+
;;
20+
*"Not Responding"*)
21+
echo "Detected an ANR! Dismissing..."
22+
adb shell input keyevent KEYCODE_DPAD_DOWN
23+
adb shell input keyevent KEYCODE_DPAD_DOWN
24+
adb shell input keyevent KEYCODE_ENTER
25+
;;
26+
*"Isn't responding"*)
27+
echo "Detected an ANR! Dismissing..."
28+
adb shell input keyevent KEYCODE_DPAD_DOWN
29+
adb shell input keyevent KEYCODE_DPAD_DOWN
30+
adb shell input keyevent KEYCODE_ENTER
31+
;;
32+
*)
33+
echo "Waiting for launcher..."
34+
sleep 3
35+
;;
36+
esac
37+
done
38+
39+
echo "Launcher is ready :-)"

0 commit comments

Comments
 (0)