use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.
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();
}
}
use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.
the class ContentService method dump.
@Override
protected synchronized void dump(FileDescriptor fd, PrintWriter pw_, String[] args) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.DUMP, "caller doesn't have the DUMP permission");
final IndentingPrintWriter pw = new IndentingPrintWriter(pw_, " ");
// 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);
}
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);
}
}
use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.
the class WifiDisplayAdapter method dumpLocked.
@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);
}
}
use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.
the class NetworkPolicyManagerService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
mContext.enforceCallingOrSelfPermission(DUMP, TAG);
final IndentingPrintWriter fout = new IndentingPrintWriter(writer, " ");
final ArraySet<String> argSet = new ArraySet<String>(args.length);
for (String arg : args) {
argSet.add(arg);
}
synchronized (mUidRulesFirstLock) {
synchronized (mNetworkPoliciesSecondLock) {
if (argSet.contains("--unsnooze")) {
for (int i = mNetworkPolicy.size() - 1; i >= 0; i--) {
mNetworkPolicy.valueAt(i).clearSnooze();
}
normalizePoliciesNL();
updateNetworkEnabledNL();
updateNetworkRulesNL();
updateNotificationsNL();
writePolicyAL();
fout.println("Cleared snooze timestamps");
return;
}
fout.print("System ready: ");
fout.println(mSystemReady);
fout.print("Restrict background: ");
fout.println(mRestrictBackground);
fout.print("Restrict power: ");
fout.println(mRestrictPower);
fout.print("Device idle: ");
fout.println(mDeviceIdleMode);
fout.println("Network policies:");
fout.increaseIndent();
for (int i = 0; i < mNetworkPolicy.size(); i++) {
fout.println(mNetworkPolicy.valueAt(i).toString());
}
fout.decreaseIndent();
fout.print("Metered ifaces: ");
fout.println(String.valueOf(mMeteredIfaces));
fout.println("Policy for UIDs:");
fout.increaseIndent();
int size = mUidPolicy.size();
for (int i = 0; i < size; i++) {
final int uid = mUidPolicy.keyAt(i);
final int policy = mUidPolicy.valueAt(i);
fout.print("UID=");
fout.print(uid);
fout.print(" policy=");
fout.print(DebugUtils.flagsToString(NetworkPolicyManager.class, "POLICY_", policy));
fout.println();
}
fout.decreaseIndent();
size = mPowerSaveWhitelistExceptIdleAppIds.size();
if (size > 0) {
fout.println("Power save whitelist (except idle) app ids:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
fout.print(mPowerSaveWhitelistExceptIdleAppIds.keyAt(i));
fout.print(": ");
fout.print(mPowerSaveWhitelistExceptIdleAppIds.valueAt(i));
fout.println();
}
fout.decreaseIndent();
}
size = mPowerSaveWhitelistAppIds.size();
if (size > 0) {
fout.println("Power save whitelist app ids:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
fout.print(mPowerSaveWhitelistAppIds.keyAt(i));
fout.print(": ");
fout.print(mPowerSaveWhitelistAppIds.valueAt(i));
fout.println();
}
fout.decreaseIndent();
}
size = mRestrictBackgroundWhitelistUids.size();
if (size > 0) {
fout.println("Restrict background whitelist uids:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
fout.print(mRestrictBackgroundWhitelistUids.keyAt(i));
fout.println();
}
fout.decreaseIndent();
}
size = mDefaultRestrictBackgroundWhitelistUids.size();
if (size > 0) {
fout.println("Default restrict background whitelist uids:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
fout.print(mDefaultRestrictBackgroundWhitelistUids.keyAt(i));
fout.println();
}
fout.decreaseIndent();
}
size = mRestrictBackgroundWhitelistRevokedUids.size();
if (size > 0) {
fout.println("Default restrict background whitelist uids revoked by users:");
fout.increaseIndent();
for (int i = 0; i < size; i++) {
fout.print("UID=");
fout.print(mRestrictBackgroundWhitelistRevokedUids.keyAt(i));
fout.println();
}
fout.decreaseIndent();
}
final SparseBooleanArray knownUids = new SparseBooleanArray();
collectKeys(mUidState, knownUids);
collectKeys(mUidRules, knownUids);
fout.println("Status for all known UIDs:");
fout.increaseIndent();
size = knownUids.size();
for (int i = 0; i < size; i++) {
final int uid = knownUids.keyAt(i);
fout.print("UID=");
fout.print(uid);
final int state = mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY);
fout.print(" state=");
fout.print(state);
if (state <= ActivityManager.PROCESS_STATE_TOP) {
fout.print(" (fg)");
} else {
fout.print(state <= ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE ? " (fg svc)" : " (bg)");
}
final int uidRules = mUidRules.get(uid, RULE_NONE);
fout.print(" rules=");
fout.print(uidRulesToString(uidRules));
fout.println();
}
fout.decreaseIndent();
fout.println("Status for just UIDs with rules:");
fout.increaseIndent();
size = mUidRules.size();
for (int i = 0; i < size; i++) {
final int uid = mUidRules.keyAt(i);
fout.print("UID=");
fout.print(uid);
final int uidRules = mUidRules.get(uid, RULE_NONE);
fout.print(" rules=");
fout.print(uidRulesToString(uidRules));
fout.println();
}
fout.decreaseIndent();
}
}
}
use of com.android.internal.util.IndentingPrintWriter in project platform_frameworks_base by android.
the class UsbService 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, " ");
final long ident = Binder.clearCallingIdentity();
try {
if (args == null || args.length == 0 || "-a".equals(args[0])) {
pw.println("USB Manager State:");
pw.increaseIndent();
if (mDeviceManager != null) {
mDeviceManager.dump(pw);
}
if (mHostManager != null) {
mHostManager.dump(pw);
}
if (mPortManager != null) {
mPortManager.dump(pw);
}
mAlsaManager.dump(pw);
synchronized (mLock) {
for (int i = 0; i < mSettingsByUser.size(); i++) {
final int userId = mSettingsByUser.keyAt(i);
final UsbSettingsManager settings = mSettingsByUser.valueAt(i);
pw.println("Settings for user " + userId + ":");
pw.increaseIndent();
settings.dump(pw);
pw.decreaseIndent();
}
}
} else if (args.length == 4 && "set-port-roles".equals(args[0])) {
final String portId = args[1];
final int powerRole;
switch(args[2]) {
case "source":
powerRole = UsbPort.POWER_ROLE_SOURCE;
break;
case "sink":
powerRole = UsbPort.POWER_ROLE_SINK;
break;
case "no-power":
powerRole = 0;
break;
default:
pw.println("Invalid power role: " + args[2]);
return;
}
final int dataRole;
switch(args[3]) {
case "host":
dataRole = UsbPort.DATA_ROLE_HOST;
break;
case "device":
dataRole = UsbPort.DATA_ROLE_DEVICE;
break;
case "no-data":
dataRole = 0;
break;
default:
pw.println("Invalid data role: " + args[3]);
return;
}
if (mPortManager != null) {
mPortManager.setPortRoles(portId, powerRole, dataRole, pw);
// Note: It might take some time for the side-effects of this operation
// to be fully applied by the kernel since the driver may need to
// renegotiate the USB port mode. If this proves to be an issue
// during debugging, it might be worth adding a sleep here before
// dumping the new state.
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 3 && "add-port".equals(args[0])) {
final String portId = args[1];
final int supportedModes;
switch(args[2]) {
case "ufp":
supportedModes = UsbPort.MODE_UFP;
break;
case "dfp":
supportedModes = UsbPort.MODE_DFP;
break;
case "dual":
supportedModes = UsbPort.MODE_DUAL;
break;
case "none":
supportedModes = 0;
break;
default:
pw.println("Invalid mode: " + args[2]);
return;
}
if (mPortManager != null) {
mPortManager.addSimulatedPort(portId, supportedModes, pw);
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 5 && "connect-port".equals(args[0])) {
final String portId = args[1];
final int mode;
final boolean canChangeMode = args[2].endsWith("?");
switch(canChangeMode ? removeLastChar(args[2]) : args[2]) {
case "ufp":
mode = UsbPort.MODE_UFP;
break;
case "dfp":
mode = UsbPort.MODE_DFP;
break;
default:
pw.println("Invalid mode: " + args[2]);
return;
}
final int powerRole;
final boolean canChangePowerRole = args[3].endsWith("?");
switch(canChangePowerRole ? removeLastChar(args[3]) : args[3]) {
case "source":
powerRole = UsbPort.POWER_ROLE_SOURCE;
break;
case "sink":
powerRole = UsbPort.POWER_ROLE_SINK;
break;
default:
pw.println("Invalid power role: " + args[3]);
return;
}
final int dataRole;
final boolean canChangeDataRole = args[4].endsWith("?");
switch(canChangeDataRole ? removeLastChar(args[4]) : args[4]) {
case "host":
dataRole = UsbPort.DATA_ROLE_HOST;
break;
case "device":
dataRole = UsbPort.DATA_ROLE_DEVICE;
break;
default:
pw.println("Invalid data role: " + args[4]);
return;
}
if (mPortManager != null) {
mPortManager.connectSimulatedPort(portId, mode, canChangeMode, powerRole, canChangePowerRole, dataRole, canChangeDataRole, pw);
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 2 && "disconnect-port".equals(args[0])) {
final String portId = args[1];
if (mPortManager != null) {
mPortManager.disconnectSimulatedPort(portId, pw);
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 2 && "remove-port".equals(args[0])) {
final String portId = args[1];
if (mPortManager != null) {
mPortManager.removeSimulatedPort(portId, pw);
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 1 && "reset".equals(args[0])) {
if (mPortManager != null) {
mPortManager.resetSimulation(pw);
pw.println();
mPortManager.dump(pw);
}
} else if (args.length == 1 && "ports".equals(args[0])) {
if (mPortManager != null) {
mPortManager.dump(pw);
}
} else {
pw.println("Dump current USB state or issue command:");
pw.println(" ports");
pw.println(" set-port-roles <id> <source|sink|no-power> <host|device|no-data>");
pw.println(" add-port <id> <ufp|dfp|dual|none>");
pw.println(" connect-port <id> <ufp|dfp><?> <source|sink><?> <host|device><?>");
pw.println(" (add ? suffix if mode, power role, or data role can be changed)");
pw.println(" disconnect-port <id>");
pw.println(" remove-port <id>");
pw.println(" reset");
pw.println();
pw.println("Example USB type C port role switch:");
pw.println(" dumpsys usb set-port-roles \"default\" source device");
pw.println();
pw.println("Example USB type C port simulation with full capabilities:");
pw.println(" dumpsys usb add-port \"matrix\" dual");
pw.println(" dumpsys usb connect-port \"matrix\" ufp? sink? device?");
pw.println(" dumpsys usb ports");
pw.println(" dumpsys usb disconnect-port \"matrix\"");
pw.println(" dumpsys usb remove-port \"matrix\"");
pw.println(" dumpsys usb reset");
pw.println();
pw.println("Example USB type C port where only power role can be changed:");
pw.println(" dumpsys usb add-port \"matrix\" dual");
pw.println(" dumpsys usb connect-port \"matrix\" dfp source? host");
pw.println(" dumpsys usb reset");
pw.println();
pw.println("Example USB OTG port where id pin determines function:");
pw.println(" dumpsys usb add-port \"matrix\" dual");
pw.println(" dumpsys usb connect-port \"matrix\" dfp source host");
pw.println(" dumpsys usb reset");
pw.println();
pw.println("Example USB device-only port:");
pw.println(" dumpsys usb add-port \"matrix\" ufp");
pw.println(" dumpsys usb connect-port \"matrix\" ufp sink device");
pw.println(" dumpsys usb reset");
}
} finally {
Binder.restoreCallingIdentity(ident);
}
}
Aggregations