Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: build/android/pylib/android_commands.py

Issue 91563002: Android: makes "RestartAdbdOnDevice" more robust. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 reboots_left -= 1 458 reboots_left -= 1
459 459
460 def MakeSystemFolderWritable(self): 460 def MakeSystemFolderWritable(self):
461 """Remounts the /system folder rw.""" 461 """Remounts the /system folder rw."""
462 out = self._adb.SendCommand('remount') 462 out = self._adb.SendCommand('remount')
463 if out.strip() != 'remount succeeded': 463 if out.strip() != 'remount succeeded':
464 raise errors.MsgException('Remount failed: %s' % out) 464 raise errors.MsgException('Remount failed: %s' % out)
465 465
466 def RestartAdbdOnDevice(self): 466 def RestartAdbdOnDevice(self):
467 logging.info('Killing adbd on the device...') 467 logging.info('Killing adbd on the device...')
468 adb_pids = self.KillAll('adbd', signal=signal.SIGTERM, with_su=True) 468 adb_pids = self.ExtractPid('adbd')
469 assert adb_pids, 'Unable to obtain adbd pid' 469 if not adb_pids:
470 logging.info('Waiting for device to settle...') 470 raise errors.MsgException('Unable to obtain adbd pid')
471 self._adb.SendCommand('wait-for-device') 471 try:
472 self.KillAll('adbd', signal=signal.SIGTERM, with_su=True)
473 logging.info('Waiting for device to settle...')
474 self._adb.SendCommand('wait-for-device')
475 new_adb_pids = self.ExtractPid('adbd')
476 if new_adb_pids == adb_pids:
477 logging.error('adbd on the device may not have been restarted.')
478 except Exception as e:
479 logging.error('Exception when trying to kill adbd on the device [%s]', e)
472 480
473 def RestartAdbServer(self): 481 def RestartAdbServer(self):
474 """Restart the adb server.""" 482 """Restart the adb server."""
475 ret = self.KillAdbServer() 483 ret = self.KillAdbServer()
476 if ret != 0: 484 if ret != 0:
477 raise errors.MsgException('KillAdbServer: %d' % ret) 485 raise errors.MsgException('KillAdbServer: %d' % ret)
478 486
479 ret = self.StartAdbServer() 487 ret = self.StartAdbServer()
480 if ret != 0: 488 if ret != 0:
481 raise errors.MsgException('StartAdbServer: %d' % ret) 489 raise errors.MsgException('StartAdbServer: %d' % ret)
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 """ 1711 """
1704 def __init__(self, output): 1712 def __init__(self, output):
1705 self._output = output 1713 self._output = output
1706 1714
1707 def write(self, data): 1715 def write(self, data):
1708 data = data.replace('\r\r\n', '\n') 1716 data = data.replace('\r\r\n', '\n')
1709 self._output.write(data) 1717 self._output.write(data)
1710 1718
1711 def flush(self): 1719 def flush(self):
1712 self._output.flush() 1720 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698