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 272e613b6817f915a2cee039caf6ff53de13bea7..ae876dfe39f92002dc9dd5aa35677d5ce1e71cfd 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -427,6 +427,15 @@ class DeviceUtils(object): |
# using double quotes here to allow interpolation of shell variables |
return '%s=%s' % (key, cmd_helper.DoubleQuote(value)) |
+ def do_run(cmd): |
+ try: |
+ return self.adb.Shell(cmd) |
+ except device_errors.AdbCommandFailedError as exc: |
+ if check_return: |
+ raise |
+ else: |
+ return exc.output |
+ |
if not isinstance(cmd, basestring): |
cmd = ' '.join(cmd_helper.SingleQuote(s) for s in cmd) |
if env: |
@@ -440,13 +449,14 @@ class DeviceUtils(object): |
if timeout is None: |
timeout = self._default_timeout |
- try: |
- output = self.adb.Shell(cmd) |
- except device_errors.AdbCommandFailedError as e: |
- if check_return: |
- raise |
- else: |
- output = e.output |
+ if len(cmd) < 512: |
jbudorick
2014/11/25 17:05:26
We should de-magic 512. "MAX_ADB_COMMAND_LENGTH" o
|
+ output = do_run(cmd) |
+ else: |
+ with device_temp_file.DeviceTempFile(self, suffix='.sh') as script: |
+ # |as_root| must be False, and |force_push| must be True, |
+ # otherwise WriteFile may introduce infinite recursion |
jbudorick
2014/11/25 17:05:26
This worries me. It's the same kind of cyclical de
|
+ self.WriteFile(script.name, cmd, as_root=False, force_push=True) |
perezju
2014/11/25 16:25:33
look, our first non-artificial use of force_push!
|
+ output = do_run('sh %s' % script.name_quoted) |
output = output.splitlines() |
if single_line: |