I'm trying to adapt my code for Android Marshmallow.
I wrote a function to check if a permission is revocable or not (PROTECTION_NORMAL
and PROTECTION_SIGNATURE
are granted upon install).
Running on API-22, Manifest.permission.READ_PHONE_STATE
returns protectionLevel=PermissionInfo.PROTECTION_DANGEROUS
, which is what I expected.
But on API-22, Manifest.permission.INSTALL_SHORTCUT
also returns protectionLevel=PermissionInfo.PROTECTION_DANGEROUS
, which is wrong from the documentation.
How does that happen? What's wrong with my code:
final PermissionInfo permissionInfo = packageManager.getPermissionInfo(permission, 0);
switch (permissionInfo.protectionLevel) {
case PermissionInfo.PROTECTION_NORMAL:
case PermissionInfo.PROTECTION_SIGNATURE:
return false;
default:
return true;
}