Java Code Examples for com.android.internal.util.IndentingPrintWriter#increaseIndent()

The following examples show how to use com.android.internal.util.IndentingPrintWriter#increaseIndent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkDiagnostics.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println(TAG + ":" + mDescription);
    final long unfinished = mCountDownLatch.getCount();
    if (unfinished > 0) {
        // This can't happen unless a caller forgets to call waitForMeasurements()
        // or a measurement isn't implemented to correctly honor the timeout.
        pw.println("WARNING: countdown wait incomplete: "
                + unfinished + " unfinished measurements");
    }

    pw.increaseIndent();

    String prefix;
    for (Measurement m : getMeasurements()) {
        prefix = m.checkSucceeded() ? "." : "F";
        pw.println(prefix + "  " + m.toString());
    }

    pw.decreaseIndent();
}
 
Example 2
Source File: WifiDisplayAdapter.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpLocked(PrintWriter pw) {
    super.dumpLocked(pw);

    pw.println("mCurrentStatus=" + getWifiDisplayStatusLocked());
    pw.println("mFeatureState=" + mFeatureState);
    pw.println("mScanState=" + mScanState);
    pw.println("mActiveDisplayState=" + mActiveDisplayState);
    pw.println("mActiveDisplay=" + mActiveDisplay);
    pw.println("mDisplays=" + Arrays.toString(mDisplays));
    pw.println("mAvailableDisplays=" + Arrays.toString(mAvailableDisplays));
    pw.println("mRememberedDisplays=" + Arrays.toString(mRememberedDisplays));
    pw.println("mPendingStatusChangeBroadcast=" + mPendingStatusChangeBroadcast);
    pw.println("mSupportsProtectedBuffers=" + mSupportsProtectedBuffers);

    // Try to dump the controller state.
    if (mDisplayController == null) {
        pw.println("mDisplayController=null");
    } else {
        pw.println("mDisplayController:");
        final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
        ipw.increaseIndent();
        DumpUtils.dumpAsync(getHandler(), mDisplayController, ipw, "", 200);
    }
}
 
Example 3
Source File: VolumeRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println("VolumeRecord:");
    pw.increaseIndent();
    pw.printPair("type", DebugUtils.valueToString(VolumeInfo.class, "TYPE_", type));
    pw.printPair("fsUuid", fsUuid);
    pw.printPair("partGuid", partGuid);
    pw.println();
    pw.printPair("nickname", nickname);
    pw.printPair("userFlags",
            DebugUtils.flagsToString(VolumeRecord.class, "USER_FLAG_", userFlags));
    pw.println();
    pw.printPair("createdMillis", TimeUtils.formatForLogging(createdMillis));
    pw.printPair("lastTrimMillis", TimeUtils.formatForLogging(lastTrimMillis));
    pw.printPair("lastBenchMillis", TimeUtils.formatForLogging(lastBenchMillis));
    pw.decreaseIndent();
    pw.println();
}
 
Example 4
Source File: StorageVolume.java    From soundboard with GNU General Public License v3.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println("StorageVolume:");
    pw.increaseIndent();
    pw.printPair("mId", mId);
    pw.printPair("mStorageId", mStorageId);
    pw.printPair("mPath", mPath);
    pw.printPair("mDescription", mDescription);
    pw.printPair("mPrimary", mPrimary);
    pw.printPair("mRemovable", mRemovable);
    pw.printPair("mEmulated", mEmulated);
    pw.printPair("mMtpReserveSize", mMtpReserveSize);
    pw.printPair("mAllowMassStorage", mAllowMassStorage);
    pw.printPair("mMaxFileSize", mMaxFileSize);
    pw.printPair("mOwner", mOwner);
    pw.printPair("mFsUuid", mFsUuid);
    pw.printPair("mState", mState);
    pw.decreaseIndent();
}
 
