use of com.smartandroid.sa.entity.MyPermission 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;
}
Aggregations