Merge "AppSecurityPermissions: Modify isDisplayablePermission" into jb-mr2-dev

This commit is contained in:
Nick Kralevich
2013-03-25 21:32:45 +00:00
committed by Android (Google) Code Review

View File

@@ -507,16 +507,25 @@ public class AppSecurityPermissions {
private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags, private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags,
int existingReqFlags) { int existingReqFlags) {
final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE; final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
// Dangerous and normal permissions are always shown to the user. final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL);
if (base == PermissionInfo.PROTECTION_DANGEROUS || final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS);
base == PermissionInfo.PROTECTION_NORMAL) { final boolean isRequired =
((newReqFlags&PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 0);
final boolean isDevelopment =
((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0);
final boolean wasGranted =
((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
// Dangerous and normal permissions are always shown to the user if the permission
// is required, or it was previously granted
if ((isNormal || isDangerous) && (isRequired || wasGranted)) {
return true; return true;
} }
// Development permissions are only shown to the user if they are already // Development permissions are only shown to the user if they are already
// granted to the app -- if we are installing an app and they are not // granted to the app -- if we are installing an app and they are not
// already granted, they will not be granted as part of the install. // already granted, they will not be granted as part of the install.
if ((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0 if (isDevelopment && wasGranted) {
&& (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
if (localLOGV) Log.i(TAG, "Special perm " + pInfo.name if (localLOGV) Log.i(TAG, "Special perm " + pInfo.name
+ ": protlevel=0x" + Integer.toHexString(pInfo.protectionLevel)); + ": protlevel=0x" + Integer.toHexString(pInfo.protectionLevel));
return true; return true;