-
-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathlaunchAndroidEmulator
More file actions
executable file
·62 lines (53 loc) · 1.92 KB
/
Copy pathlaunchAndroidEmulator
File metadata and controls
executable file
·62 lines (53 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/androidEmulatorProfile
source "$SCRIPT_DIR/androidEmulatorProfile"
for tool in "$EMULATOR" "$ADB"; do
if [ ! -x "$tool" ]; then
echo "Required Android SDK tool not found or not executable: $tool" >&2
exit 1
fi
done
if ! "$EMULATOR" -list-avds | grep -Fxq "$AVD_NAME"; then
echo "Android emulator $AVD_NAME does not exist." >&2
echo "Run scripts/createAndroidEmulator first." >&2
exit 1
fi
if ! avd_matches_expected_profile; then
echo "Android emulator $AVD_NAME does not match the expected local test profile." >&2
echo "Delete or update it manually, then run scripts/createAndroidEmulator." >&2
exit 1
fi
if "$ADB" devices | awk 'NR > 1 && $2 == "device" { found = 1 } END { exit found ? 0 : 1 }'; then
boot_completed="$("$ADB" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r' || true)"
if [ "$boot_completed" = "1" ]; then
echo "Android device already connected and booted."
"$ADB" devices
exit 0
fi
fi
nohup "$EMULATOR" \
-avd "$AVD_NAME" \
-no-snapshot-save \
-no-window \
-gpu swiftshader_indirect \
-noaudio \
-no-boot-anim \
-camera-back none >/tmp/unstyled-tests-emulator.log 2>&1 &
"$ADB" wait-for-device
for _ in $(seq 1 180); do
boot_completed="$("$ADB" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r' || true)"
if [ "$boot_completed" = "1" ]; then
"$ADB" shell settings put global window_animation_scale 0 >/dev/null 2>&1 || true
"$ADB" shell settings put global transition_animation_scale 0 >/dev/null 2>&1 || true
"$ADB" shell settings put global animator_duration_scale 0 >/dev/null 2>&1 || true
echo "Android emulator $AVD_NAME is booted."
"$ADB" devices
exit 0
fi
sleep 1
done
echo "Timed out waiting for Android emulator $AVD_NAME to boot." >&2
echo "Emulator log: /tmp/unstyled-tests-emulator.log" >&2
exit 1