Search in sources :

Example 76 with IndentingPrintWriter

use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.

the class NetworkStatsService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter rawWriter, String[] args) {
    mContext.enforceCallingOrSelfPermission(DUMP, TAG);
    long duration = DateUtils.DAY_IN_MILLIS;
    final HashSet<String> argSet = new HashSet<String>();
    for (String arg : args) {
        argSet.add(arg);
        if (arg.startsWith("--duration=")) {
            try {
                duration = Long.parseLong(arg.substring(11));
            } catch (NumberFormatException ignored) {
            }
        }
    }
    // usage: dumpsys netstats --full --uid --tag --poll --checkin
    final boolean poll = argSet.contains("--poll") || argSet.contains("poll");
    final boolean checkin = argSet.contains("--checkin");
    final boolean fullHistory = argSet.contains("--full") || argSet.contains("full");
    final boolean includeUid = argSet.contains("--uid") || argSet.contains("detail");
    final boolean includeTag = argSet.contains("--tag") || argSet.contains("detail");
    final IndentingPrintWriter pw = new IndentingPrintWriter(rawWriter, "  ");
    synchronized (mStatsLock) {
        if (poll) {
            performPollLocked(FLAG_PERSIST_ALL | FLAG_PERSIST_FORCE);
            pw.println("Forced poll");
            return;
        }
        if (checkin) {
            final long end = System.currentTimeMillis();
            final long start = end - duration;
            pw.print("v1,");
            pw.print(start / SECOND_IN_MILLIS);
            pw.print(',');
            pw.print(end / SECOND_IN_MILLIS);
            pw.println();
            pw.println("xt");
            mXtRecorder.dumpCheckin(rawWriter, start, end);
            if (includeUid) {
                pw.println("uid");
                mUidRecorder.dumpCheckin(rawWriter, start, end);
            }
            if (includeTag) {
                pw.println("tag");
                mUidTagRecorder.dumpCheckin(rawWriter, start, end);
            }
            return;
        }
        pw.println("Active interfaces:");
        pw.increaseIndent();
        for (int i = 0; i < mActiveIfaces.size(); i++) {
            pw.printPair("iface", mActiveIfaces.keyAt(i));
            pw.printPair("ident", mActiveIfaces.valueAt(i));
            pw.println();
        }
        pw.decreaseIndent();
        pw.println("Active UID interfaces:");
        pw.increaseIndent();
        for (int i = 0; i < mActiveUidIfaces.size(); i++) {
            pw.printPair("iface", mActiveUidIfaces.keyAt(i));
            pw.printPair("ident", mActiveUidIfaces.valueAt(i));
            pw.println();
        }
        pw.decreaseIndent();
        pw.println("Dev stats:");
        pw.increaseIndent();
        mDevRecorder.dumpLocked(pw, fullHistory);
        pw.decreaseIndent();
        pw.println("Xt stats:");
        pw.increaseIndent();
        mXtRecorder.dumpLocked(pw, fullHistory);
        pw.decreaseIndent();
        if (includeUid) {
            pw.println("UID stats:");
            pw.increaseIndent();
            mUidRecorder.dumpLocked(pw, fullHistory);
            pw.decreaseIndent();
        }
        if (includeTag) {
            pw.println("UID tag stats:");
            pw.increaseIndent();
            mUidTagRecorder.dumpLocked(pw, fullHistory);
            pw.decreaseIndent();
        }
    }
}
Also used : IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter) HashSet(java.util.HashSet)

Example 77 with IndentingPrintWriter

use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.

the class TvInputHardwareManager method dump.

public void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump TvInputHardwareManager from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mLock) {
        pw.println("TvInputHardwareManager Info:");
        pw.increaseIndent();
        pw.println("mConnections: deviceId -> Connection");
        pw.increaseIndent();
        for (int i = 0; i < mConnections.size(); i++) {
            int deviceId = mConnections.keyAt(i);
            Connection mConnection = mConnections.valueAt(i);
            pw.println(deviceId + ": " + mConnection);
        }
        pw.decreaseIndent();
        pw.println("mHardwareList:");
        pw.increaseIndent();
        for (TvInputHardwareInfo tvInputHardwareInfo : mHardwareList) {
            pw.println(tvInputHardwareInfo);
        }
        pw.decreaseIndent();
        pw.println("mHdmiDeviceList:");
        pw.increaseIndent();
        for (HdmiDeviceInfo hdmiDeviceInfo : mHdmiDeviceList) {
            pw.println(hdmiDeviceInfo);
        }
        pw.decreaseIndent();
        pw.println("mHardwareInputIdMap: deviceId -> inputId");
        pw.increaseIndent();
        for (int i = 0; i < mHardwareInputIdMap.size(); i++) {
            int deviceId = mHardwareInputIdMap.keyAt(i);
            String inputId = mHardwareInputIdMap.valueAt(i);
            pw.println(deviceId + ": " + inputId);
        }
        pw.decreaseIndent();
        pw.println("mHdmiInputIdMap: id -> inputId");
        pw.increaseIndent();
        for (int i = 0; i < mHdmiInputIdMap.size(); i++) {
            int id = mHdmiInputIdMap.keyAt(i);
            String inputId = mHdmiInputIdMap.valueAt(i);
            pw.println(id + ": " + inputId);
        }
        pw.decreaseIndent();
        pw.println("mInputMap: inputId -> inputInfo");
        pw.increaseIndent();
        for (Map.Entry<String, TvInputInfo> entry : mInputMap.entrySet()) {
            pw.println(entry.getKey() + ": " + entry.getValue());
        }
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) TvInputHardwareInfo(android.media.tv.TvInputHardwareInfo) TvInputInfo(android.media.tv.TvInputInfo) Map(java.util.Map) ArrayMap(android.util.ArrayMap) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 78 with IndentingPrintWriter

