From c60e3f540fcdc8610df96d5f6267c1eec2fddd18 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Thu, 28 Nov 2013 06:35:32 +0000 Subject: [PATCH] Android: makes "RestartAdbdOnDevice" more robust. Some bots fail on the command that kills adbd on the device, even though the device should be online and available. BUG=322132 Review URL: https://codereview.chromium.org/91563002 git-svn-id: http://src.chromium.org/svn/trunk/src/build@237708 4ff67af0-8c30-449e-8e8b-ad334ec8d88c --- android/pylib/android_commands.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/android/pylib/android_commands.py b/android/pylib/android_commands.py index 6f9b99cc2..f3feb2a50 100644 --- a/android/pylib/android_commands.py +++ b/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."""