Index: build/android/pylib/android_commands.py |
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py |
index 6f9b99cc2405f9eab6760fe5d71d4fa5c5a9196c..f3feb2a50e96a8a71d7ae00557115b936c6c0395 100644 |
--- a/build/android/pylib/android_commands.py |
+++ b/build/android/pylib/android_commands.py |
@@ -465,10 +465,18 @@ class AndroidCommands(object): |
def RestartAdbdOnDevice(self): |
logging.info('Killing adbd on the device...') |
- adb_pids = self.KillAll('adbd', signal=signal.SIGTERM, with_su=True) |
- assert adb_pids, 'Unable to obtain adbd pid' |
- logging.info('Waiting for device to settle...') |
- self._adb.SendCommand('wait-for-device') |
+ adb_pids = self.ExtractPid('adbd') |
+ if not adb_pids: |
+ raise errors.MsgException('Unable to obtain adbd pid') |
+ try: |
+ self.KillAll('adbd', signal=signal.SIGTERM, with_su=True) |
+ logging.info('Waiting for device to settle...') |
+ self._adb.SendCommand('wait-for-device') |
+ new_adb_pids = self.ExtractPid('adbd') |
+ if new_adb_pids == adb_pids: |
+ logging.error('adbd on the device may not have been restarted.') |
+ except Exception as e: |
+ logging.error('Exception when trying to kill adbd on the device [%s]', e) |
def RestartAdbServer(self): |
"""Restart the adb server.""" |