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 e432904ad690af0bf7d3c76faedd476185a0f6ed..6ebef08c3fd0728682d330aa7bac9e150af1d671 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -72,6 +72,17 @@ _CONTROL_CHARGING_COMMANDS = [ |
}, |
] |
+# This must be done in a single shell command. |
+_RESTART_ADBD_SCRIPT = """ |
+ function restart() { |
+ stop adbd |
+ start adbd |
+ } |
+ |
+ restart & |
+""" |
+ |
+ |
@decorators.WithExplicitTimeoutAndRetries( |
_DEFAULT_TIMEOUT, _DEFAULT_RETRIES) |
def GetAVDs(): |
@@ -383,6 +394,13 @@ class DeviceUtils(object): |
if wifi: |
timeout_retry.WaitFor(wifi_enabled) |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
+ def RestartAdbd(self, timeout=None, retries=None): |
+ with device_temp_file.DeviceTempFile(self.adb) as tmp: |
+ self.WriteFile(tmp.name, _RESTART_ADBD_SCRIPT) |
+ self.RunShellCommand(['sh', tmp.name], as_root=True, check_return=True) |
+ self.adb.WaitForDevice() |
+ |
REBOOT_DEFAULT_TIMEOUT = 10 * _DEFAULT_TIMEOUT |
REBOOT_DEFAULT_RETRIES = _DEFAULT_RETRIES |