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 403f235eabdc6877bc79e225ecdf9a83ee08b693..d52a74b985825da44277b1b8ee1541d57622616b 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -53,7 +53,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): |