1#!/bin/bash
2#
3# android_install_skia: installs the skia apk on the device.
4
5function print_usage {
6  echo "USAGE: android_install_skia [options]"
7  echo " Options:         -f  Forces the package to be installed by removing any"
8  echo "                      previously installed packages"
9  echo "                  -h  Prints this help message"
10  echo "            --release Install the release build of Skia"
11  echo "      -s [device_s/n] Serial number of the device to be used"
12}
13
14SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
15
16source $SCRIPT_DIR/android_setup.sh
17source $SCRIPT_DIR/utils/setup_adb.sh
18
19forceRemoval="false"
20installLauncher="false"
21installOptions="-r"
22
23for arg in ${APP_ARGS[@]}
24do
25  if [[ "${arg}" == "-f" ]];
26  then
27    forceRemoval="true"
28  elif [[ "${arg}" == "-h" ]];
29  then
30    print_usage
31    exit
32  elif [[ "${arg}" == "-r" ]];
33  then
34    echo "DEPRECATED: -r is now a no-op"
35  else
36    echo "ERROR: unrecognized option ${arg}"
37    print_usage
38    exit 1;
39  fi
40done
41
42if [[ "$forceRemoval" == "true" ]];
43then
44    echo "Forcing removal of previously installed packages"
45    $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null
46fi
47
48echo "Installing Skia App from ${SKIA_OUT}/${BUILDTYPE}"
49$ADB ${DEVICE_SERIAL} install ${installOptions} ${SKIA_OUT}/${BUILDTYPE}/android/bin/SkiaAndroid.apk
50