| 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
|
|
|