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..c717e931958bb6954b807c1288fe2d1edf8ffef6 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,10 @@ 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 ':' in line: |
+ k, v = line.split(': ', 1) |
+ result[k.strip()] = v.strip() |
perezju
2015/03/10 09:46:09
I think you should just log a warning on all skipp
|
return result |
@decorators.WithTimeoutAndRetriesFromInstance() |
@@ -1451,8 +1458,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 |
jbudorick
2015/03/10 00:04:43
This isn't quite what I suggested in the last CL.
perezju
2015/03/10 09:46:09
I'm not entirely sure I understand what these dump
jbudorick
2015/03/10 13:22:35
AFAIK this actually affects charging to some degre
|
if enabled: |
command = self._cache['charging_config']['enable_command'] |