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 | |
470 def RestartAdbServer(self): | 462 def RestartAdbServer(self): |
471 """Restart the adb server.""" | 463 """Restart the adb server.""" |
472 ret = self.KillAdbServer() | 464 ret = self.KillAdbServer() |
473 if ret != 0: | 465 if ret != 0: |
474 raise errors.MsgException('KillAdbServer: %d' % ret) | 466 raise errors.MsgException('KillAdbServer: %d' % ret) |
475 | 467 |
476 ret = self.StartAdbServer() | 468 ret = self.StartAdbServer() |
477 if ret != 0: | 469 if ret != 0: |
478 raise errors.MsgException('StartAdbServer: %d' % ret) | 470 raise errors.MsgException('StartAdbServer: %d' % ret) |
479 | 471 |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 """ | 1625 """ |
1634 def __init__(self, output): | 1626 def __init__(self, output): |
1635 self._output = output | 1627 self._output = output |
1636 | 1628 |
1637 def write(self, data): | 1629 def write(self, data): |
1638 data = data.replace('\r\r\n', '\n') | 1630 data = data.replace('\r\r\n', '\n') |
1639 self._output.write(data) | 1631 self._output.write(data) |
1640 | 1632 |
1641 def flush(self): | 1633 def flush(self): |
1642 self._output.flush() | 1634 self._output.flush() |
OLD | NEW |