| 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 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 return ret | 495 return ret |
| 496 | 496 |
| 497 def StartAdbServer(self): | 497 def StartAdbServer(self): |
| 498 """Start adb server.""" | 498 """Start adb server.""" |
| 499 adb_cmd = ['taskset', '-c', '0', constants.ADB_PATH, 'start-server'] | 499 adb_cmd = ['taskset', '-c', '0', constants.ADB_PATH, 'start-server'] |
| 500 ret = cmd_helper.RunCmd(adb_cmd) | 500 ret = cmd_helper.RunCmd(adb_cmd) |
| 501 retry = 0 | 501 retry = 0 |
| 502 while retry < 3: | 502 while retry < 3: |
| 503 ret = cmd_helper.RunCmd(['pgrep', 'adb']) | 503 ret = cmd_helper.RunCmd(['pgrep', 'adb']) |
| 504 if ret == 0: | 504 if ret == 0: |
| 505 # pgrep found adb, start-server succeeded. | 505 # pgrep fonud adb, start-server succeeded. |
| 506 # Waiting for device to reconnect before returning success. | |
| 507 self._adb.SendCommand('wait-for-device') | |
| 508 return 0 | 506 return 0 |
| 509 retry += 1 | 507 retry += 1 |
| 510 time.sleep(retry) | 508 time.sleep(retry) |
| 511 return ret | 509 return ret |
| 512 | 510 |
| 513 def WaitForSystemBootCompleted(self, wait_time): | 511 def WaitForSystemBootCompleted(self, wait_time): |
| 514 """Waits for targeted system's boot_completed flag to be set. | 512 """Waits for targeted system's boot_completed flag to be set. |
| 515 | 513 |
| 516 Args: | 514 Args: |
| 517 wait_time: time in seconds to wait | 515 wait_time: time in seconds to wait |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 """ | 1703 """ |
| 1706 def __init__(self, output): | 1704 def __init__(self, output): |
| 1707 self._output = output | 1705 self._output = output |
| 1708 | 1706 |
| 1709 def write(self, data): | 1707 def write(self, data): |
| 1710 data = data.replace('\r\r\n', '\n') | 1708 data = data.replace('\r\r\n', '\n') |
| 1711 self._output.write(data) | 1709 self._output.write(data) |
| 1712 | 1710 |
| 1713 def flush(self): | 1711 def flush(self): |
| 1714 self._output.flush() | 1712 self._output.flush() |
| OLD | NEW |