Example 5
Source File: PackageInstallerSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void dumpLocked(IndentingPrintWriter pw) {
    pw.println("Session " + sessionId + ":");
    pw.increaseIndent();

    pw.printPair("userId", userId);
    pw.printPair("mOriginalInstallerUid", mOriginalInstallerUid);
    pw.printPair("mInstallerPackageName", mInstallerPackageName);
    pw.printPair("mInstallerUid", mInstallerUid);
    pw.printPair("createdMillis", createdMillis);
    pw.printPair("stageDir", stageDir);
    pw.printPair("stageCid", stageCid);
    pw.println();

    params.dump(pw);

    pw.printPair("mClientProgress", mClientProgress);
    pw.printPair("mProgress", mProgress);
    pw.printPair("mSealed", mSealed);
    pw.printPair("mPermissionsManuallyAccepted", mPermissionsManuallyAccepted);
    pw.printPair("mRelinquished", mRelinquished);
    pw.printPair("mDestroyed", mDestroyed);
    pw.printPair("mFds", mFds.size());
    pw.printPair("mBridges", mBridges.size());
    pw.printPair("mFinalStatus", mFinalStatus);
    pw.printPair("mFinalMessage", mFinalMessage);
    pw.println();

    pw.decreaseIndent();
}
 
Example 6
Source File: KeepaliveTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println("Packet keepalives:");
    pw.increaseIndent();
    for (NetworkAgentInfo nai : mKeepalives.keySet()) {
        pw.println(nai.name());
        pw.increaseIndent();
        for (int slot : mKeepalives.get(nai).keySet()) {
            KeepaliveInfo ki = mKeepalives.get(nai).get(slot);
            pw.println(slot + ": " + ki.toString());
        }
        pw.decreaseIndent();
    }
    pw.decreaseIndent();
}
 
Example 7
Source File: MultipathPolicyTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    // Do not use in production. Access to class data is only safe on the handler thrad.
    pw.println("MultipathPolicyTracker:");
    pw.increaseIndent();
    for (MultipathTracker t : mMultipathTrackers.values()) {
        pw.println(String.format("Network %s: quota %d, budget %d. Preference: %s",
                t.network, t.getQuota(), t.getMultipathBudget(),
                DebugUtils.flagsToString(ConnectivityManager.class, "MULTIPATH_PREFERENCE_",
                        t.getMultipathPreference())));
    }
    pw.decreaseIndent();
}
 
Example 8
Source File: DeviceStorageMonitorService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dumpImpl(FileDescriptor fd, PrintWriter _pw, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(_pw, "  ");
    if (args == null || args.length == 0 || "-a".equals(args[0])) {
        pw.println("Known volumes:");
        pw.increaseIndent();
        for (int i = 0; i < mStates.size(); i++) {
            final UUID uuid = mStates.keyAt(i);
            final State state = mStates.valueAt(i);
            if (StorageManager.UUID_DEFAULT.equals(uuid)) {
                pw.println("Default:");
            } else {
                pw.println(uuid + ":");
            }
            pw.increaseIndent();
            pw.printPair("level", State.levelToString(state.level));
            pw.printPair("lastUsableBytes", state.lastUsableBytes);
            pw.println();
            pw.decreaseIndent();
        }
        pw.decreaseIndent();
        pw.println();

        pw.printPair("mSeq", mSeq.get());
        pw.printPair("mForceState", State.levelToString(mForceLevel));
        pw.println();
        pw.println();

    } else {
        Shell shell = new Shell();
        shell.exec(mRemoteService, null, fd, null, args, null, new ResultReceiver(null));
    }
}
 
Example 9
Source File: HdmiCecController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(final IndentingPrintWriter pw) {
    for (int i = 0; i < mLocalDevices.size(); ++i) {
        pw.println("HdmiCecLocalDevice #" + i + ":");
        pw.increaseIndent();
        mLocalDevices.valueAt(i).dump(pw);
        pw.decreaseIndent();
    }
    pw.println("CEC message history:");
    pw.increaseIndent();
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    for (MessageHistoryRecord record : mMessageHistory) {
        record.dump(pw, sdf);
    }
    pw.decreaseIndent();
}
 
