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

Unified Diff: build/android/pylib/device/battery_utils.py

Issue 1057563002: [Android] Convert to BatteryUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/device/battery_utils.py
diff --git a/build/android/pylib/device/battery_utils.py b/build/android/pylib/device/battery_utils.py
index 96e3bf660c5841642ba3fc0fb88e560b11314df5..9d872e0e45ae0ae699e8af75527b0da4bcb97db6 100644
--- a/build/android/pylib/device/battery_utils.py
+++ b/build/android/pylib/device/battery_utils.py
@@ -246,3 +246,23 @@ class BatteryUtils(object):
yield
finally:
self.EnableBatteryUpdates(timeout=timeout, retries=retries)
+
+ def ChargeDeviceToLevel(self, level):
nednguyen 2015/04/01 22:17:39 Maybe this needn't be addressed in this patch but
jbudorick 2015/04/01 22:32:21 Why does this matter?
jbudorick 2015/04/01 22:34:15 Actually, this comment should just make it explici
nednguyen 2015/04/01 22:49:06 Just looking at the method name, it's unclear what
jbudorick 2015/04/01 22:58:51 We generally want our devices in a charging state
rnephew (Wrong account) 2015/04/01 23:01:04 Added comment saying it enabled charging.
+ """ Waits for device to be charged to given level.
+
+ Args:
+ level: level of charge to wait for.
+ """
+ self.SetCharging(True)
nednguyen 2015/04/01 22:17:39 Assume that the device's charging state is off, an
jbudorick 2015/04/01 22:32:21 I don't see why a user asking for a device to be c
+
+ def device_charged():
+ battery_level = self.GetBatteryInfo().get('level')
+ if battery_level is None:
+ logging.warning('Unable to find current battery level.')
+ battery_level = 100
+ else:
+ logging.info('current battery level: %s', battery_level)
+ battery_level = int(battery_level)
+ return battery_level >= level
+
+ timeout_retry.WaitFor(device_charged, wait_period=60)

Powered by Google App Engine
This is Rietveld 408576698