Chromium Code Reviews| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 full_reboot: Whether to fully reboot the device or just restart the shell. | 343 full_reboot: Whether to fully reboot the device or just restart the shell. |
| 344 """ | 344 """ |
| 345 # TODO(torne): hive can't reboot the device either way without breaking the | 345 # TODO(torne): hive can't reboot the device either way without breaking the |
| 346 # connection; work out if we can handle this better | 346 # connection; work out if we can handle this better |
| 347 if os.environ.get('USING_HIVE'): | 347 if os.environ.get('USING_HIVE'): |
| 348 logging.warning('Ignoring reboot request as we are on hive') | 348 logging.warning('Ignoring reboot request as we are on hive') |
| 349 return | 349 return |
| 350 if full_reboot or not self.IsRootEnabled(): | 350 if full_reboot or not self.IsRootEnabled(): |
| 351 self._adb.SendCommand('reboot') | 351 self._adb.SendCommand('reboot') |
| 352 timeout = 300 | 352 timeout = 300 |
| 353 retries = 1 | |
| 354 # Wait for the device to disappear. | |
| 355 while retries < 10 and self._device in GetAttachedDevices(): | |
|
frankf
2013/08/09 18:06:29
Ah, makes sense. nit: self.IsOnline()
bulach
2013/08/09 18:17:19
Done.
| |
| 356 time.sleep(1) | |
| 357 retries += 1 | |
| 353 else: | 358 else: |
| 354 self.RestartShell() | 359 self.RestartShell() |
| 355 timeout = 120 | 360 timeout = 120 |
| 356 # To run tests we need at least the package manager and the sd card (or | 361 # To run tests we need at least the package manager and the sd card (or |
| 357 # other external storage) to be ready. | 362 # other external storage) to be ready. |
| 358 self.WaitForDevicePm() | 363 self.WaitForDevicePm() |
|
frankf
2013/08/09 17:30:51
Doesn't WaitForDevicePm already do a 'wait-for-dev
bulach
2013/08/09 17:35:44
it does, but looks like that can succeed *before*
| |
| 359 self.WaitForSdCardReady(timeout) | 364 self.WaitForSdCardReady(timeout) |
| 360 | 365 |
| 361 def Shutdown(self): | 366 def Shutdown(self): |
| 362 """Shuts down the device.""" | 367 """Shuts down the device.""" |
| 363 self._adb.SendCommand('reboot -p') | 368 self._adb.SendCommand('reboot -p') |
| 364 | 369 |
| 365 def Uninstall(self, package): | 370 def Uninstall(self, package): |
| 366 """Uninstalls the specified package from the device. | 371 """Uninstalls the specified package from the device. |
| 367 | 372 |
| 368 Args: | 373 Args: |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1514 """ | 1519 """ |
| 1515 def __init__(self, output): | 1520 def __init__(self, output): |
| 1516 self._output = output | 1521 self._output = output |
| 1517 | 1522 |
| 1518 def write(self, data): | 1523 def write(self, data): |
| 1519 data = data.replace('\r\r\n', '\n') | 1524 data = data.replace('\r\r\n', '\n') |
| 1520 self._output.write(data) | 1525 self._output.write(data) |
| 1521 | 1526 |
| 1522 def flush(self): | 1527 def flush(self): |
| 1523 self._output.flush() | 1528 self._output.flush() |
| OLD | NEW |