use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.

the class MidiService method dump.

@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    pw.println("MIDI Manager State:");
    pw.increaseIndent();
    pw.println("Devices:");
    pw.increaseIndent();
    synchronized (mDevicesByInfo) {
        for (Device device : mDevicesByInfo.values()) {
            pw.println(device.toString());
        }
    }
    pw.decreaseIndent();
    pw.println("Clients:");
    pw.increaseIndent();
    synchronized (mClients) {
        for (Client client : mClients.values()) {
            pw.println(client.toString());
        }
    }
    pw.decreaseIndent();
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 79 with IndentingPrintWriter

use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.

the class UsageStatsService method dump.

/**
     * Called by the Binder stub.
     */
void dump(String[] args, PrintWriter pw) {
    synchronized (mLock) {
        IndentingPrintWriter idpw = new IndentingPrintWriter(pw, "  ");
        ArraySet<String> argSet = new ArraySet<>();
        argSet.addAll(Arrays.asList(args));
        final int userCount = mUserState.size();
        for (int i = 0; i < userCount; i++) {
            idpw.printPair("user", mUserState.keyAt(i));
            idpw.println();
            idpw.increaseIndent();
            if (argSet.contains("--checkin")) {
                mUserState.valueAt(i).checkin(idpw);
            } else {
                mUserState.valueAt(i).dump(idpw);
                idpw.println();
                if (args.length > 0) {
                    if ("history".equals(args[0])) {
                        mAppIdleHistory.dumpHistory(idpw, mUserState.keyAt(i));
                    } else if ("flush".equals(args[0])) {
                        UsageStatsService.this.flushToDiskLocked();
                        pw.println("Flushed stats to disk");
                    }
                }
            }
            mAppIdleHistory.dump(idpw, mUserState.keyAt(i));
            idpw.decreaseIndent();
        }
        pw.println();
        pw.println("Carrier privileged apps (have=" + mHaveCarrierPrivilegedApps + "): " + mCarrierPrivilegedApps);
        pw.println();
        pw.println("Settings:");
        pw.print("  mAppIdleDurationMillis=");
        TimeUtils.formatDuration(mAppIdleScreenThresholdMillis, pw);
        pw.println();
        pw.print("  mAppIdleWallclockThresholdMillis=");
        TimeUtils.formatDuration(mAppIdleWallclockThresholdMillis, pw);
        pw.println();
        pw.print("  mCheckIdleIntervalMillis=");
        TimeUtils.formatDuration(mCheckIdleIntervalMillis, pw);
        pw.println();
        pw.print("  mAppIdleParoleIntervalMillis=");
        TimeUtils.formatDuration(mAppIdleParoleIntervalMillis, pw);
        pw.println();
        pw.print("  mAppIdleParoleDurationMillis=");
        TimeUtils.formatDuration(mAppIdleParoleDurationMillis, pw);
        pw.println();
        pw.println();
        pw.print("mAppIdleEnabled=");
        pw.print(mAppIdleEnabled);
        pw.print(" mAppIdleTempParoled=");
        pw.print(mAppIdleTempParoled);
        pw.print(" mCharging=");
        pw.print(mCharging);
        pw.print(" mLastAppIdleParoledTime=");
        TimeUtils.formatDuration(mLastAppIdleParoledTime, pw);
        pw.println();
    }
}
Also used : ArraySet(android.util.ArraySet) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 80 with IndentingPrintWriter

use of com.android.internal.util.IndentingPrintWriter in project android_frameworks_base by ParanoidAndroid.

the class AccountManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        fout.println("Permission Denial: can't dump AccountsManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " without permission " + android.Manifest.permission.DUMP);
        return;
    }
    final boolean isCheckinRequest = scanArgs(args, "--checkin") || scanArgs(args, "-c");
    final IndentingPrintWriter ipw = new IndentingPrintWriter(fout, "  ");
    final List<UserInfo> users = getUserManager().getUsers();
    for (UserInfo user : users) {
        ipw.println("User " + user + ":");
        ipw.increaseIndent();
        dumpUser(getUserAccounts(user.id), fd, ipw, args, isCheckinRequest);
        ipw.println();
        ipw.decreaseIndent();
    }
}
Also used : UserInfo(android.content.pm.UserInfo) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Aggregations

IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)126 CharArrayWriter (java.io.CharArrayWriter)21 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)10 ArrayList (java.util.ArrayList)10 ArraySet (android.util.ArraySet)9 HashSet (java.util.HashSet)7 PackageParser (android.content.pm.PackageParser)6 UserInfo (android.content.pm.UserInfo)6 ArrayMap (android.util.ArrayMap)6 SparseBooleanArray (android.util.SparseBooleanArray)6 Map (java.util.Map)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Point (android.graphics.Point)5 INetworkPolicyManager (android.net.INetworkPolicyManager)5 NetworkPolicyManager (android.net.NetworkPolicyManager)5 IBinder (android.os.IBinder)5 RemoteCallbackList (android.os.RemoteCallbackList)5 DiskInfo (android.os.storage.DiskInfo)5 VolumeInfo (android.os.storage.VolumeInfo)5 VolumeRecord (android.os.storage.VolumeRecord)5