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

Commit d464bcf5 authored by Marcin Oczeretko's avatar Marcin Oczeretko
Browse files

Add collection start time to LooperStats dumpsys output

Test: called adb shell cmd looper_stats dump
Bug: 113651685
Change-Id: Iccd224b1b50a9ba31a9de254f251fac26fee2171
parent 37c3c958
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)