Im trying to list the protection level for each permission in the selected application, for the code given below. But i do not know how to get it done.
ArrayList<String> list_permission = new ArrayList<String>();
String[] reqp = info.requestedPermissions;
if (reqp != null) {
for (i = 0; i < reqp.length; i++) {
k = i + 1;
String a = reqp[i];
if (a.contains("android.permission.")) {
String aa[] = a.split("android.permission.");
list_permission.add(aa[1]);
} else {
list_permission.add(a);
}
}
}
can anyone help me with this... just want to add the protection level in front of the permission.
You can use PackageManager class getPermissionInfo() method to get PermissionInfo object for any particular permission. PermissionInfo object has property Protection Lavel that can be used to check the protection level of any permission... You can check it against the constant defined in the PermissoinInfo class like
PROTECTION_FLAG_SYSTEM
.Like following code :
UPDATE:
To get the Protection level of
requestedPermissions
:Following line would only work on API level 16 or above:
// Get the permissions for the core android package