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

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

Issue 1040473002: [android] Create Battery Utils to seperate power functionality (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/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index 9f538e1b0efd9f51ffaa4c1345febe8149edccc6..e36047b10466b0c80147f17a2850265cb3241ec5 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -1438,6 +1438,7 @@ class DeviceUtils(object):
"""
return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs)
+ # TODO(rnephew): Remove when battery_utils is switched to.
@decorators.WithTimeoutAndRetriesFromInstance()
def GetBatteryInfo(self, timeout=None, retries=None):
"""Gets battery info for the device.
@@ -1465,6 +1466,7 @@ class DeviceUtils(object):
result[k.strip()] = v.strip()
return result
+ # TODO(rnephew): Remove when battery_utils is switched to.
@decorators.WithTimeoutAndRetriesFromInstance()
def GetCharging(self, timeout=None, retries=None):
"""Gets the charging state of the device.
@@ -1482,6 +1484,7 @@ class DeviceUtils(object):
return True
return False
+ # TODO(rnephew): Remove when battery_utils is switched to.
@decorators.WithTimeoutAndRetriesFromInstance()
def SetCharging(self, enabled, timeout=None, retries=None):
"""Enables or disables charging on the device.
@@ -1512,7 +1515,7 @@ class DeviceUtils(object):
timeout_retry.WaitFor(set_and_verify_charging, wait_period=1)
- # TODO(rnephew): Make private when all use cases can use the context manager.
+ # TODO(rnephew): Remove when battery_utils is switched to.
@decorators.WithTimeoutAndRetriesFromInstance()
def DisableBatteryUpdates(self, timeout=None, retries=None):
""" Resets battery data and makes device appear like it is not
@@ -1542,7 +1545,7 @@ class DeviceUtils(object):
check_return=True)
timeout_retry.WaitFor(battery_updates_disabled, wait_period=1)
- # TODO(rnephew): Make private when all use cases can use the context manager.
+ # TODO(rnephew): Remove when battery_utils is switched to.
@decorators.WithTimeoutAndRetriesFromInstance()
def EnableBatteryUpdates(self, timeout=None, retries=None):
""" Restarts device charging so that dumpsys no longer collects power data.
@@ -1559,6 +1562,7 @@ class DeviceUtils(object):
self.RunShellCommand(['dumpsys', 'battery', 'reset'], check_return=True)
timeout_retry.WaitFor(battery_updates_enabled, wait_period=1)
+ # TODO(rnephew): Remove when battery_utils is switched to.
@contextlib.contextmanager
def BatteryMeasurement(self, timeout=None, retries=None):
"""Context manager that enables battery data collection. It makes
@@ -1648,3 +1652,20 @@ class DeviceUtils(object):
return parallelizer.Parallelizer(devices)
else:
return parallelizer.SyncParallelizer(devices)
+
+ # TODO(rnephew): Implement cache class.
+ def GetCacheEntry(self, key):
perezju 2015/03/30 11:05:23 I'm not sure I like this idea. Why would a class e
jbudorick 2015/03/30 13:35:03 BatteryUtils doesn't know how to control the lifet
rnephew (Wrong account) 2015/03/30 17:50:29 It will use this when it stops passing the calls t
+ """Cache getter."""
+ return self._cache.get(key)
+
+ def SetCacheEntry(self, key, value, override=False):
+ """Cache setter."""
+ if key not in self._cache:
+ self._cache[key] = value
+ elif override and value != self._cache[key]:
+ logging.warning('%s already in cache. Overriding %s with %s.', key,
+ self._cache[key], value)
+ self._cache[key] = value
+ else:
+ logging.warning('%s already in cache. Not overriding %s with %s.', key,
+ self._cache[key], value)
« build/android/pylib/device/battery_utils.py ('K') | « build/android/pylib/device/device_errors.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698