-
Notifications
You must be signed in to change notification settings - Fork 3
/
emulatorctl
executable file
·64 lines (58 loc) · 1.22 KB
/
emulatorctl
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
63
64
#!/usr/bin/env bash
function show_usage() {
echo "Usage:
$(basename "$") [options]"
echo ""
echo "Options:
-l List emulators / avds
-c [name] Create emulator / avd
-d Delete emulator / avd
-r Run emulator / avd
-e Exit emulator / avd
-v [api] Anroid API
-h Display this message"
}
if [[ $# -eq 0 ]]; then
show_usage
exit 1
fi
ACTION=0
ANDROID_API=34
EMULATOR_NAME=""
while getopts ":hldrec:v:" arg; do
case "${arg}" in
l)
avdmanager list avd
exit 0
;;
d)
avdmanager delete avd --name "$(avdmanager list avd -c | fzf)"
exit 0
;;
r)
echo "Starting emulator ..."
flutter emulators --launch "$(avdmanager list avd -c | fzf)"
exit 0
;;
e)
echo "Exiting emulator ..."
adb emu kill
exit 0
;;
c)
ACTION="create"
EMULATOR_NAME="${OPTARG}"
;;
v)
ANDROID_API="${OPTARG}"
;;
h | *)
show_usage
exit 0
;;
esac
done
if [[ ${ACTION} == "create" ]]; then
avdmanager create avd --name "${EMULATOR_NAME}-android-${ANDROID_API}" --package "system-images;android-${ANDROID_API}-ext12;google_apis_playstore;x86_64"
fi
exit 0