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

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: 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
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..1205cb8f6534a8406ccc5746e4d9f176b098adc6 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 'true' == line.split('powered: ')[1]:
Philippe 2014/04/08 11:27:08 Nit: I would swap the two operands here for readab
qsr 2014/04/08 15:37:05 Done.
+ return True
class NewLineNormalizer(object):

Powered by Google App Engine
This is Rietveld 408576698