1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3#
4# This source code is licensed under the MIT license found in the
5# LICENSE file in the root directory of this source tree.
6
7# Runs an Android emulator locally.
8# If there already is a running emulator, this just uses that.
9# The only reason to use this config is that it represents a known-good
10# virtual device configuration.
11# This is useful for running integration tests on a local machine.
12
13THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
14
15STATE=`adb get-state`
16
17if [ -n "$STATE" ]; then
18    echo "An emulator is already running."
19    exit 1
20fi
21
22echo "Installing packages"
23source "${THIS_DIR}/android-setup.sh" && getAndroidPackages
24
25echo "Creating Android virtual device..."
26source "${THIS_DIR}/android-setup.sh" && createAVD
27
28echo "Launching Android virtual device..."
29source "${THIS_DIR}/android-setup.sh" && launchAVD
30