| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
| 6 | 6 |
| 7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
| 8 """ | 8 """ |
| 9 # pylint: disable-all | 9 # pylint: disable-all |
| 10 | 10 |
| (...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 def DisableUsbCharging(self, timeout=10): | 1920 def DisableUsbCharging(self, timeout=10): |
| 1921 command = self._GetControlUsbChargingCommand() | 1921 command = self._GetControlUsbChargingCommand() |
| 1922 if not command: | 1922 if not command: |
| 1923 raise Exception('Unable to act on usb charging.') | 1923 raise Exception('Unable to act on usb charging.') |
| 1924 disable_command = command['disable_command'] | 1924 disable_command = command['disable_command'] |
| 1925 t0 = time.time() | 1925 t0 = time.time() |
| 1926 # Do not loop directly on self.IsDeviceCharging to cut the number of calls | 1926 # Do not loop directly on self.IsDeviceCharging to cut the number of calls |
| 1927 # to the device. | 1927 # to the device. |
| 1928 while True: | 1928 while True: |
| 1929 if t0 + timeout - time.time() < 0: | 1929 if t0 + timeout - time.time() < 0: |
| 1930 raise pexpect.TIMEOUT('Unable to enable USB charging in time.') | 1930 raise pexpect.TIMEOUT('Unable to disable USB charging in time: %s' % ( |
| 1931 self.GetBatteryInfo())) |
| 1931 self.RunShellCommand(disable_command) | 1932 self.RunShellCommand(disable_command) |
| 1932 if not self.IsDeviceCharging(): | 1933 if not self.IsDeviceCharging(): |
| 1933 break | 1934 break |
| 1934 | 1935 |
| 1935 def EnableUsbCharging(self, timeout=10): | 1936 def EnableUsbCharging(self, timeout=10): |
| 1936 command = self._GetControlUsbChargingCommand() | 1937 command = self._GetControlUsbChargingCommand() |
| 1937 if not command: | 1938 if not command: |
| 1938 raise Exception('Unable to act on usb charging.') | 1939 raise Exception('Unable to act on usb charging.') |
| 1939 disable_command = command['enable_command'] | 1940 disable_command = command['enable_command'] |
| 1940 t0 = time.time() | 1941 t0 = time.time() |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1965 """ | 1966 """ |
| 1966 def __init__(self, output): | 1967 def __init__(self, output): |
| 1967 self._output = output | 1968 self._output = output |
| 1968 | 1969 |
| 1969 def write(self, data): | 1970 def write(self, data): |
| 1970 data = data.replace('\r\r\n', '\n') | 1971 data = data.replace('\r\r\n', '\n') |
| 1971 self._output.write(data) | 1972 self._output.write(data) |
| 1972 | 1973 |
| 1973 def flush(self): | 1974 def flush(self): |
| 1974 self._output.flush() | 1975 self._output.flush() |
| OLD | NEW |