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 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp | 16 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp |
17 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then | 17 if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then |
18 # Does not exist for builds with static skia. | 18 # Does not exist for builds with static skia. |
19 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp | 19 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/loc
al/tmp |
20 fi | 20 fi |
21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp | 21 adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local
/tmp |
22 if [[ -n $RESOURCE_PATH ]]; then | 22 if [[ -n $RESOURCE_PATH ]]; then |
23 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH | 23 adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH |
24 fi | 24 fi |
25 | 25 |
26 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -c; fi | 26 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -c; fi |
27 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" | 27 STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" |
28 $ADB ${DEVICE_SERIAL} shell \ | 28 CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" |
29 "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ | 29 echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ |
30 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; echo \$? > ${STATUS_FILENAME}
" | 30 /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ |
| 31 echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} |
| 32 chmod +x ${CMD_FILENAME} |
| 33 $ADB ${DEVICE_SERIAL} push ${CMD_FILENAME} /data/local/tmp |
| 34 rm ${CMD_FILENAME} |
| 35 $ADB ${DEVICE_SERIAL} shell sh /data/local/tmp/${CMD_FILENAME} |
| 36 |
31 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then | 37 if [ -z "$($ADB $DEVICE_SERIAL shell 'if [ -f $STATUS_FILENAME ]; then echo exis
ts; fi')" ]; then |
32 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 38 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
33 echo "***********************************************************************" | 39 echo "***********************************************************************" |
34 echo "The application terminated unexpectedly and did not produce an exit code
" | 40 echo "The application terminated unexpectedly and did not produce an exit code
" |
35 echo "***********************************************************************" | 41 echo "***********************************************************************" |
36 exit 1 | 42 exit 1 |
37 fi | 43 fi |
38 | 44 |
39 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` | 45 EXIT_CODE=`$ADB ${DEVICE_SERIAL} shell cat ${STATUS_FILENAME}` |
40 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} | 46 $ADB ${DEVICE_SERIAL} shell rm -f ${STATUS_FILENAME} ${CMD_FILENAME} |
41 | 47 |
42 # check to see if the 'cat' command failed and print errors accordingly | 48 # check to see if the 'cat' command failed and print errors accordingly |
43 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then | 49 if [[ ${EXIT_CODE} == *${STATUS_FILENAME}* ]]; then |
44 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 50 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
45 echo "***********************************************************************" | 51 echo "***********************************************************************" |
46 echo "ADB failed to retrieve the application's exit code" | 52 echo "ADB failed to retrieve the application's exit code" |
47 echo "***********************************************************************" | 53 echo "***********************************************************************" |
48 exit 1 | 54 exit 1 |
49 fi | 55 fi |
50 | 56 |
51 echo "EXIT_CODE is ${EXIT_CODE}" | 57 echo "EXIT_CODE is ${EXIT_CODE}" |
52 if [ $'0\r' != "${EXIT_CODE}" ]; then | 58 if [ $'0\r' != "${EXIT_CODE}" ]; then |
53 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi | 59 if [ $LOGCAT ]; then $ADB $DEVICE_SERIAL logcat -d; fi |
54 exit 1 | 60 exit 1 |
55 fi | 61 fi |
56 exit 0 | 62 exit 0 |
OLD | NEW |