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

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

Issue 1829753004: Splitting up wait_for_device into two pieces (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # Wait for the device to be ready to run tests. 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 source $SCRIPT_DIR/android_setup.sh 6 source $SCRIPT_DIR/android_setup.sh
7 source $SCRIPT_DIR/utils/setup_adb.sh 7 source $SCRIPT_DIR/utils/setup_adb.sh
8 8
9 # Helper function used by get_battery_level. Parses the battery level from 9 # Helper function used by get_battery_level. Parses the battery level from
10 # dumpsys output. 10 # dumpsys output.
11 function _parse_battery_level { 11 function _parse_battery_level {
12 SPLIT=( $@ ) 12 SPLIT=( $@ )
13 13
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if [ "$RV" != "-1" ]; then 56 if [ "$RV" != "-1" ]; then
57 echo "$RV" 57 echo "$RV"
58 return 58 return
59 fi 59 fi
60 60
61 echo "Could not determine battery level!" 1>&2 61 echo "Could not determine battery level!" 1>&2
62 # Just exit to prevent hanging forever or failing the build. 62 # Just exit to prevent hanging forever or failing the build.
63 echo "0" 63 echo "0"
64 } 64 }
65 65
66 set -e
67
68 # Wait for the device to be connected and fully booted.
69 while [ "$($ADB $DEVICE_SERIAL shell getprop sys.boot_completed | tr -d '\r')" ! = "1" ]; do
70 echo "Waiting for the device to be connected and ready."
71 sleep 5
72 done
73
74 # Wait for battery charge. 66 # Wait for battery charge.
75 DESIRED_BATTERY_LEVEL=80 67 DESIRED_BATTERY_LEVEL=80
76 CURRENT_BATTERY_LEVEL="$(get_battery_level)" 68 CURRENT_BATTERY_LEVEL="$(get_battery_level)"
77 while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do 69 while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do
78 echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRE D_BATTERY_LEVEL}" 70 echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRE D_BATTERY_LEVEL}"
79 sleep 5 71 sleep 5
80 CURRENT_BATTERY_LEVEL="$(get_battery_level)" 72 CURRENT_BATTERY_LEVEL="$(get_battery_level)"
81 done 73 done
82 74
83 echo "Ready!" 75 echo "Charged!"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698