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 # pylint: disable-all | 9 # pylint: disable-all |
| 10 | 10 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 self.Reboot(full_reboot=(reboots_left == 1)) | 537 self.Reboot(full_reboot=(reboots_left == 1)) |
| 538 reboots_left -= 1 | 538 reboots_left -= 1 |
| 539 | 539 |
| 540 def MakeSystemFolderWritable(self): | 540 def MakeSystemFolderWritable(self): |
| 541 """Remounts the /system folder rw.""" | 541 """Remounts the /system folder rw.""" |
| 542 out = self._adb.SendCommand('remount') | 542 out = self._adb.SendCommand('remount') |
| 543 if out.strip() != 'remount succeeded': | 543 if out.strip() != 'remount succeeded': |
| 544 raise errors.MsgException('Remount failed: %s' % out) | 544 raise errors.MsgException('Remount failed: %s' % out) |
| 545 | 545 |
| 546 def RestartAdbdOnDevice(self): | 546 def RestartAdbdOnDevice(self): |
| 547 logging.info('Killing adbd on the device...') | 547 logging.info('Restarting adbd on the device...') |
| 548 adb_pids = self.ExtractPid('adbd') | 548 with DeviceTempFile(self, suffix=".sh") as temp_script_file: |
|
bulach
2014/06/02 11:47:50
nit: s/"/'/
| |
| 549 if not adb_pids: | 549 host_script_path = os.path.join(constants.DIR_SOURCE_ROOT, |
| 550 raise errors.MsgException('Unable to obtain adbd pid') | 550 'build', |
| 551 try: | 551 'android', |
| 552 self.KillAll('adbd', signum=signal.SIGTERM, with_su=True) | 552 'pylib', |
| 553 logging.info('Waiting for device to settle...') | 553 'restart_adbd.sh') |
| 554 self._adb.Push(host_script_path, temp_script_file.name) | |
| 555 self.RunShellCommand('. %s' % temp_script_file.name) | |
| 554 self._adb.SendCommand('wait-for-device') | 556 self._adb.SendCommand('wait-for-device') |
| 555 new_adb_pids = self.ExtractPid('adbd') | |
| 556 if new_adb_pids == adb_pids: | |
| 557 logging.warning('adbd on the device may not have been restarted.') | |
| 558 except Exception as e: | |
| 559 logging.error('Exception when trying to kill adbd on the device [%s]', e) | |
| 560 | 557 |
| 561 def RestartAdbServer(self): | 558 def RestartAdbServer(self): |
| 562 """Restart the adb server.""" | 559 """Restart the adb server.""" |
| 563 ret = self.KillAdbServer() | 560 ret = self.KillAdbServer() |
| 564 if ret != 0: | 561 if ret != 0: |
| 565 raise errors.MsgException('KillAdbServer: %d' % ret) | 562 raise errors.MsgException('KillAdbServer: %d' % ret) |
| 566 | 563 |
| 567 ret = self.StartAdbServer() | 564 ret = self.StartAdbServer() |
| 568 if ret != 0: | 565 if ret != 0: |
| 569 raise errors.MsgException('StartAdbServer: %d' % ret) | 566 raise errors.MsgException('StartAdbServer: %d' % ret) |
| (...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1980 """ | 1977 """ |
| 1981 def __init__(self, output): | 1978 def __init__(self, output): |
| 1982 self._output = output | 1979 self._output = output |
| 1983 | 1980 |
| 1984 def write(self, data): | 1981 def write(self, data): |
| 1985 data = data.replace('\r\r\n', '\n') | 1982 data = data.replace('\r\r\n', '\n') |
| 1986 self._output.write(data) | 1983 self._output.write(data) |
| 1987 | 1984 |
| 1988 def flush(self): | 1985 def flush(self): |
| 1989 self._output.flush() | 1986 self._output.flush() |
| OLD | NEW |