diff options
Diffstat (limited to 'simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java')
-rw-r--r-- | simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java b/simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java index cb0eac3d..f1e2b202 100644 --- a/simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java +++ b/simpleperf/app_api/java/com/android/simpleperf/ProfileSession.java @@ -16,9 +16,6 @@ package com.android.simpleperf; -import android.os.Build; -import android.system.OsConstants; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -56,7 +53,6 @@ import java.util.stream.Collectors; * </p> */ public class ProfileSession { - private static final String SIMPLEPERF_PATH_IN_IMAGE = "/system/bin/simpleperf"; enum State { NOT_YET_STARTED, @@ -67,10 +63,8 @@ public class ProfileSession { private State state = State.NOT_YET_STARTED; private String appDataDir; - private String simpleperfPath; private String simpleperfDataDir; private Process simpleperfProcess; - private boolean traceOffcpu = false; /** * @param appDataDir the same as android.content.Context.getDataDir(). @@ -121,12 +115,7 @@ public class ProfileSession { if (state != State.NOT_YET_STARTED) { throw new AssertionError("startRecording: session in wrong state " + state); } - for (String arg : args) { - if (arg.equals("--trace-offcpu")) { - traceOffcpu = true; - } - } - simpleperfPath = findSimpleperf(); + String simpleperfPath = findSimpleperf(); checkIfPerfEnabled(); createSimpleperfDataDir(); createSimpleperfProcess(simpleperfPath, args); @@ -140,10 +129,6 @@ public class ProfileSession { if (state != State.STARTED) { throw new AssertionError("pauseRecording: session in wrong state " + state); } - if (traceOffcpu) { - throw new AssertionError( - "--trace-offcpu option doesn't work well with pause/resume recording"); - } sendCmd("pause"); state = State.PAUSED; } @@ -166,14 +151,7 @@ public class ProfileSession { if (state != State.STARTED && state != State.PAUSED) { throw new AssertionError("stopRecording: session in wrong state " + state); } - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P + 1 && - simpleperfPath.equals(SIMPLEPERF_PATH_IN_IMAGE)) { - // The simpleperf shipped on Android Q contains a bug, which may make it abort if - // calling simpleperfProcess.destroy(). - destroySimpleperfProcessWithoutClosingStdin(); - } else { - simpleperfProcess.destroy(); - } + simpleperfProcess.destroy(); try { int exitCode = simpleperfProcess.waitFor(); if (exitCode != 0) { @@ -185,22 +163,6 @@ public class ProfileSession { state = State.STOPPED; } - private void destroySimpleperfProcessWithoutClosingStdin() { - // In format "Process[pid=? ..." - String s = simpleperfProcess.toString(); - final String prefix = "Process[pid="; - if (s.startsWith(prefix)) { - int startIndex = prefix.length(); - int endIndex = s.indexOf(','); - if (endIndex > startIndex) { - int pid = Integer.parseInt(s.substring(startIndex, endIndex).trim()); - android.os.Process.sendSignal(pid, OsConstants.SIGTERM); - return; - } - } - simpleperfProcess.destroy(); - } - private String readInputStream(InputStream in) { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String result = reader.lines().collect(Collectors.joining("\n")); @@ -218,7 +180,7 @@ public class ProfileSession { return simpleperfPath; } // 2. Try /system/bin/simpleperf, which is available on Android >= Q. - simpleperfPath = SIMPLEPERF_PATH_IN_IMAGE; + simpleperfPath = "/system/bin/simpleperf"; if (isExecutableFile(simpleperfPath)) { return simpleperfPath; } |