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

Unified 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: Remove unnecessary line 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/bin/adb_wait_for_device
diff --git a/platform_tools/android/bin/adb_wait_for_device b/platform_tools/android/bin/adb_wait_for_device
index 0b640d22b42349aa841066b2b5d7cf8f6691652f..882cd3fed47a4d078c4574d7bbcec680a288a753 100755
--- a/platform_tools/android/bin/adb_wait_for_device
+++ b/platform_tools/android/bin/adb_wait_for_device
@@ -1,14 +1,39 @@
#!/bin/bash
#
-# Wait for the device to be both attached and booted.
+# Wait for the device to be ready to run tests.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
+function get_battery_level {
+ STATS="$($ADB $DEVICE_SERIAL shell dumpsys batteryproperties)"
+ SPLIT=( $STATS )
+ for i in "${!SPLIT[@]}"; do
+ if [ "${SPLIT[$i]}" = "level:" ]; then
+ echo "${SPLIT[$i+1]}"
+ return
+ fi
+ done
+ echo "Could not determine battery level!" 1>&2
+ echo "0"
+}
+
set -e
-set -x
+# Wait for the device to be connected and fully booted.
while [ "$($ADB $DEVICE_SERIAL shell getprop sys.boot_completed | tr -d '\r')" != "1" ]; do
+ echo "Waiting for the device to be connected and ready."
sleep 5
done
+
+# Wait for battery charge.
+DESIRED_BATTERY_LEVEL=30
+CURRENT_BATTERY_LEVEL="$(get_battery_level)"
+while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do
+ echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRED_BATTERY_LEVEL}"
+ sleep 5
+ CURRENT_BATTERY_LEVEL="$(get_battery_level)"
+done
+
+echo "Ready!"
« 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