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 9f538e1b0efd9f51ffaa4c1345febe8149edccc6..948046da854a5cc3b103f08b27b78f9a66ff3613 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(): |
@@ -382,6 +393,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) |
perezju
2015/03/30 16:01:16
wouldn't RunShellCommand(_RESTART_ADBD_SCRIPT, ...
jbudorick
2015/03/30 16:42:14
Not quite (which is probably what I tried before t
|
+ self.adb.WaitForDevice() |
+ |
REBOOT_DEFAULT_TIMEOUT = 10 * _DEFAULT_TIMEOUT |
REBOOT_DEFAULT_RETRIES = _DEFAULT_RETRIES |
@@ -512,7 +530,7 @@ class DeviceUtils(object): |
return exc.output |
if not isinstance(cmd, basestring): |
- cmd = ' '.join(cmd_helper.SingleQuote(s) for s in cmd) |
+ cmd = ' '.join(cmd_helper.SingleQuote(s) for s in cmd if s) |
perezju
2015/03/30 16:01:16
Not sure if we want to do this. A client may have
jbudorick
2015/03/30 16:42:14
I was trying to think of cases where a client woul
|
if env: |
env = ' '.join(env_quote(k, v) for k, v in env.iteritems()) |
cmd = '%s %s' % (env, cmd) |