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

Unified Diff: build/android/pylib/android_commands.py

Issue 228253003: Update usb charging command to wait for it to succeed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 years, 8 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 | tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 8faa1be4f860d4f779ee4743404b78dc9973cb96..21dd379d8672f7831ee991c6fe13b5c1bf521347 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -1870,14 +1870,30 @@ class AndroidCommands(object):
if not command:
raise Exception('Unable to act on usb charging.')
disable_command = command['disable_command']
- self.RunShellCommand(disable_command)
+ # Do not loop directly on self.IsDeviceCharging to cut the number of calls
+ # to the device.
+ while True:
+ self.RunShellCommand(disable_command)
+ if not self.IsDeviceCharging():
+ break
def EnableUsbCharging(self):
command = self._GetControlUsbChargingCommand()
if not command:
raise Exception('Unable to act on usb charging.')
disable_command = command['enable_command']
- self.RunShellCommand(disable_command)
+ # Do not loop directly on self.IsDeviceCharging to cut the number of calls
+ # to the device.
+ while True:
+ self.RunShellCommand(disable_command)
+ if self.IsDeviceCharging():
+ break
+
+ def IsDeviceCharging(self):
+ for line in self.RunShellCommand('dumpsys battery'):
+ if 'powered: ' in line:
+ if line.split('powered: ')[1] == 'true':
+ return True
class NewLineNormalizer(object):
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698