File: start.sh

package info (click to toggle)
roc-toolkit 0.4.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,700 kB
  • sloc: cpp: 102,987; ansic: 8,959; python: 6,125; sh: 942; makefile: 19; javascript: 9
file content (39 lines) | stat: -rwxr-xr-x 821 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

set -euo pipefail

function color_msg() {
    printf '%s \033[1;35m%s\033[0m\n' "---" "$1"
}

function run_cmd() {
    echo "+++ $*"
    "$@" || exit 1
}

export PATH="$ANDROID_SDK_ROOT/tools/bin:${PATH}"
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:${PATH}"

# create avd if it doesn't exist
if ! avdmanager list avd -c | grep -qF roc_device
then
    color_msg "creating avd"
    run_cmd device \
        --name roc_device --image "default" --arch "${ABI}" --api "${API}" \
        create
fi

# show avd list
color_msg "checking avd"
run_cmd avdmanager list avd

# start emulator if it's not started
if ! adb devices | grep -qF emulator
then
    color_msg "starting device"
    run_cmd device --name roc_device start
fi

# show device list
color_msg "checking device"
run_cmd adb devices