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

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, 8 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
« no previous file with comments | « build/android/provision_devices.py ('k') | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..91fa93bfc37145cc1e9d9baa9e7b0a68a2b2a271 100644
--- a/build/android/pylib/device/battery_utils.py
+++ b/build/android/pylib/device/battery_utils.py
@@ -246,3 +246,24 @@ class BatteryUtils(object):
yield
finally:
self.EnableBatteryUpdates(timeout=timeout, retries=retries)
+
+ def ChargeDeviceToLevel(self, level, wait_period=60):
+ """Enables charging and waits for device to be charged to given level.
+
+ Args:
+ level: level of charge to wait for.
+ wait_period: time in seconds to wait between checking.
+ """
+ self.SetCharging(True)
+
+ 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=wait_period)
« no previous file with comments | « build/android/provision_devices.py ('k') | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698