From 1befe4fd62dffee1e9a9d19549d18e8604c726e2 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Mon, 25 Feb 2019 15:22:43 -0800 Subject: simpleperf: make app api available for profileable apps. Add api-prepare cmd to prepare recording via app api. Add api-collect cmd to collect recording data generated by app api. The recording data is compressed into a zip file. The two added cmds support both debuggable apps and profileable apps. Move api_app_profiler.py to api_profiler.py. And use the two added cmds in it. Also improve app_api code: 1. Fix finding simpleperf. 2. Use time based output filenames. Bug: 123717243 Test: test manually, will add run python tests later. Change-Id: I88c20578d01a84bc20ea72276f2cab0f3c4d9109 --- simpleperf/environment.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'simpleperf/environment.cpp') diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp index e82162b5..3591626e 100644 --- a/simpleperf/environment.cpp +++ b/simpleperf/environment.cpp @@ -623,6 +623,10 @@ std::set WaitForAppProcesses(const std::string& package_name) { } } +bool IsAppDebuggable(const std::string& package_name) { + return Workload::RunCmd({"run-as", package_name, "echo", ">/dev/null", "2>/dev/null"}, false); +} + namespace { class InAppRunner { @@ -767,7 +771,7 @@ class RunAs : public InAppRunner { bool RunAs::Prepare() { // Test if run-as can access the package. - if (!Workload::RunCmd({"run-as", package_name_, "echo", ">/dev/null", "2>/dev/null"}, false)) { + if (!IsAppDebuggable(package_name_)) { return false; } // run-as can't run /data/local/tmp/simpleperf directly. So copy simpleperf binary if needed. -- cgit v1.2.3