Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b51fd80f authored by Mohamad Mahmoud's avatar Mohamad Mahmoud
Browse files

Limit the number of dumped processes in the CPU usage section in dropbox files to 10

Test: tested on a local device
Bug: 261435148
Change-Id: I28cc04fec464dd6515311508459b1e1305aefed8
parent 90e81227
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -841,7 +841,19 @@ public class ProcessCpuTracker {
        return sw.toString();
    }

    final public String printCurrentState(long now) {
    /**
     * Returns current CPU state with all the processes as a String, sorted by load
     * in descending order.
     */
    public final String printCurrentState(long now) {
        return printCurrentState(now, Integer.MAX_VALUE);
    }

    /**
     * Returns current CPU state with the top {@code maxProcessesToDump} highest load
     * processes as a String, sorted by load in descending order.
     */
    public final String printCurrentState(long now, int maxProcessesToDump) {
        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

        buildWorkingProcs();
@@ -883,8 +895,8 @@ public class ProcessCpuTracker {
        if (DEBUG) Slog.i(TAG, "totalTime " + totalTime + " over sample time "
                + (mCurrentSampleTime-mLastSampleTime));

        int N = mWorkingProcs.size();
        for (int i=0; i<N; i++) {
        int dumpedProcessCount = Math.min(maxProcessesToDump, mWorkingProcs.size());
        for (int i = 0; i < dumpedProcessCount; i++) {
            Stats st = mWorkingProcs.get(i);
            printProcessCPU(pw, st.added ? " +" : (st.removed ? " -": "  "),
                    st.pid, st.name, (int)st.rel_uptime,
+2 −1
Original line number Diff line number Diff line
@@ -2310,7 +2310,8 @@ public class AppProfiler {

    void printCurrentCpuState(StringBuilder report, long time) {
        synchronized (mProcessCpuTracker) {
            report.append(mProcessCpuTracker.printCurrentState(time));
            // Only print the first 10 processes
            report.append(mProcessCpuTracker.printCurrentState(time, /* maxProcesses= */10));
        }
    }