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 try: | |
464 logging.info('Killing adbd on the device...') | |
465 adb_pids = self.ExtractPid('adbd') | |
466 if adb_pids: | |
467 self.RunShellCommandWithSU('kill %s' % ' '.join(adb_pids)) | |
468 logging.info('Waiting for device to settle...') | |
469 time.sleep(5) | |
470 except Exception as e: | |
craigdh
2013/10/02 17:36:53
Let's not eat the exception here. It's fine if you
bulach
2013/10/03 08:26:13
good point! agreed, moved the try..except up to th
| |
471 logging.error('Exception when killing adbd %s', e) | |
472 | |
462 def RestartAdbServer(self): | 473 def RestartAdbServer(self): |
463 """Restart the adb server.""" | 474 """Restart the adb server.""" |
464 ret = self.KillAdbServer() | 475 ret = self.KillAdbServer() |
465 if ret != 0: | 476 if ret != 0: |
466 raise errors.MsgException('KillAdbServer: %d' % ret) | 477 raise errors.MsgException('KillAdbServer: %d' % ret) |
467 | 478 |
468 ret = self.StartAdbServer() | 479 ret = self.StartAdbServer() |
469 if ret != 0: | 480 if ret != 0: |
470 raise errors.MsgException('StartAdbServer: %d' % ret) | 481 raise errors.MsgException('StartAdbServer: %d' % ret) |
471 | 482 |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1578 """ | 1589 """ |
1579 def __init__(self, output): | 1590 def __init__(self, output): |
1580 self._output = output | 1591 self._output = output |
1581 | 1592 |
1582 def write(self, data): | 1593 def write(self, data): |
1583 data = data.replace('\r\r\n', '\n') | 1594 data = data.replace('\r\r\n', '\n') |
1584 self._output.write(data) | 1595 self._output.write(data) |
1585 | 1596 |
1586 def flush(self): | 1597 def flush(self): |
1587 self._output.flush() | 1598 self._output.flush() |
OLD | NEW |