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

Commit 8b93675d authored by Kweku Adams's avatar Kweku Adams
Browse files

Clean up some dump code.

Move JobServiceContext dump inside the class so it can be modified more
directly. Also make the JobConcurrencyManager dump a little cleaner.

Bug: 141645789
Bug: 171305774
Test: visually inspect dump
Change-Id: I4f699e8b17da329251e1f53e44bf9fac978b3510
parent d014bb74
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -741,17 +741,26 @@ class JobConcurrencyManager {

        pw.increaseIndent();
        try {
            pw.print("Configuration:");
            pw.println("Configuration:");
            pw.increaseIndent();
            pw.print(KEY_SCREEN_OFF_ADJUSTMENT_DELAY_MS, mScreenOffAdjustmentDelayMs).println();
            pw.println();
            CONFIG_LIMITS_SCREEN_ON.normal.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_ON.moderate.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_ON.low.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_ON.critical.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_OFF.normal.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_OFF.moderate.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_OFF.low.dump(pw);
            pw.println();
            CONFIG_LIMITS_SCREEN_OFF.critical.dump(pw);
            pw.println();
            pw.decreaseIndent();

            pw.print("Screen state: current ");
@@ -770,18 +779,17 @@ class JobConcurrencyManager {

            pw.println();

            pw.println("Current max jobs:");
            pw.println("  ");
            pw.print("Current work counts: ");
            pw.println(mWorkCountTracker);

            pw.println();

            pw.print("mLastMemoryTrimLevel: ");
            pw.print(mLastMemoryTrimLevel);
            pw.println(mLastMemoryTrimLevel);
            pw.println();

            pw.print("User Grace Period: ");
            pw.print(mGracePeriodObserver.mGracePeriodExpiration);
            pw.println(mGracePeriodObserver.mGracePeriodExpiration);
            pw.println();

            mStatLogger.dump(pw);
+12 −25
Original line number Diff line number Diff line
@@ -3040,7 +3040,6 @@ public class JobSchedulerService extends com.android.server.SystemService
            pw.println();

            for (int i = mJobRestrictions.size() - 1; i >= 0; i--) {
                pw.print("    ");
                mJobRestrictions.get(i).dumpConstants(pw);
                pw.println();
            }
@@ -3067,7 +3066,6 @@ public class JobSchedulerService extends com.android.server.SystemService

                    job.dump(pw, "    ", true, nowElapsed);


                    pw.print("    Restricted due to:");
                    final boolean isRestricted = checkIfRestricted(job) != null;
                    if (isRestricted) {
@@ -3161,39 +3159,28 @@ public class JobSchedulerService extends com.android.server.SystemService
            }
            pw.println();
            pw.println("Active jobs:");
            pw.increaseIndent();
            for (int i=0; i<mActiveServices.size(); i++) {
                JobServiceContext jsc = mActiveServices.get(i);
                pw.print("Slot #"); pw.print(i); pw.print(": ");
                jsc.dumpLocked(pw, nowElapsed);

                final JobStatus job = jsc.getRunningJobLocked();
                if (job == null) {
                    if (jsc.mStoppedReason != null) {
                        pw.print("inactive since ");
                        TimeUtils.formatDuration(jsc.mStoppedTime, nowElapsed, pw);
                        pw.print(", stopped because: ");
                        pw.println(jsc.mStoppedReason);
                    } else {
                        pw.println("inactive");
                    }
                    continue;
                } else {
                    pw.println(job.toShortString());
                    pw.print("    Running for: ");
                    TimeUtils.formatDuration(nowElapsed - jsc.getExecutionStartTimeElapsed(), pw);
                    pw.print(", timeout at: ");
                    TimeUtils.formatDuration(jsc.getTimeoutElapsed() - nowElapsed, pw);
                    pw.println();
                if (job != null) {
                    pw.increaseIndent();
                    job.dump(pw, "  ", false, nowElapsed);
                    int priority = evaluateJobPriorityLocked(job);
                    pw.print("Evaluated priority: ");
                    pw.println(JobInfo.getPriorityString(priority));
                    pw.println(JobInfo.getPriorityString(job.lastEvaluatedPriority));

                    pw.print("Active at ");
                    TimeUtils.formatDuration(job.madeActive - nowUptime, pw);
                    pw.print(", pending for ");
                    TimeUtils.formatDuration(job.madeActive - job.madePending, pw);
                    pw.println();
                    pw.decreaseIndent();
                }
            }
            pw.decreaseIndent();
            if (filterUid == -1) {
                pw.println();
                pw.print("mReadyToRock="); pw.println(mReadyToRock);
+24 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.WorkSource;
import android.util.EventLog;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.TimeUtils;

@@ -901,8 +902,30 @@ public final class JobServiceContext implements ServiceConnection {
        mTimeoutElapsed = sElapsedRealtimeClock.millis() + timeoutMillis;
    }


    private void removeOpTimeOutLocked() {
        mCallbackHandler.removeMessages(MSG_TIMEOUT);
    }

    void dumpLocked(IndentingPrintWriter pw, final long nowElapsed) {
        if (mRunningJob == null) {
            if (mStoppedReason != null) {
                pw.print("inactive since ");
                TimeUtils.formatDuration(mStoppedTime, nowElapsed, pw);
                pw.print(", stopped because: ");
                pw.println(mStoppedReason);
            } else {
                pw.println("inactive");
            }
        } else {
            pw.println(mRunningJob.toShortString());

            pw.increaseIndent();
            pw.print("Running for: ");
            TimeUtils.formatDuration(nowElapsed - mExecutionStartTimeElapsed, pw);
            pw.print(", timeout at: ");
            TimeUtils.formatDuration(mTimeoutElapsed - nowElapsed, pw);
            pw.println();
            pw.decreaseIndent();
        }
    }
}