aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/bin/android_install_app
blob: 74aea516c38cc6ffa67f467792ea90f8050de013 (plain)
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
65
66
67
68
69
70
71
72
#!/bin/bash
#
# android_install_app: installs the Skia development apps on the device.

function print_usage {
  echo "USAGE: android_install_app [options] AppName"
  echo " Options:         -f  Forces the package to be installed by removing any"
  echo "                      previously installed packages"
  echo "                  -h  Prints this help message"
  echo "            --release Install the release build of Skia"
  echo "      -s [device_s/n] Serial number of the device to be used"
  echo "              AppName Can be either SampleApp or Viewer"
}

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh

forceRemoval="false"
app=""

for arg in ${APP_ARGS[@]}; do
  if [[ "${arg}" == "-f" ]]; then
    forceRemoval="true"
  elif [[ "${arg}" == "-h" ]]; then
    print_usage
    exit
  elif [[ "${arg}" == "-r" ]]; then
    echo "DEPRECATED: -r is now a no-op"
  elif [[ ${arg} == '-'* ]]; then
    echo "ERROR: unrecognized option ${arg}"
    print_usage
    exit 1;
  else
    if [[ ${app} != "" ]]; then
      echo "ERROR: app already defined ${app}"
      exit 1;
    else
      app=${arg}
    fi
  fi
done

if [[ ${app} == "" ]]; then
  echo "Defaulting to installing SampleApp."
  app="SampleApp"
fi


if [[ "$forceRemoval" == "true" ]];
then
    echo "Forcing removal of previously installed packages"
    $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null
fi

if [[ "$BUILDTYPE" == "Release" ]];
then
    apk_suffix="release.apk"
else
    apk_suffix="debug.apk"
fi

if [[ ${app} == 'SampleApp' ]]; then
    app="sample_app"
fi

APP_LC=$(echo $app | tr "[:upper:]" "[:lower:]")

echo "Installing ${APP_LC} from ${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix}"
$ADB ${DEVICE_SERIAL} install -r ${SCRIPT_DIR}/../apps/${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix}