private void doListPermissions( ArrayList<String> groupList, boolean groups, boolean labels, boolean summary, int startProtectionLevel, int endProtectionLevel) throws RemoteException { for (int i = 0; i < groupList.size(); i++) { String groupName = groupList.get(i); String prefix = ""; if (groups) { if (i > 0) System.out.println(""); if (groupName != null) { PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(groupName, 0); if (summary) { Resources res = getResources(pgi); if (res != null) { System.out.print(loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel) + ": "); } else { System.out.print(pgi.name + ": "); } } else { System.out.println((labels ? "+ " : "") + "group:" + pgi.name); if (labels) { System.out.println(" package:" + pgi.packageName); Resources res = getResources(pgi); if (res != null) { System.out.println(" label:" + loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel)); System.out.println( " description:" + loadText(pgi, pgi.descriptionRes, pgi.nonLocalizedDescription)); } } } } else { System.out.println(((labels && !summary) ? "+ " : "") + "ungrouped:"); } prefix = " "; } List<PermissionInfo> ps = mPm.queryPermissionsByGroup(groupList.get(i), 0); int count = ps.size(); boolean first = true; for (int p = 0; p < count; p++) { PermissionInfo pi = ps.get(p); if (groups && groupName == null && pi.group != null) { continue; } final int base = pi.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE; if (base < startProtectionLevel || base > endProtectionLevel) { continue; } if (summary) { if (first) { first = false; } else { System.out.print(", "); } Resources res = getResources(pi); if (res != null) { System.out.print(loadText(pi, pi.labelRes, pi.nonLocalizedLabel)); } else { System.out.print(pi.name); } } else { System.out.println(prefix + (labels ? "+ " : "") + "permission:" + pi.name); if (labels) { System.out.println(prefix + " package:" + pi.packageName); Resources res = getResources(pi); if (res != null) { System.out.println( prefix + " label:" + loadText(pi, pi.labelRes, pi.nonLocalizedLabel)); System.out.println( prefix + " description:" + loadText(pi, pi.descriptionRes, pi.nonLocalizedDescription)); } System.out.println( prefix + " protectionLevel:" + PermissionInfo.protectionToString(pi.protectionLevel)); } } } if (summary) { System.out.println(""); } } }
private void doListPermissions( ArrayList<String> groupList, boolean groups, boolean labels, boolean summary, int startProtectionLevel, int endProtectionLevel) throws RemoteException { for (int i = 0; i < groupList.size(); i++) { String groupName = groupList.get(i); String prefix = ""; if (groups) { if (i > 0) System.out.println(""); if (groupName != null) { PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(groupName, 0); if (summary) { Resources res = getResources(pgi); if (res != null) { System.out.print(loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel) + ": "); } else { System.out.print(pgi.name + ": "); } } else { System.out.println((labels ? "+ " : "") + "group:" + pgi.name); if (labels) { System.out.println(" package:" + pgi.packageName); Resources res = getResources(pgi); if (res != null) { System.out.println(" label:" + loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel)); System.out.println( " description:" + loadText(pgi, pgi.descriptionRes, pgi.nonLocalizedDescription)); } } } } else { System.out.println(((labels && !summary) ? "+ " : "") + "ungrouped:"); } prefix = " "; } List<PermissionInfo> ps = mPm.queryPermissionsByGroup(groupList.get(i), 0); int count = ps.size(); boolean first = true; for (int p = 0; p < count; p++) { PermissionInfo pi = ps.get(p); if (groups && groupName == null && pi.group != null) { continue; } if (pi.protectionLevel < startProtectionLevel || pi.protectionLevel > endProtectionLevel) { continue; } if (summary) { if (first) { first = false; } else { System.out.print(", "); } Resources res = getResources(pi); if (res != null) { System.out.print(loadText(pi, pi.labelRes, pi.nonLocalizedLabel)); } else { System.out.print(pi.name); } } else { System.out.println(prefix + (labels ? "+ " : "") + "permission:" + pi.name); if (labels) { System.out.println(prefix + " package:" + pi.packageName); Resources res = getResources(pi); if (res != null) { System.out.println( prefix + " label:" + loadText(pi, pi.labelRes, pi.nonLocalizedLabel)); System.out.println( prefix + " description:" + loadText(pi, pi.descriptionRes, pi.nonLocalizedDescription)); } String protLevel = "unknown"; switch (pi.protectionLevel) { case PermissionInfo.PROTECTION_DANGEROUS: protLevel = "dangerous"; break; case PermissionInfo.PROTECTION_NORMAL: protLevel = "normal"; break; case PermissionInfo.PROTECTION_SIGNATURE: protLevel = "signature"; break; case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM: protLevel = "signatureOrSystem"; break; } System.out.println(prefix + " protectionLevel:" + protLevel); } } } if (summary) { System.out.println(""); } } }