Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: build/android/devil/android/device_utils.py

Issue 1397663002: DeviceUtils.StartInstrumentation: Shrink command-line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 for line in self.RunShellCommand(cmd, check_return=True): 921 for line in self.RunShellCommand(cmd, check_return=True):
922 if line.startswith('Error:'): 922 if line.startswith('Error:'):
923 raise device_errors.CommandFailedError(line, str(self)) 923 raise device_errors.CommandFailedError(line, str(self))
924 924
925 @decorators.WithTimeoutAndRetriesFromInstance() 925 @decorators.WithTimeoutAndRetriesFromInstance()
926 def StartInstrumentation(self, component, finish=True, raw=False, 926 def StartInstrumentation(self, component, finish=True, raw=False,
927 extras=None, timeout=None, retries=None): 927 extras=None, timeout=None, retries=None):
928 if extras is None: 928 if extras is None:
929 extras = {} 929 extras = {}
930 930
931 cmd = ['am', 'instrument'] 931 # Store the package name in a shell variable to help the command stay under
932 # the _MAX_ADB_COMMAND_LENGTH limit.
933 package = component.split('/')[0]
934 def shrink(value):
jbudorick 2015/10/08 14:27:28 I don't agree with handling this this way. It lead
agrieve 2015/10/08 15:42:10 RunShellCommand can already be passed env variable
jbudorick 2015/10/08 15:51:09 Yeah, I didn't think env would work here.
agrieve 2015/10/08 20:03:33 Extracted it into a helper. Wasn't actually able t
935 parts = (x and cmd_helper.SingleQuote(x) for x in value.split(package))
936 return '$p'.join(parts)
937
938 cmd = 'p=%s;am instrument' % package
932 if finish: 939 if finish:
933 cmd.append('-w') 940 cmd += ' -w'
934 if raw: 941 if raw:
935 cmd.append('-r') 942 cmd += ' -r'
943
936 for k, v in extras.iteritems(): 944 for k, v in extras.iteritems():
937 cmd.extend(['-e', str(k), str(v)]) 945 cmd += ' -e %s %s' % (shrink(str(k)), shrink(str(v)))
938 cmd.append(component) 946
947 cmd += ' %s' % shrink(component)
939 return self.RunShellCommand(cmd, check_return=True, large_output=True) 948 return self.RunShellCommand(cmd, check_return=True, large_output=True)
940 949
941 @decorators.WithTimeoutAndRetriesFromInstance() 950 @decorators.WithTimeoutAndRetriesFromInstance()
942 def BroadcastIntent(self, intent_obj, timeout=None, retries=None): 951 def BroadcastIntent(self, intent_obj, timeout=None, retries=None):
943 """Send a broadcast intent. 952 """Send a broadcast intent.
944 953
945 Args: 954 Args:
946 intent: An Intent to broadcast. 955 intent: An Intent to broadcast.
947 timeout: timeout in seconds 956 timeout: timeout in seconds
948 retries: number of retries 957 retries: number of retries
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions 2065 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions
2057 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): 2066 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions):
2058 permissions.append('android.permission.READ_EXTERNAL_STORAGE') 2067 permissions.append('android.permission.READ_EXTERNAL_STORAGE')
2059 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) 2068 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions)
2060 if cmd: 2069 if cmd:
2061 output = self.RunShellCommand(cmd) 2070 output = self.RunShellCommand(cmd)
2062 if output: 2071 if output:
2063 logging.warning('Possible problem when granting permissions. Blacklist ' 2072 logging.warning('Possible problem when granting permissions. Blacklist '
2064 'may need to be updated.') 2073 'may need to be updated.')
2065 logging.warning(output) 2074 logging.warning(output)
OLDNEW
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698