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

Unified Diff: platform_tools/android/bin/adb_wait_for_device

Issue 1527713002: adb_wait_for_device: More fixes (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 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 fc8a0f118dd5402ff2ec345104febf0be58c02d4..acf73b1bcc20942a7d9373eb9a50d44967577596 100755
--- a/platform_tools/android/bin/adb_wait_for_device
+++ b/platform_tools/android/bin/adb_wait_for_device
@@ -6,7 +6,9 @@ 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 {
+# Helper function used by get_battery_level. Parses the battery level from
+# dumpsys output.
+function _parse_battery_level {
SPLIT=( $@ )
HAS_BATTERY=1
@@ -18,7 +20,7 @@ function _get_battery_level {
fi
if [ "${SPLIT[$i]}" = "present:" ]; then
PRESENT="$(echo "${SPLIT[$i+1]}" | tr -d '\r')"
- if [ "$PRESENT" -eq "0" ]; then
+ if [ "$PRESENT" = "0" ]; then
borenet 2015/12/14 18:26:24 Prevents error if PRESENT is not an integer, eg. "
HAS_BATTERY=0
fi
if [ "$PRESENT" = "false" ]; then
@@ -36,10 +38,11 @@ function _get_battery_level {
echo "100"
}
+# Echo the battery level percentage of the attached Android device.
function get_battery_level {
STATS="$($ADB $DEVICE_SERIAL shell dumpsys batteryproperties)"
SPLIT=( $STATS )
- RV="$(_get_battery_level ${SPLIT[@]})"
+ RV="$(_parse_battery_level ${SPLIT[@]})"
if [ -n "$RV" ]; then
echo "$RV"
return
@@ -49,7 +52,7 @@ function get_battery_level {
STATS="$($ADB $DEVICE_SERIAL shell dumpsys battery)"
SPLIT=( $STATS )
- RV="$(_get_battery_level ${SPLIT[@]})"
+ RV="$(_parse_battery_level ${SPLIT[@]})"
if [ "$RV" != "-1" ]; then
echo "$RV"
return
« 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