diff options
author | Yabin Cui <yabinc@google.com> | 2017-05-26 11:16:13 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-05-26 11:16:13 -0700 |
commit | cb38f9409733232cad495fba96590aba15fb073b (patch) | |
tree | 168f832007b5b790e8425fb4efc5c4c1fa1822ea /simpleperf | |
parent | 0a0e79662c04a31204eeb9ff27fc0bc7ed048c4b (diff) | |
download | extras-cb38f9409733232cad495fba96590aba15fb073b.tar.gz |
simpleperf: fix app_profiler.py.
The old way doesn't work on non-rooted devices.
Bug: http://b/62028152
Test: run app_profiler.py non non-rooted devices.
Change-Id: I2b528a8ec64675cf62323ef3e58f6cdeb2547240
Diffstat (limited to 'simpleperf')
-rw-r--r-- | simpleperf/scripts/app_profiler.py | 5 | ||||
-rw-r--r-- | simpleperf/scripts/utils.py | 13 |
2 files changed, 11 insertions, 7 deletions
diff --git a/simpleperf/scripts/app_profiler.py b/simpleperf/scripts/app_profiler.py index 05e9534f..ea181f16 100644 --- a/simpleperf/scripts/app_profiler.py +++ b/simpleperf/scripts/app_profiler.py @@ -271,10 +271,7 @@ class AppProfiler(object): def collect_profiling_data(self): - self.run_in_app_dir(['chmod', 'a+rw', 'perf.data']) - self.adb.check_run(['shell', 'cp', - '/data/data/%s/perf.data' % self.config['app_package_name'], '/data/local/tmp']) - self.adb.check_run(['pull', '/data/local/tmp/perf.data', self.config['perf_data_path']]) + self.run_in_app_dir(['cat', 'perf.data', '>' + self.config['perf_data_path']]) config = copy.copy(self.config) config['symfs_dirs'] = [] if self.config['native_lib_dir']: diff --git a/simpleperf/scripts/utils.py b/simpleperf/scripts/utils.py index 01853744..5474676d 100644 --- a/simpleperf/scripts/utils.py +++ b/simpleperf/scripts/utils.py @@ -107,9 +107,16 @@ class AdbHelper(object): def run_and_return_output(self, adb_args): adb_args = [self.adb_path] + adb_args log_debug('run adb cmd: %s' % adb_args) - subproc = subprocess.Popen(adb_args, stdout=subprocess.PIPE) - (stdoutdata, _) = subproc.communicate() - result = (subproc.returncode == 0) + if adb_args[-1][0] == '>': + stdout_file = adb_args[-1][1:] + with open(stdout_file, 'wb') as stdout_fh: + returncode = subprocess.call(adb_args[:-1], stdout=stdout_fh) + stdoutdata = '' + else: + subproc = subprocess.Popen(adb_args, stdout=subprocess.PIPE) + (stdoutdata, _) = subproc.communicate() + returncode = subproc.returncode + result = (returncode == 0) if stdoutdata: stdoutdata = bytes_to_str(stdoutdata) log_debug(stdoutdata) |