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

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

Issue 1293143002: [Android] Change battery_utils TieredSetCharging from exceptions based to discovery based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: logging Created 5 years, 4 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 | « no previous file | 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 ac5e7a87ae9187709b1d16f0f18bd6bb78dda183..1c7a06e7defc57159d63587b09e8a3915489c36f 100644
--- a/build/android/pylib/device/battery_utils.py
+++ b/build/android/pylib/device/battery_utils.py
@@ -487,20 +487,21 @@ class BatteryUtils(object):
logging.warning('Device charging already in expected state: %s', enabled)
return
+ self._DiscoverDeviceProfile()
if enabled:
- try:
+ if self._cache['profile']['enable_command']:
self.SetCharging(enabled)
- except device_errors.CommandFailedError:
- logging.info('Unable to enable charging via hardware.'
- ' Falling back to software enabling.')
+ else:
+ logging.info('Unable to enable charging via hardware. '
+ 'Falling back to software enabling.')
self.EnableBatteryUpdates()
else:
- try:
+ if self._cache['profile']['enable_command']:
self._ClearPowerData()
self.SetCharging(enabled)
- except device_errors.CommandFailedError:
- logging.info('Unable to disable charging via hardware.'
- ' Falling back to software disabling.')
+ else:
+ logging.info('Unable to disable charging via hardware. '
+ 'Falling back to software disabling.')
self.DisableBatteryUpdates()
@contextlib.contextmanager
« no previous file with comments | « no previous file | build/android/pylib/device/battery_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698