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 b6fd7323bb9a3c71e566049719a963bba2ce9023..a988e8df476bf1d72852fae32d12de2fdee3ff69 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -69,6 +69,11 @@ _CONTROL_CHARGING_COMMANDS = [ |
}, |
] |
+_DEFAULT_CHARGING_COMMANDS = { |
+ 'witness_file': None, |
+ 'enable_command': 'dumpsys battery reset', |
+ 'disable_command': 'dumpsys battery set usb 0', |
+} |
@decorators.WithExplicitTimeoutAndRetries( |
_DEFAULT_TIMEOUT, _DEFAULT_RETRIES) |
@@ -1414,8 +1419,17 @@ class DeviceUtils(object): |
# Skip the first line, which is just a header. |
for line in self.RunShellCommand( |
['dumpsys', 'battery'], check_return=True)[1:]: |
- k, v = line.split(': ', 1) |
- result[k.strip()] = v.strip() |
+ # If usb charging has been disabled, an extra line of header exists. |
+ # If usb charging has been disabled, an extra line of header exists. |
klundberg
2015/03/11 14:27:14
I'm seeing double :-)
Please remove one of the co
rnephew (Wrong account)
2015/03/11 18:27:01
Done.
|
+ if 'UPDATES STOPPED' in line: |
+ logging.warning('Dumpsys battery not recieving updates. ' |
klundberg
2015/03/11 14:27:14
s/recieving/receiving
rnephew (Wrong account)
2015/03/11 18:27:01
Done.
|
+ 'Run dumpsys battery reset if this is in error.') |
+ elif ':' not in line: |
+ logging.warning('Unknown line found in dumpsys battery.') |
+ logging.warning(line) |
+ else: |
+ k, v = line.split(': ', 1) |
+ result[k.strip()] = v.strip() |
return result |
@decorators.WithTimeoutAndRetriesFromInstance() |
@@ -1451,8 +1465,9 @@ class DeviceUtils(object): |
self._cache['charging_config'] = c |
break |
else: |
- raise device_errors.CommandFailedError( |
- 'Unable to find charging commands.') |
+ logging.warning('No charging information found.' |
+ 'Defaulting to generic values.') |
+ self._cache['charging_config'] = _DEFAULT_CHARGING_COMMANDS |
if enabled: |
command = self._cache['charging_config']['enable_command'] |