OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_run_skia: starts the correct skia program on the device, prints the | 3 # android_run_skia: starts the correct skia program on the device, prints the |
4 # output, and kills the app if interrupted. | 4 # output, and kills the app if interrupted. |
5 | 5 |
6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
7 source $SCRIPT_DIR/android_setup.sh | 7 source $SCRIPT_DIR/android_setup.sh |
8 source $SCRIPT_DIR/utils/setup_adb.sh | 8 source $SCRIPT_DIR/utils/setup_adb.sh |
9 | 9 |
10 if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ]; | 10 if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ]; |
11 then | 11 then |
12 echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library" | 12 echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library" |
13 exit 1 | 13 exit 1 |
14 fi | 14 fi |
15 | 15 |
| 16 verbose "pushing binaries onto the device..." |
16 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp | 17 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp |
17 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then | 18 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then |
18 # Does not exist for builds with static skia. | 19 # Does not exist for builds with static skia. |
19 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp | 20 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp |
20 fi | 21 fi |
21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp | 22 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp |
22 if [[ -n $RESOURCE_PATH ]]; then | 23 if [[ -n $RESOURCE_PATH ]]; then |
| 24 verbose "pushing resources onto the device..." |
23 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH | 25 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH |
24 fi | 26 fi |
25 | 27 |
26 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -c; fi | 28 if [ $LOGCAT ]; then |
| 29 verbose "clearing the device logs..." |
| 30 $ADB $DEVICE_SERIAL logcat -c; |
| 31 fi |
27 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" | 32 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" |
28 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" | 33 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" |
29 echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ | 34 echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ |
30 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ | 35 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ |
31 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} | 36 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} |
32 chmod +x ${CMD_FILENAME} | 37 chmod +x ${CMD_FILENAME} |
| 38 verbose "pushing command file onto the device..." |
33 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp | 39 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp |
34 rm ${CMD_FILENAME} | 40 rm ${CMD_FILENAME} |
| 41 verbose "preparing to run ${APP_ARGS[0]} on the device..." |
35 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME} | 42 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME} |
36 | 43 |
37 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then | 44 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then |
38 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 45 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
39 echo "***********************************************************************" | 46 echo "***********************************************************************" |
40 echo "The application terminated unexpectedly and did not produce an exit code
" | 47 echo "The application terminated unexpectedly and did not produce an exit code
" |
41 echo "***********************************************************************" | 48 echo "***********************************************************************" |
42 exit 1 | 49 exit 1 |
43 fi | 50 fi |
44 | 51 |
45 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` | 52 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` |
46 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME} | 53 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME} |
47 | 54 |
48 # check to see if the 'cat' command failed and print errors accordingly | 55 # check to see if the 'cat' command failed and print errors accordingly |
49 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then | 56 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then |
50 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 57 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
51 echo "***********************************************************************" | 58 echo "***********************************************************************" |
52 echo "ADB failed to retrieve the application's exit code" | 59 echo "ADB failed to retrieve the application's exit code" |
53 echo "***********************************************************************" | 60 echo "***********************************************************************" |
54 exit 1 | 61 exit 1 |
55 fi | 62 fi |
56 | 63 |
57 echo "EXIT_CODE is ${EXIT_CODE}" | 64 echo "EXIT_CODE is ${EXIT_CODE}" |
58 if [ $'0\r' != "${EXIT_CODE}" ]; then | 65 if [ $'0\r' != "${EXIT_CODE}" ]; then |
59 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 66 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
60 exit 1 | 67 exit 1 |
61 fi | 68 fi |
62 exit 0 | 69 exit 0 |
OLD | NEW |