OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_install_app: installs the Skia development apps on the device. | 3 # android_install_app: installs the Skia development apps on the device. |
4 | 4 |
5 function print_usage { | 5 function print_usage { |
6 echo "USAGE: android_install_app [options] AppName" | 6 echo "USAGE: android_install_app [options]" |
7 echo " Options: -f Forces the package to be installed by removing any
" | 7 echo " Options: -f Forces the package to be installed by removing any
" |
8 echo " previously installed packages" | 8 echo " previously installed packages" |
9 echo " -h Prints this help message" | 9 echo " -h Prints this help message" |
10 echo " --release Install the release build of Skia" | 10 echo " --release Install the release build of Skia" |
11 echo " -s [device_s/n] Serial number of the device to be used" | 11 echo " -s [device_s/n] Serial number of the device to be used" |
12 echo " AppName Can be either SampleApp or Viewer" | |
13 } | 12 } |
14 | 13 |
15 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 14 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
16 | 15 |
17 source $SCRIPT_DIR/android_setup.sh | 16 source $SCRIPT_DIR/android_setup.sh |
18 source $SCRIPT_DIR/utils/setup_adb.sh | 17 source $SCRIPT_DIR/utils/setup_adb.sh |
19 | 18 |
20 forceRemoval="false" | 19 forceRemoval="false" |
21 app="" | |
22 | 20 |
23 for arg in ${APP_ARGS[@]}; do | 21 for arg in ${APP_ARGS[@]}; do |
24 if [[ "${arg}" == "-f" ]]; then | 22 if [[ "${arg}" == "-f" ]]; then |
25 forceRemoval="true" | 23 forceRemoval="true" |
26 elif [[ "${arg}" == "-h" ]]; then | 24 elif [[ "${arg}" == "-h" ]]; then |
27 print_usage | 25 print_usage |
28 exit | 26 exit |
29 elif [[ "${arg}" == "-r" ]]; then | 27 elif [[ "${arg}" == "-r" ]]; then |
30 echo "DEPRECATED: -r is now a no-op" | 28 echo "DEPRECATED: -r is now a no-op" |
31 elif [[ ${arg} == '-'* ]]; then | 29 elif [[ ${arg} == '-'* ]]; then |
32 echo "ERROR: unrecognized option ${arg}" | 30 echo "ERROR: unrecognized option ${arg}" |
33 print_usage | 31 print_usage |
34 exit 1; | 32 exit 1; |
35 else | |
36 if [[ ${app} != "" ]]; then | |
37 echo "ERROR: app already defined ${app}" | |
38 exit 1; | |
39 else | |
40 app=${arg} | |
41 fi | |
42 fi | 33 fi |
43 done | 34 done |
44 | 35 |
45 if [[ ${app} == "" ]]; then | |
46 echo "Defaulting to installing SampleApp." | |
47 app="SampleApp" | |
48 fi | |
49 | |
50 | 36 |
51 if [[ "$forceRemoval" == "true" ]]; | 37 if [[ "$forceRemoval" == "true" ]]; |
52 then | 38 then |
53 echo "Forcing removal of previously installed packages" | 39 echo "Forcing removal of previously installed packages" |
54 $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null | 40 $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null |
55 fi | 41 fi |
56 | 42 |
57 if [[ "$BUILDTYPE" == "Release" ]]; | 43 if [[ "$BUILDTYPE" == "Release" ]]; |
58 then | 44 then |
59 apk_suffix="release.apk" | 45 apk_suffix="release.apk" |
60 else | 46 else |
61 apk_suffix="debug.apk" | 47 apk_suffix="debug.apk" |
62 fi | 48 fi |
63 | 49 |
64 if [[ ${app} == 'SampleApp' ]]; then | 50 APP_LC=$(echo Viewer | tr "[:upper:]" "[:lower:]") |
65 app="sample_app" | |
66 fi | |
67 | |
68 APP_LC=$(echo $app | tr "[:upper:]" "[:lower:]") | |
69 | 51 |
70 echo "Installing ${APP_LC} from ${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_
ARCH}-${apk_suffix}" | 52 echo "Installing ${APP_LC} from ${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_
ARCH}-${apk_suffix}" |
71 $ADB ${DEVICE_SERIAL} install -r ${SCRIPT_DIR}/../apps/${APP_LC}/build/outputs/a
pk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix} | 53 $ADB ${DEVICE_SERIAL} install -r ${SCRIPT_DIR}/../apps/${APP_LC}/build/outputs/a
pk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix} |
72 | 54 |
OLD | NEW |