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

Commit f6ff0f88 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge changes Icdb40ee3,I4c239844

* changes:
  Knobs for connectivity experiments.
  Mechanical refactoring to improve job dumping.
parents d0f119f8 ac2e8efa
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -57,26 +57,46 @@ public class IndentingPrintWriter extends PrintWriter {
        mWrapLength = wrapLength;
    }

    public void increaseIndent() {
    public IndentingPrintWriter setIndent(String indent) {
        mIndentBuilder.setLength(0);
        mIndentBuilder.append(indent);
        mCurrentIndent = null;
        return this;
    }

    public IndentingPrintWriter setIndent(int indent) {
        mIndentBuilder.setLength(0);
        for (int i = 0; i < indent; i++) {
            increaseIndent();
        }
        return this;
    }

    public IndentingPrintWriter increaseIndent() {
        mIndentBuilder.append(mSingleIndent);
        mCurrentIndent = null;
        return this;
    }

    public void decreaseIndent() {
    public IndentingPrintWriter decreaseIndent() {
        mIndentBuilder.delete(0, mSingleIndent.length());
        mCurrentIndent = null;
        return this;
    }

    public void printPair(String key, Object value) {
    public IndentingPrintWriter printPair(String key, Object value) {
        print(key + "=" + String.valueOf(value) + " ");
        return this;
    }

    public void printPair(String key, Object[] value) {
    public IndentingPrintWriter printPair(String key, Object[] value) {
        print(key + "=" + Arrays.toString(value) + " ");
        return this;
    }

    public void printHexPair(String key, int value) {
    public IndentingPrintWriter printHexPair(String key, int value) {
        print(key + "=0x" + Integer.toHexString(value) + " ");
        return this;
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -201,6 +201,12 @@ message ConstantsProto {
    // be indices into this array, rather than the raw constants used by
    // AppIdleHistory.
    repeated int32 standby_beats = 20;
    // The fraction of a job's running window that must pass before we
    // consider running it when the network is congested.
    optional double conn_congestion_delay_frac = 21;
    // The fraction of a prefetch job's running window that must pass before
    // we consider matching it against a metered network.
    optional double conn_prefetch_relax_frac = 22;
}

message StateControllerProto {
+15 −19
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IAppOpsCallback;
import com.android.internal.app.IAppOpsService;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.server.ForceAppStandbyTrackerProto.ExemptedPackage;
import com.android.server.ForceAppStandbyTrackerProto.RunAnyInBackgroundRestrictedPackages;
@@ -1182,72 +1183,67 @@ public class AppStateTracker {
        }
    }

    public void dump(PrintWriter pw, String indent) {
    @Deprecated
    public void dump(PrintWriter pw, String prefix) {
        dump(new IndentingPrintWriter(pw, "  ").setIndent(prefix));
    }

    public void dump(IndentingPrintWriter pw) {
        synchronized (mLock) {
            pw.print(indent);
            pw.println("Forced App Standby Feature enabled: " + mForcedAppStandbyEnabled);

            pw.print(indent);
            pw.print("Force all apps standby: ");
            pw.println(isForceAllAppsStandbyEnabled());

            pw.print(indent);
            pw.print("Small Battery Device: ");
            pw.println(isSmallBatteryDevice());

            pw.print(indent);
            pw.print("Force all apps standby for small battery device: ");
            pw.println(mForceAllAppStandbyForSmallBattery);

            pw.print(indent);
            pw.print("Plugged In: ");
            pw.println(mIsPluggedIn);

            pw.print(indent);
            pw.print("Active uids: ");
            dumpUids(pw, mActiveUids);

            pw.print(indent);
            pw.print("Foreground uids: ");
            dumpUids(pw, mForegroundUids);

            pw.print(indent);
            pw.print("Whitelist appids: ");
            pw.println(Arrays.toString(mPowerWhitelistedAllAppIds));

            pw.print(indent);
            pw.print("Temp whitelist appids: ");
            pw.println(Arrays.toString(mTempWhitelistedAppIds));

            pw.print(indent);
            pw.println("Exempted packages:");
            pw.increaseIndent();
            for (int i = 0; i < mExemptedPackages.size(); i++) {
                pw.print(indent);
                pw.print("User ");
                pw.print(mExemptedPackages.keyAt(i));
                pw.println();

                pw.increaseIndent();
                for (int j = 0; j < mExemptedPackages.sizeAt(i); j++) {
                    pw.print(indent);
                    pw.print("    ");
                    pw.print(mExemptedPackages.valueAt(i, j));
                    pw.println();
                }
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
            pw.println();

            pw.print(indent);
            pw.println("Restricted packages:");
            pw.increaseIndent();
            for (Pair<Integer, String> uidAndPackage : mRunAnyRestrictedPackages) {
                pw.print(indent);
                pw.print("  ");
                pw.print(UserHandle.formatUid(uidAndPackage.first));
                pw.print(" ");
                pw.print(uidAndPackage.second);
                pw.println();
            }
            pw.decreaseIndent();

            mStatLogger.dump(pw, indent);
            mStatLogger.dump(pw);
        }
    }

+8 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.StatLoggerProto.Event;

import java.io.PrintWriter;
@@ -78,19 +79,23 @@ public class StatLogger {
        }
    }

    @Deprecated
    public void dump(PrintWriter pw, String prefix) {
        dump(new IndentingPrintWriter(pw, "  ").setIndent(prefix));
    }

    public void dump(IndentingPrintWriter pw) {
        synchronized (mLock) {
            pw.print(prefix);
            pw.println("Stats:");
            pw.increaseIndent();
            for (int i = 0; i < SIZE; i++) {
                pw.print(prefix);
                pw.print("  ");
                final int count = mCountStats[i];
                final double durationMs = mDurationStats[i] / 1000.0;
                pw.println(String.format("%s: count=%d, total=%.1fms, avg=%.3fms",
                        mLabels[i], count, durationMs,
                        (count == 0 ? 0 : ((double) durationMs) / count)));
            }
            pw.decreaseIndent();
        }
    }

+207 −199

File changed.

Preview size limit exceeded, changes collapsed.

Loading