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

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

Issue 1522013002: Add minimum battery level to adb_wait_for_device (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 both attached and booted. 3 # Wait for the device to be ready to run tests.
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 BATTERY_LEVEL=0
rmistry 2015/12/14 13:35:05 Remove.
borenet 2015/12/14 13:42:09 Done.
10
11 function get_battery_level {
12 STATS="$($ADB $DEVICE_SERIAL shell dumpsys batteryproperties)"
13 SPLIT=( $STATS )
14 for i in "${!SPLIT[@]}"; do
15 if [ "${SPLIT[$i]}" = "level:" ]; then
16 BATTERY_LEVEL="${SPLIT[$i+1]}"
17 return
18 fi
19 done
20 echo "No battery level found!"
21 }
22
9 set -e 23 set -e
10 set -x
11 24
25 # Wait for the device to be connected and fully booted.
12 while [ "$($ADB $DEVICE_SERIAL shell getprop sys.boot_completed | tr -d '\r')" ! = "1" ]; do 26 while [ "$($ADB $DEVICE_SERIAL shell getprop sys.boot_completed | tr -d '\r')" ! = "1" ]; do
27 echo "Waiting for the device to be connected and ready."
13 sleep 5 28 sleep 5
14 done 29 done
30
31 # Wait for battery charge.
32 DESIRED_BATTERY_LEVEL=30
33 get_battery_level
rmistry 2015/12/14 13:11:27 Working on the global BATTERY_LEVEL is confusing.
borenet 2015/12/14 13:26:56 I'm not aware of a way to do that in a bash script
rmistry 2015/12/14 13:35:05 Yes that is how you return values from bash functi
borenet 2015/12/14 13:42:09 No, but they don't hurt anything, and my bash para
34 while [ "$BATTERY_LEVEL" -lt "$DESIRED_BATTERY_LEVEL" ]; do
35 echo "Battery level is ${BATTERY_LEVEL}; waiting to charge to ${DESIRED_BATTER Y_LEVEL}"
36 sleep 5
rmistry 2015/12/14 13:11:27 5 seconds seems like a very short time to wait for
borenet 2015/12/14 13:26:56 The work we're doing every 5 seconds is cheap, and
rmistry 2015/12/14 13:35:05 Sounds good since the calls are cheap. Can always
37 get_battery_level
38 done
39
40 echo "Ready!"
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