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..858f7c5be2d3ac196fbd54afafd34d26539ae995 100644 |
--- a/build/android/pylib/device/battery_utils.py |
+++ b/build/android/pylib/device/battery_utils.py |
@@ -487,20 +487,17 @@ 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: |
perezju
2015/08/18 09:14:15
nit: maybe keep a logging.info to indicate whether
rnephew (Wrong account)
2015/08/18 14:54:53
Done.
|
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: |
self.DisableBatteryUpdates() |
@contextlib.contextmanager |