Index: build/android/pylib/device/device_utils.py |
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py |
index f461b2802529176da22f9017485e3d9e2a5746dc..2389b5191dc3ed639cac4d07e3543eeb45b2681f 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -69,7 +69,20 @@ def RestartServer(): |
Raises: |
CommandFailedError if we fail to kill or restart the server. |
""" |
- pylib.android_commands.AndroidCommands().RestartAdbServer() |
+ def adb_killed(): |
+ status, _ = cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb']) |
+ return status != 0 # pgrep didn't find adb, kill-server succeeded |
+ |
+ def adb_started(): |
+ status, _ = cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb']) |
+ return status == 0 # pgrep found adb, start-server succeeded |
+ |
+ adb_wrapper.AdbWrapper.KillServer() |
+ if not timeout_retry.WaitFor(adb_killed, wait_period=1, max_tries=5): |
+ raise device_errors.CommandFailedError('Failed to kill adb server') |
+ adb_wrapper.AdbWrapper.StartServer() |
+ if not timeout_retry.WaitFor(adb_started, wait_period=1, max_tries=5): |
+ raise device_errors.CommandFailedError('Failed to start adb server') |
class DeviceUtils(object): |