use of android.content.pm.PermissionInfo in project android_frameworks_base by crdroidandroid.
the class PackageManagerShellCommand method doListPermissions.
private void doListPermissions(ArrayList<String> groupList, boolean groups, boolean labels, boolean summary, int startProtectionLevel, int endProtectionLevel) throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
final int groupCount = groupList.size();
for (int i = 0; i < groupCount; i++) {
String groupName = groupList.get(i);
String prefix = "";
if (groups) {
if (i > 0) {
pw.println("");
}
if (groupName != null) {
PermissionGroupInfo pgi = mInterface.getPermissionGroupInfo(groupName, 0);
if (summary) {
Resources res = getResources(pgi);
if (res != null) {
pw.print(loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel) + ": ");
} else {
pw.print(pgi.name + ": ");
}
} else {
pw.println((labels ? "+ " : "") + "group:" + pgi.name);
if (labels) {
pw.println(" package:" + pgi.packageName);
Resources res = getResources(pgi);
if (res != null) {
pw.println(" label:" + loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel));
pw.println(" description:" + loadText(pgi, pgi.descriptionRes, pgi.nonLocalizedDescription));
}
}
}
} else {
pw.println(((labels && !summary) ? "+ " : "") + "ungrouped:");
}
prefix = " ";
}
List<PermissionInfo> ps = mInterface.queryPermissionsByGroup(groupList.get(i), 0).getList();
final 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 {
pw.print(", ");
}
Resources res = getResources(pi);
if (res != null) {
pw.print(loadText(pi, pi.labelRes, pi.nonLocalizedLabel));
} else {
pw.print(pi.name);
}
} else {
pw.println(prefix + (labels ? "+ " : "") + "permission:" + pi.name);
if (labels) {
pw.println(prefix + " package:" + pi.packageName);
Resources res = getResources(pi);
if (res != null) {
pw.println(prefix + " label:" + loadText(pi, pi.labelRes, pi.nonLocalizedLabel));
pw.println(prefix + " description:" + loadText(pi, pi.descriptionRes, pi.nonLocalizedDescription));
}
pw.println(prefix + " protectionLevel:" + PermissionInfo.protectionToString(pi.protectionLevel));
}
}
}
if (summary) {
pw.println("");
}
}
}
use of android.content.pm.PermissionInfo in project VirtualApp by asLody.
the class PackageParserEx method generatePermissionInfo.
public static PermissionInfo generatePermissionInfo(VPackage.PermissionComponent p, int flags) {
if (p == null)
return null;
if ((flags & PackageManager.GET_META_DATA) == 0) {
return p.info;
}
PermissionInfo pi = new PermissionInfo(p.info);
pi.metaData = p.metaData;
return pi;
}
use of android.content.pm.PermissionInfo in project SmartAndroidSource by jaychou2012.
the class AppInfo method getUsesPermission.
/**
* Get the App's All use Permission
*
* @param packageName
* @return the use Permissions by ArrayList<MyPermission> permissions
*/
public ArrayList<MyPermission> getUsesPermission(String packageName) {
ArrayList<MyPermission> myPerms = new ArrayList<MyPermission>();
try {
PackageManager packageManager = c.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
String[] usesPermissionsArray = packageInfo.requestedPermissions;
for (int i = 0; i < usesPermissionsArray.length; i++) {
MyPermission permi = new MyPermission();
// �õ�ÿ��Ȩ������,��:android.permission.INTERNET
String usesPermissionName = usesPermissionsArray[i];
permi.setPermissionName(usesPermissionName);
System.out.println("usesPermissionName=" + usesPermissionName);
// ͨ��usesPermissionName��ȡ��Ȩ����ϸ��Ϣ
PermissionInfo permissionInfo = packageManager.getPermissionInfo(usesPermissionName, 0);
// ��ø�Ȩ�������ĸ�Ȩ����,��:����ͨ��
PermissionGroupInfo permissionGroupInfo = packageManager.getPermissionGroupInfo(permissionInfo.group, 0);
permi.setPermissionGroup(permissionGroupInfo.loadLabel(packageManager).toString());
System.out.println("permissionGroup=" + permissionGroupInfo.loadLabel(packageManager).toString());
// ��ȡ��Ȩ�ı�ǩ��Ϣ,����:��ȫ���������Ȩ��
String permissionLabel = permissionInfo.loadLabel(packageManager).toString();
permi.setPermissionLabel(permissionLabel);
System.out.println("permissionLabel=" + permissionLabel);
// ��ȡ��Ȩ����ϸ������Ϣ,����:�����Ӧ�ô����������ֺ�ʹ���Զ�������Э��
// �����������ijЩӦ���ṩ���������������ݵ�;��,���Ӧ�������Ȩ������������������.
String permissionDescription = permissionInfo.loadDescription(packageManager).toString();
permi.setPermissionDescription(permissionDescription);
System.out.println("permissionDescription=" + permissionDescription);
System.out.println("===========================================");
myPerms.add(permi);
}
return myPerms;
} catch (Exception e) {
}
return myPerms;
}
use of android.content.pm.PermissionInfo in project platform_frameworks_base by android.
the class PackageManagerShellCommand method doListPermissions.
private void doListPermissions(ArrayList<String> groupList, boolean groups, boolean labels, boolean summary, int startProtectionLevel, int endProtectionLevel) throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
final int groupCount = groupList.size();
for (int i = 0; i < groupCount; i++) {
String groupName = groupList.get(i);
String prefix = "";
if (groups) {
if (i > 0) {
pw.println("");
}
if (groupName != null) {
PermissionGroupInfo pgi = mInterface.getPermissionGroupInfo(groupName, 0);
if (summary) {
Resources res = getResources(pgi);
if (res != null) {
pw.print(loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel) + ": ");
} else {
pw.print(pgi.name + ": ");
}
} else {
pw.println((labels ? "+ " : "") + "group:" + pgi.name);
if (labels) {
pw.println(" package:" + pgi.packageName);
Resources res = getResources(pgi);
if (res != null) {
pw.println(" label:" + loadText(pgi, pgi.labelRes, pgi.nonLocalizedLabel));
pw.println(" description:" + loadText(pgi, pgi.descriptionRes, pgi.nonLocalizedDescription));
}
}
}
} else {
pw.println(((labels && !summary) ? "+ " : "") + "ungrouped:");
}
prefix = " ";
}
List<PermissionInfo> ps = mInterface.queryPermissionsByGroup(groupList.get(i), 0).getList();
final 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 {
pw.print(", ");
}
Resources res = getResources(pi);
if (res != null) {
pw.print(loadText(pi, pi.labelRes, pi.nonLocalizedLabel));
} else {
pw.print(pi.name);
}
} else {
pw.println(prefix + (labels ? "+ " : "") + "permission:" + pi.name);
if (labels) {
pw.println(prefix + " package:" + pi.packageName);
Resources res = getResources(pi);
if (res != null) {
pw.println(prefix + " label:" + loadText(pi, pi.labelRes, pi.nonLocalizedLabel));
pw.println(prefix + " description:" + loadText(pi, pi.descriptionRes, pi.nonLocalizedDescription));
}
pw.println(prefix + " protectionLevel:" + PermissionInfo.protectionToString(pi.protectionLevel));
}
}
}
if (summary) {
pw.println("");
}
}
}
use of android.content.pm.PermissionInfo in project platform_frameworks_base by android.
the class Settings method writePermissionLPr.
void writePermissionLPr(XmlSerializer serializer, BasePermission bp) throws XmlPullParserException, java.io.IOException {
if (bp.sourcePackage != null) {
serializer.startTag(null, TAG_ITEM);
serializer.attribute(null, ATTR_NAME, bp.name);
serializer.attribute(null, "package", bp.sourcePackage);
if (bp.protectionLevel != PermissionInfo.PROTECTION_NORMAL) {
serializer.attribute(null, "protection", Integer.toString(bp.protectionLevel));
}
if (PackageManagerService.DEBUG_SETTINGS)
Log.v(PackageManagerService.TAG, "Writing perm: name=" + bp.name + " type=" + bp.type);
if (bp.type == BasePermission.TYPE_DYNAMIC) {
final PermissionInfo pi = bp.perm != null ? bp.perm.info : bp.pendingInfo;
if (pi != null) {
serializer.attribute(null, "type", "dynamic");
if (pi.icon != 0) {
serializer.attribute(null, "icon", Integer.toString(pi.icon));
}
if (pi.nonLocalizedLabel != null) {
serializer.attribute(null, "label", pi.nonLocalizedLabel.toString());
}
}
}
serializer.endTag(null, TAG_ITEM);
}
}
Aggregations