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

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

Issue 993733002: Add new method to disable android device charging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/device_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/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']
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698