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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 # Force a hard reboot on last attempt | 452 # Force a hard reboot on last attempt |
453 self.Reboot(full_reboot=(reboots_left == 1)) | 453 self.Reboot(full_reboot=(reboots_left == 1)) |
454 reboots_left -= 1 | 454 reboots_left -= 1 |
455 | 455 |
456 def MakeSystemFolderWritable(self): | 456 def MakeSystemFolderWritable(self): |
457 """Remounts the /system folder rw.""" | 457 """Remounts the /system folder rw.""" |
458 out = self._adb.SendCommand('remount') | 458 out = self._adb.SendCommand('remount') |
459 if out.strip() != 'remount succeeded': | 459 if out.strip() != 'remount succeeded': |
460 raise errors.MsgException('Remount failed: %s' % out) | 460 raise errors.MsgException('Remount failed: %s' % out) |
461 | 461 |
| 462 def KillAdbdDevice(self): |
| 463 logging.info('Killing adbd on the device...') |
| 464 adb_pids = self.ExtractPid('adbd') |
| 465 if adb_pids: |
| 466 self.RunShellCommandWithSU('kill %s' % ' '.join(adb_pids)) |
| 467 logging.info('Waiting for device to settle...') |
| 468 time.sleep(5) |
| 469 |
462 def RestartAdbServer(self): | 470 def RestartAdbServer(self): |
463 """Restart the adb server.""" | 471 """Restart the adb server.""" |
464 ret = self.KillAdbServer() | 472 ret = self.KillAdbServer() |
465 if ret != 0: | 473 if ret != 0: |
466 raise errors.MsgException('KillAdbServer: %d' % ret) | 474 raise errors.MsgException('KillAdbServer: %d' % ret) |
467 | 475 |
468 ret = self.StartAdbServer() | 476 ret = self.StartAdbServer() |
469 if ret != 0: | 477 if ret != 0: |
470 raise errors.MsgException('StartAdbServer: %d' % ret) | 478 raise errors.MsgException('StartAdbServer: %d' % ret) |
471 | 479 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 """ | 1618 """ |
1611 def __init__(self, output): | 1619 def __init__(self, output): |
1612 self._output = output | 1620 self._output = output |
1613 | 1621 |
1614 def write(self, data): | 1622 def write(self, data): |
1615 data = data.replace('\r\r\n', '\n') | 1623 data = data.replace('\r\r\n', '\n') |
1616 self._output.write(data) | 1624 self._output.write(data) |
1617 | 1625 |
1618 def flush(self): | 1626 def flush(self): |
1619 self._output.flush() | 1627 self._output.flush() |
OLD | NEW |