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

The following examples show how to use com.android.internal.util.IndentingPrintWriter#print() . 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: NetworkStatsHistory.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw, boolean fullHistory) {
    pw.print("NetworkStatsHistory: bucketDuration=");
    pw.println(bucketDuration / SECOND_IN_MILLIS);
    pw.increaseIndent();

    final int start = fullHistory ? 0 : Math.max(0, bucketCount - 32);
    if (start > 0) {
        pw.print("(omitting "); pw.print(start); pw.println(" buckets)");
    }

    for (int i = start; i < bucketCount; i++) {
        pw.print("st="); pw.print(bucketStart[i] / SECOND_IN_MILLIS);
        if (rxBytes != null) { pw.print(" rb="); pw.print(rxBytes[i]); }
        if (rxPackets != null) { pw.print(" rp="); pw.print(rxPackets[i]); }
        if (txBytes != null) { pw.print(" tb="); pw.print(txBytes[i]); }
        if (txPackets != null) { pw.print(" tp="); pw.print(txPackets[i]); }
        if (operations != null) { pw.print(" op="); pw.print(operations[i]); }
        pw.println();
    }

    pw.decreaseIndent();
}
 
Example 2
Source File: IdleController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    pw.println("Currently idle: " + mIdleTracker.isIdle());
    pw.println();

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        pw.print("#");
        js.printUniqueId(pw);
        pw.print(" from ");
        UserHandle.formatUid(pw, js.getSourceUid());
        pw.println();
    }
}
 
Example 3
Source File: StorageController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    pw.println("Not low: " + mStorageTracker.isStorageNotLow());
    pw.println("Sequence: " + mStorageTracker.getSeq());
    pw.println();

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        pw.print("#");
        js.printUniqueId(pw);
        pw.print(" from ");
        UserHandle.formatUid(pw, js.getSourceUid());
        pw.println();
    }
}
 
Example 4
Source File: BatteryController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    pw.println("Stable power: " + mChargeTracker.isOnStablePower());
    pw.println("Not low: " + mChargeTracker.isBatteryNotLow());

    if (mChargeTracker.isMonitoring()) {
        pw.print("MONITORING: seq=");
        pw.println(mChargeTracker.getSeq());
    }
    pw.println();

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        pw.print("#");
        js.printUniqueId(pw);
        pw.print(" from ");
        UserHandle.formatUid(pw, js.getSourceUid());
        pw.println();
    }
}
 
Example 5
Source File: ConnectivityController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mLock")
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    for (int i = 0; i < mTrackedJobs.size(); i++) {
        final JobStatus js = mTrackedJobs.valueAt(i);
        if (predicate.test(js)) {
            pw.print("#");
            js.printUniqueId(pw);
            pw.print(" from ");
            UserHandle.formatUid(pw, js.getSourceUid());
            pw.print(": ");
            pw.print(js.getJob().getRequiredNetwork());
            pw.println();
        }
    }
}
 
Example 6
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 7
Source File: TimeController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    final long nowElapsed = sElapsedRealtimeClock.millis();
    pw.println("Elapsed clock: " + nowElapsed);

    pw.print("Next delay alarm in ");
    TimeUtils.formatDuration(mNextDelayExpiredElapsedMillis, nowElapsed, pw);
    pw.println();
    pw.print("Next deadline alarm in ");
    TimeUtils.formatDuration(mNextJobExpiredElapsedMillis, nowElapsed, pw);
    pw.println();
    pw.println();

    for (JobStatus ts : mTrackedJobs) {
        if (!predicate.test(ts)) {
            continue;
        }
        pw.print("#");
        ts.printUniqueId(pw);
        pw.print(" from ");
        UserHandle.formatUid(pw, ts.getSourceUid());
        pw.print(": Delay=");
        if (ts.hasTimingDelayConstraint()) {
            TimeUtils.formatDuration(ts.getEarliestRunTime(), nowElapsed, pw);
        } else {
            pw.print("N/A");
        }
        pw.print(", Deadline=");
        if (ts.hasDeadlineConstraint()) {
            TimeUtils.formatDuration(ts.getLatestRunTimeElapsed(), nowElapsed, pw);
        } else {
            pw.print("N/A");
        }
        pw.println();
    }
}
 
Example 8
Source File: SearchManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
    synchronized (mSearchables) {
        for (int i = 0; i < mSearchables.size(); i++) {
            ipw.print("\nUser: "); ipw.println(mSearchables.keyAt(i));
            ipw.increaseIndent();
            mSearchables.valueAt(i).dump(fd, ipw, args);
            ipw.decreaseIndent();
        }
    }
}
 
Example 9
Source File: NetworkPolicyLogger.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void reverseDump(IndentingPrintWriter pw) {
    final Data[] allData = toArray();
    for (int i = allData.length - 1; i >= 0; --i) {
        if (allData[i] == null) {
            pw.println("NULL");
            continue;
        }
        pw.print(formatDate(allData[i].timeStamp));
        pw.print(" - ");
        pw.println(getContent(allData[i]));
    }
}
 
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: HdmiCecController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(final IndentingPrintWriter pw, SimpleDateFormat sdf) {
    pw.print(mIsReceived ? "[R]" : "[S]");
    pw.print(" time=");
    pw.print(sdf.format(new Date(mTime)));
    pw.print(" message=");
    pw.println(mMessage);
}
 
Example 12
Source File: OverlayManagerSettings.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(@NonNull final PrintWriter p) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(p, "  ");
    pw.println("Settings");
    pw.increaseIndent();

    if (mItems.isEmpty()) {
        pw.println("<none>");
        return;
    }

    final int N = mItems.size();
    for (int i = 0; i < N; i++) {
        final SettingsItem item = mItems.get(i);
        pw.println(item.mPackageName + ":" + item.getUserId() + " {");
        pw.increaseIndent();

        pw.print("mPackageName.......: "); pw.println(item.mPackageName);
        pw.print("mUserId............: "); pw.println(item.getUserId());
        pw.print("mTargetPackageName.: "); pw.println(item.getTargetPackageName());
        pw.print("mBaseCodePath......: "); pw.println(item.getBaseCodePath());
        pw.print("mState.............: "); pw.println(OverlayInfo.stateToString(item.getState()));
        pw.print("mIsEnabled.........: "); pw.println(item.isEnabled());
        pw.print("mIsStatic..........: "); pw.println(item.isStatic());
        pw.print("mPriority..........: "); pw.println(item.mPriority);
        pw.print("mCategory..........: "); pw.println(item.mCategory);

        pw.decreaseIndent();
        pw.println("}");
    }
}
 
Example 13
Source File: NetworkStatsRecorder.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dumpLocked(IndentingPrintWriter pw, boolean fullHistory) {
    if (mPending != null) {
        pw.print("Pending bytes: "); pw.println(mPending.getTotalBytes());
    }
    if (fullHistory) {
        pw.println("Complete history:");
        getOrLoadCompleteLocked().dump(pw);
    } else {
        pw.println("History since boot:");
        mSinceBoot.dump(pw);
    }
}
 
Example 14
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 15
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 16
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 17
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 18
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 19
Source File: AppStateTracker.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    synchronized (mLock) {
        pw.println("Forced App Standby Feature enabled: " + mForcedAppStandbyEnabled);

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

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

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

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

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

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

        pw.print("Except-idle + user whitelist appids: ");
        pw.println(Arrays.toString(mPowerWhitelistedAllAppIds));

        pw.print("User whitelist appids: ");
        pw.println(Arrays.toString(mPowerWhitelistedUserAppIds));

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

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

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

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

        mStatLogger.dump(pw);
    }
}
 
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);
    }
}