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

Commit 2a7854ad authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add collection start time to LooperStats dumpsys output"

parents 03eb4c32 d464bcf5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public class LooperStats implements Looper.Observer {
    private final int mEntriesSizeCap;
    private int mSamplingInterval;
    private CachedDeviceState.Readonly mDeviceState;
    private long mStartTime = System.currentTimeMillis();

    public LooperStats(int samplingInterval, int entriesSizeCap) {
        this.mSamplingInterval = samplingInterval;
@@ -144,6 +145,11 @@ public class LooperStats implements Looper.Observer {
        return exportedEntries;
    }

    /** Returns a timestamp indicating when the statistics were last reset. */
    public long getStartTimeMillis() {
        return mStartTime;
    }

    private void maybeAddSpecialEntry(List<ExportedEntry> exportedEntries, Entry specialEntry) {
        synchronized (specialEntry) {
            if (specialEntry.messageCount > 0 || specialEntry.exceptionCount > 0) {
@@ -163,6 +169,7 @@ public class LooperStats implements Looper.Observer {
        synchronized (mOverflowEntry) {
            mOverflowEntry.reset();
        }
        mStartTime = System.currentTimeMillis();
    }

    public void setSamplingInterval(int samplingInterval) {
+4 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.ShellCommand;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.format.DateFormat;
import android.util.KeyValueListParser;
import android.util.Slog;

@@ -91,7 +92,9 @@ public class LooperStatsService extends Binder {
    @Override
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
        List<LooperStats.ExportedEntry> entries = mStats.getEntries();
        pw.print("Start time: ");
        pw.println(DateFormat.format("yyyy-MM-dd HH:mm:ss", mStats.getStartTimeMillis()));
        final List<LooperStats.ExportedEntry> entries = mStats.getEntries();
        entries.sort(Comparator
                .comparing((LooperStats.ExportedEntry entry) -> entry.workSourceUid)
                .thenComparing(entry -> entry.threadName)