Example 10
Source File: PackageInstallerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(IndentingPrintWriter pw) {
    synchronized (mSessions) {
        pw.println("Active install sessions:");
        pw.increaseIndent();
        int N = mSessions.size();
        for (int i = 0; i < N; i++) {
            final PackageInstallerSession session = mSessions.valueAt(i);
            session.dump(pw);
            pw.println();
        }
        pw.println();
        pw.decreaseIndent();

        pw.println("Historical install sessions:");
        pw.increaseIndent();
        N = mHistoricalSessions.size();
        for (int i = 0; i < N; i++) {
            pw.print(mHistoricalSessions.get(i));
            pw.println();
        }
        pw.println();
        pw.decreaseIndent();

        pw.println("Legacy install sessions:");
        pw.increaseIndent();
        pw.println(mLegacySessions.toString());
        pw.decreaseIndent();
    }
}
 
Example 11
Source File: NetworkStatsCollection.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    for (Key key : getSortedKeys()) {
        pw.print("ident="); pw.print(key.ident.toString());
        pw.print(" uid="); pw.print(key.uid);
        pw.print(" set="); pw.print(NetworkStats.setToString(key.set));
        pw.print(" tag="); pw.println(NetworkStats.tagToString(key.tag));

        final NetworkStatsHistory history = mStats.get(key);
        pw.increaseIndent();
        history.dump(pw, true);
        pw.decreaseIndent();
    }
}
 
Example 12
Source File: DiskInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println("DiskInfo{" + id + "}:");
    pw.increaseIndent();
    pw.printPair("flags", DebugUtils.flagsToString(getClass(), "FLAG_", flags));
    pw.printPair("size", size);
    pw.printPair("label", label);
    pw.println();
    pw.printPair("sysPath", sysPath);
    pw.decreaseIndent();
    pw.println();
}
 
Example 13
Source File: JobSchedulerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(IndentingPrintWriter pw) {
    pw.println("Settings:");
    pw.increaseIndent();
    pw.printPair(KEY_MIN_IDLE_COUNT, MIN_IDLE_COUNT).println();
    pw.printPair(KEY_MIN_CHARGING_COUNT, MIN_CHARGING_COUNT).println();
    pw.printPair(KEY_MIN_BATTERY_NOT_LOW_COUNT, MIN_BATTERY_NOT_LOW_COUNT).println();
    pw.printPair(KEY_MIN_STORAGE_NOT_LOW_COUNT, MIN_STORAGE_NOT_LOW_COUNT).println();
    pw.printPair(KEY_MIN_CONNECTIVITY_COUNT, MIN_CONNECTIVITY_COUNT).println();
    pw.printPair(KEY_MIN_CONTENT_COUNT, MIN_CONTENT_COUNT).println();
    pw.printPair(KEY_MIN_READY_JOBS_COUNT, MIN_READY_JOBS_COUNT).println();
    pw.printPair(KEY_HEAVY_USE_FACTOR, HEAVY_USE_FACTOR).println();
    pw.printPair(KEY_MODERATE_USE_FACTOR, MODERATE_USE_FACTOR).println();
    pw.printPair(KEY_FG_JOB_COUNT, FG_JOB_COUNT).println();
    pw.printPair(KEY_BG_NORMAL_JOB_COUNT, BG_NORMAL_JOB_COUNT).println();
    pw.printPair(KEY_BG_MODERATE_JOB_COUNT, BG_MODERATE_JOB_COUNT).println();
    pw.printPair(KEY_BG_LOW_JOB_COUNT, BG_LOW_JOB_COUNT).println();
    pw.printPair(KEY_BG_CRITICAL_JOB_COUNT, BG_CRITICAL_JOB_COUNT).println();
    pw.printPair(KEY_MAX_STANDARD_RESCHEDULE_COUNT, MAX_STANDARD_RESCHEDULE_COUNT).println();
    pw.printPair(KEY_MAX_WORK_RESCHEDULE_COUNT, MAX_WORK_RESCHEDULE_COUNT).println();
    pw.printPair(KEY_MIN_LINEAR_BACKOFF_TIME, MIN_LINEAR_BACKOFF_TIME).println();
    pw.printPair(KEY_MIN_EXP_BACKOFF_TIME, MIN_EXP_BACKOFF_TIME).println();
    pw.printPair(KEY_STANDBY_HEARTBEAT_TIME, STANDBY_HEARTBEAT_TIME).println();
    pw.print("standby_beats={");
    pw.print(STANDBY_BEATS[0]);
    for (int i = 1; i < STANDBY_BEATS.length; i++) {
        pw.print(", ");
        pw.print(STANDBY_BEATS[i]);
    }
    pw.println('}');
    pw.printPair(KEY_CONN_CONGESTION_DELAY_FRAC, CONN_CONGESTION_DELAY_FRAC).println();
    pw.printPair(KEY_CONN_PREFETCH_RELAX_FRAC, CONN_PREFETCH_RELAX_FRAC).println();
    pw.decreaseIndent();
}
 
