Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: platform_tools/android/bin/adb_wait_for_charge

Issue 2105813003: Check for empty output in adb_wait_for_charge. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # Wait for the device to be charged enough for testing. 3 # Wait for the device to be charged enough for testing.
4 4
5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6 SKIP_TOOLCHAIN_SETUP="true" 6 SKIP_TOOLCHAIN_SETUP="true"
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 # Helper function used by get_battery_level. Parses the battery level from 10 # Helper function used by get_battery_level. Parses the battery level from
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if [ -n "$RV" ]; then 47 if [ -n "$RV" ]; then
48 echo "$RV" 48 echo "$RV"
49 return 49 return
50 fi 50 fi
51 51
52 echo "Battery level fallback..." 1>&2 52 echo "Battery level fallback..." 1>&2
53 53
54 STATS="$($ADB $DEVICE_SERIAL shell dumpsys battery)" 54 STATS="$($ADB $DEVICE_SERIAL shell dumpsys battery)"
55 SPLIT=( $STATS ) 55 SPLIT=( $STATS )
56 RV="$(_parse_battery_level ${SPLIT[@]})" 56 RV="$(_parse_battery_level ${SPLIT[@]})"
57 if [ "$RV" != "-1" ]; then 57 if [ -n "$RV" ] && [ "$RV" != "-1" ]; then
58 echo "$RV" 58 echo "$RV"
59 return 59 return
60 fi 60 fi
61 61
62 echo "Could not determine battery level!" 1>&2 62 echo "Could not determine battery level!" 1>&2
63 # Just exit to prevent hanging forever or failing the build. 63 # Just exit to prevent hanging forever or failing the build.
64 echo "0" 64 echo "0"
65 } 65 }
66 66
67 # Wait for battery charge. 67 # Wait for battery charge.
68 DESIRED_BATTERY_LEVEL=80 68 DESIRED_BATTERY_LEVEL=80
69 CURRENT_BATTERY_LEVEL="$(get_battery_level)" 69 CURRENT_BATTERY_LEVEL="$(get_battery_level)"
70 while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do 70 while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do
71 echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRE D_BATTERY_LEVEL}" 71 echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRE D_BATTERY_LEVEL}"
72 sleep 5 72 sleep 5
73 CURRENT_BATTERY_LEVEL="$(get_battery_level)" 73 CURRENT_BATTERY_LEVEL="$(get_battery_level)"
74 done 74 done
75 75
76 echo "Charged!" 76 echo "Charged!"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698