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

Commit a17c0f5e authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

More procstats work: separate global proc account, more dumping.

We now keep track of the time actually process run independently
of the time packages run in process, so we can give an accurate
summary of how long each physical process runs.

New command line options can be supplied to restrict printing to
a specific package, dump in a new csv format, control what is
printed in the csv format, and print a checkin report.

Add toString methods to ArrayMap and ArraySet.

Change-Id: I47b8f68472592ecc0088c5286d3564aa615f4e0a
parent fb5a41a3
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -550,6 +550,43 @@ public final class ArrayMap<K, V> implements Map<K, V> {
        return result;
    }

    /**
     * {@inheritDoc}
     *
     * <p>This implementation composes a string by iterating over its mappings. If
     * this map contains itself as a key or a value, the string "(this Map)"
     * will appear in its place.
     */
    @Override
    public String toString() {
        if (isEmpty()) {
            return "{}";
        }

        StringBuilder buffer = new StringBuilder(mSize * 28);
        buffer.append('{');
        for (int i=0; i<mSize; i++) {
            if (i > 0) {
                buffer.append(", ");
            }
            Object key = keyAt(i);
            if (key != this) {
                buffer.append(key);
            } else {
                buffer.append("(this Map)");
            }
            buffer.append('=');
            Object value = valueAt(i);
            if (value != this) {
                buffer.append(value);
            } else {
                buffer.append("(this Map)");
            }
        }
        buffer.append('}');
        return buffer.toString();
    }

    // ------------------------------------------------------------------------
    // Interop with traditional Java containers.  Not as efficient as using
    // specialized collection APIs.
+30 −0
Original line number Diff line number Diff line
@@ -493,6 +493,36 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
        return result;
    }

    /**
     * {@inheritDoc}
     *
     * <p>This implementation composes a string by iterating over its values. If
     * this set contains itself as a value, the string "(this Set)"
     * will appear in its place.
     */
    @Override
    public String toString() {
        if (isEmpty()) {
            return "{}";
        }

        StringBuilder buffer = new StringBuilder(mSize * 14);
        buffer.append('{');
        for (int i=0; i<mSize; i++) {
            if (i > 0) {
                buffer.append(", ");
            }
            Object value = valueAt(i);
            if (value != this) {
                buffer.append(value);
            } else {
                buffer.append("(this Set)");
            }
        }
        buffer.append('}');
        return buffer.toString();
    }

    // ------------------------------------------------------------------------
    // Interop with traditional Java containers.  Not as efficient as using
    // specialized collection APIs.
+4 −3
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ public final class ActivityManagerService extends ActivityManagerNative
     * Tracking long-term execution of processes to look for abuse and other
     * bad app behavior.
     */
    final ProcessTracker mProcessTracker = new ProcessTracker();
    ProcessTracker mProcessTracker;
    /**
     * The currently running isolated processes.
@@ -1547,6 +1547,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        m.mContext = context;
        m.mFactoryTest = factoryTest;
        m.mIntentFirewall = new IntentFirewall(m.new IntentFirewallInterface());
        m.mProcessTracker = new ProcessTracker(context);
        m.mStackSupervisor = new ActivityStackSupervisor(m, context, thr.mLooper);
@@ -10173,12 +10174,12 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
        String[] newArgs = new String[args.length - opti];
        if (args.length > 2) System.arraycopy(args, opti, newArgs, 0, args.length - opti);
        System.arraycopy(args, opti, newArgs, 0, args.length - opti);
        TaskRecord lastTask = null;
        boolean needSep = false;
        for (int i=activities.size()-1; i>=0; i--) {
            ActivityRecord r = (ActivityRecord)activities.get(i);
            ActivityRecord r = activities.get(i);
            if (needSep) {
                pw.println();
            }
+2 −1
Original line number Diff line number Diff line
@@ -244,7 +244,8 @@ final class ProcessList {
    }

    int adjToTrackedState(int adj) {
        return adj >= FOREGROUND_APP_ADJ ? mAdjToTrackedState[adj] : ProcessTracker.STATE_NOTHING;
        return adj >= FOREGROUND_APP_ADJ
                ? mAdjToTrackedState[adj] : ProcessTracker.STATE_PERSISTENT;
    }

    private void writeFile(String path, String data) {
+4 −4
Original line number Diff line number Diff line
@@ -451,8 +451,8 @@ final class ProcessRecord {
            ProcessList plist) {
        int state = this == TOP_APP ? ProcessTracker.STATE_TOP
                : plist.adjToTrackedState(setAdj);
        for (int ip=pkgList.size()-1; ip>=0; ip--) {
            pkgList.valueAt(ip).setState(state, memFactor, now);
        if (pkgList.size() > 0) {
            pkgList.valueAt(0).setState(state, memFactor, now, pkgList);
        }
    }

@@ -461,8 +461,8 @@ final class ProcessRecord {
     */
    public void resetPackageList() {
        long now = SystemClock.uptimeMillis();
        for (int i=0; i<pkgList.size(); i++) {
            pkgList.valueAt(i).setState(ProcessTracker.STATE_NOTHING, 0, now);
        if (pkgList.size() > 0) {
            pkgList.valueAt(0).setState(ProcessTracker.STATE_NOTHING, 0, now, pkgList);
        }
        pkgList.clear();
        pkgList.put(info.packageName, baseProcessTracker);
Loading