Example 14
Source File: NetworkFactory.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    pw.println(toString());
    pw.increaseIndent();
    for (int i = 0; i < mNetworkRequests.size(); i++) {
        pw.println(mNetworkRequests.valueAt(i));
    }
    pw.decreaseIndent();
}
 
Example 15
Source File: OverlayDisplayAdapter.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dumpLocked(PrintWriter pw) {
    pw.println("  " + mName + ":");
    pw.println("    mModes=" + Arrays.toString(mModes.toArray()));
    pw.println("    mActiveMode=" + mActiveMode);
    pw.println("    mGravity=" + mGravity);
    pw.println("    mSecure=" + mSecure);
    pw.println("    mNumber=" + mNumber);

    // Try to dump the window state.
    if (mWindow != null) {
        final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "    ");
        ipw.increaseIndent();
        DumpUtils.dumpAsync(mUiHandler, mWindow, ipw, "", 200);
    }
}
 
Example 16
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
protected synchronized void dump(FileDescriptor fd, PrintWriter pw_, String[] args) {
    if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw_)) return;
    final IndentingPrintWriter pw = new IndentingPrintWriter(pw_, "  ");

    final boolean dumpAll = ArrayUtils.contains(args, "-a");

    // This makes it so that future permission checks will be in the context of this
    // process rather than the caller's process. We will restore this before returning.
    final long identityToken = clearCallingIdentity();
    try {
        if (mSyncManager == null) {
            pw.println("No SyncManager created!  (Disk full?)");
        } else {
            mSyncManager.dump(fd, pw, dumpAll);
        }
        pw.println();
        pw.println("Observer tree:");
        synchronized (mRootNode) {
            int[] counts = new int[2];
            final SparseIntArray pidCounts = new SparseIntArray();
            mRootNode.dumpLocked(fd, pw, args, "", "  ", counts, pidCounts);
            pw.println();
            ArrayList<Integer> sorted = new ArrayList<Integer>();
            for (int i=0; i<pidCounts.size(); i++) {
                sorted.add(pidCounts.keyAt(i));
            }
            Collections.sort(sorted, new Comparator<Integer>() {
                @Override
                public int compare(Integer lhs, Integer rhs) {
                    int lc = pidCounts.get(lhs);
                    int rc = pidCounts.get(rhs);
                    if (lc < rc) {
                        return 1;
                    } else if (lc > rc) {
                        return -1;
                    }
                    return 0;
                }

            });
            for (int i=0; i<sorted.size(); i++) {
                int pid = sorted.get(i);
                pw.print("  pid "); pw.print(pid); pw.print(": ");
                pw.print(pidCounts.get(pid)); pw.println(" observers");
            }
            pw.println();
            pw.print(" Total number of nodes: "); pw.println(counts[0]);
            pw.print(" Total number of observers: "); pw.println(counts[1]);
        }

        synchronized (mCache) {
            pw.println();
            pw.println("Cached content:");
            pw.increaseIndent();
            for (int i = 0; i < mCache.size(); i++) {
                pw.println("User " + mCache.keyAt(i) + ":");
                pw.increaseIndent();
                pw.println(mCache.valueAt(i));
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
Example 17
Source File: ContentService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected synchronized void dump(FileDescriptor fd, PrintWriter pw_, String[] args) {
    if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw_)) return;
    final IndentingPrintWriter pw = new IndentingPrintWriter(pw_, "  ");

    final boolean dumpAll = ArrayUtils.contains(args, "-a");

    // This makes it so that future permission checks will be in the context of this
    // process rather than the caller's process. We will restore this before returning.
    final long identityToken = clearCallingIdentity();
    try {
        if (mSyncManager == null) {
            pw.println("SyncManager not available yet");
        } else {
            mSyncManager.dump(fd, pw, dumpAll);
        }
        pw.println();
        pw.println("Observer tree:");
        synchronized (mRootNode) {
            int[] counts = new int[2];
            final SparseIntArray pidCounts = new SparseIntArray();
            mRootNode.dumpLocked(fd, pw, args, "", "  ", counts, pidCounts);
            pw.println();
            ArrayList<Integer> sorted = new ArrayList<Integer>();
            for (int i=0; i<pidCounts.size(); i++) {
                sorted.add(pidCounts.keyAt(i));
            }
            Collections.sort(sorted, new Comparator<Integer>() {
                @Override
                public int compare(Integer lhs, Integer rhs) {
                    int lc = pidCounts.get(lhs);
                    int rc = pidCounts.get(rhs);
                    if (lc < rc) {
                        return 1;
                    } else if (lc > rc) {
                        return -1;
                    }
                    return 0;
                }

            });
            for (int i=0; i<sorted.size(); i++) {
                int pid = sorted.get(i);
                pw.print("  pid "); pw.print(pid); pw.print(": ");
                pw.print(pidCounts.get(pid)); pw.println(" observers");
            }
            pw.println();
            pw.print(" Total number of nodes: "); pw.println(counts[0]);
            pw.print(" Total number of observers: "); pw.println(counts[1]);
        }

        synchronized (mCache) {
            pw.println();
            pw.println("Cached content:");
            pw.increaseIndent();
            for (int i = 0; i < mCache.size(); i++) {
                pw.println("User " + mCache.keyAt(i) + ":");
                pw.increaseIndent();
                pw.println(mCache.valueAt(i));
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
Example 18
Source File: ResourcesManager.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * @hide
 */
public void dump(String prefix, PrintWriter printWriter) {
    synchronized (this) {
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, "  ");
        for (int i = 0; i < prefix.length() / 2; i++) {
            pw.increaseIndent();
        }

        pw.println("ResourcesManager:");
        pw.increaseIndent();
        if (mLoadedApkAssets != null) {
            pw.print("cached apks: total=");
            pw.print(mLoadedApkAssets.size());
            pw.print(" created=");
            pw.print(mLoadedApkAssets.createCount());
            pw.print(" evicted=");
            pw.print(mLoadedApkAssets.evictionCount());
            pw.print(" hit=");
            pw.print(mLoadedApkAssets.hitCount());
            pw.print(" miss=");
            pw.print(mLoadedApkAssets.missCount());
            pw.print(" max=");
            pw.print(mLoadedApkAssets.maxSize());
        } else {
            pw.print("cached apks: 0 [cache disabled]");
        }
        pw.println();

        pw.print("total apks: ");
        pw.println(countLiveReferences(mCachedApkAssets.values()));

        pw.print("resources: ");

        int references = countLiveReferences(mResourceReferences);
        for (ActivityResources activityResources : mActivityResourceReferences.values()) {
            references += countLiveReferences(activityResources.activityResources);
        }
        pw.println(references);

        pw.print("resource impls: ");
        pw.println(countLiveReferences(mResourceImpls.values()));
    }
}
 
Example 19
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    // Binder.java closes the resource for us.
    @SuppressWarnings("resource")
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    pw.println("Tethering:");
    pw.increaseIndent();

    pw.println("Configuration:");
    pw.increaseIndent();
    final TetheringConfiguration cfg = mConfig;
    cfg.dump(pw);
    pw.decreaseIndent();

    synchronized (mPublicSync) {
        pw.println("Tether state:");
        pw.increaseIndent();
        for (int i = 0; i < mTetherStates.size(); i++) {
            final String iface = mTetherStates.keyAt(i);
            final TetherState tetherState = mTetherStates.valueAt(i);
            pw.print(iface + " - ");

            switch (tetherState.lastState) {
                case IControlsTethering.STATE_UNAVAILABLE:
                    pw.print("UnavailableState");
                    break;
                case IControlsTethering.STATE_AVAILABLE:
                    pw.print("AvailableState");
                    break;
                case IControlsTethering.STATE_TETHERED:
                    pw.print("TetheredState");
                    break;
                case IControlsTethering.STATE_LOCAL_ONLY:
                    pw.print("LocalHotspotState");
                    break;
                default:
                    pw.print("UnknownState");
                    break;
            }
            pw.println(" - lastError = " + tetherState.lastError);
        }
        pw.println("Upstream wanted: " + upstreamWanted());
        pw.println("Current upstream interface(s): " + mCurrentUpstreamIfaceSet);
        pw.decreaseIndent();
    }

    pw.println("Hardware offload:");
    pw.increaseIndent();
    mOffloadController.dump(pw);
    pw.decreaseIndent();

    pw.println("Log:");
    pw.increaseIndent();
    if (argsContain(args, SHORT_ARG)) {
        pw.println("<log removed for brevity>");
    } else {
        mLog.dump(fd, pw, args);
    }
    pw.decreaseIndent();

    pw.decreaseIndent();
}
 
Example 20
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
protected synchronized void dump(FileDescriptor fd, PrintWriter pw_, String[] args) {
    if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw_)) return;
    final IndentingPrintWriter pw = new IndentingPrintWriter(pw_, "  ");

    final boolean dumpAll = ArrayUtils.contains(args, "-a");

    // This makes it so that future permission checks will be in the context of this
    // process rather than the caller's process. We will restore this before returning.
    final long identityToken = clearCallingIdentity();
    try {
        if (mSyncManager == null) {
            pw.println("SyncManager not available yet");
        } else {
            mSyncManager.dump(fd, pw, dumpAll);
        }
        pw.println();
        pw.println("Observer tree:");
        synchronized (mRootNode) {
            int[] counts = new int[2];
            final SparseIntArray pidCounts = new SparseIntArray();
            mRootNode.dumpLocked(fd, pw, args, "", "  ", counts, pidCounts);
            pw.println();
            ArrayList<Integer> sorted = new ArrayList<Integer>();
            for (int i=0; i<pidCounts.size(); i++) {
                sorted.add(pidCounts.keyAt(i));
            }
            Collections.sort(sorted, new Comparator<Integer>() {
                @Override
                public int compare(Integer lhs, Integer rhs) {
                    int lc = pidCounts.get(lhs);
                    int rc = pidCounts.get(rhs);
                    if (lc < rc) {
                        return 1;
                    } else if (lc > rc) {
                        return -1;
                    }
                    return 0;
                }

            });
            for (int i=0; i<sorted.size(); i++) {
                int pid = sorted.get(i);
                pw.print("  pid "); pw.print(pid); pw.print(": ");
                pw.print(pidCounts.get(pid)); pw.println(" observers");
            }
            pw.println();
            pw.print(" Total number of nodes: "); pw.println(counts[0]);
            pw.print(" Total number of observers: "); pw.println(counts[1]);

            sObserverDeathDispatcher.dump(pw, " ");
        }
        synchronized (sObserverLeakDetectedUid) {
            pw.println();
            pw.print("Observer leaking UIDs: ");
            pw.println(sObserverLeakDetectedUid.toString());
        }

        synchronized (mCache) {
            pw.println();
            pw.println("Cached content:");
            pw.increaseIndent();
            for (int i = 0; i < mCache.size(); i++) {
                pw.println("User " + mCache.keyAt(i) + ":");
                pw.increaseIndent();
                pw.println(mCache.valueAt(i));
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}