1#!/bin/bash
2#
3# android_launch_app: Launches the skia sampleApp on the device.
4
5SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6source $SCRIPT_DIR/android_setup.sh
7source $SCRIPT_DIR/utils/setup_adb.sh
8
9# TODO: check to ensure that the app exists on the device and prompt to install
10
11if [[ -n $RESOURCE_PATH ]]; then
12  adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
13fi
14
15app=${APP_ARGS[0]}
16if [[ ${app} == '-'* ]]; then
17    echo "Defaulting to running SampleApp."
18    app="SampleApp"
19    APP_ARGS=( "SampleApp" ${APP_ARGS[*]} )
20fi
21
22if [[ ${app} == 'SampleApp' ]]; then
23    activity="com.skia.sample_app/com.skia.SkiaSampleActivity"
24elif [[ ${app} == "VisualBench" ]] ; then
25    activity="com.skia.visualbench/com.skia.VisualBenchActivity"
26else
27    echo "ERROR: supports either 'SampleApp' or 'VisualBench' as valid apps"
28    exit 1
29fi
30$ADB ${DEVICE_SERIAL} shell "am start -S -n ${activity} --es cmdLineFlags \"${APP_ARGS[*]:1}\""
31