summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-03-25 21:32:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-03-25 21:32:45 +0000
commitc1905339bcb67c11380a366c5ac98da82e6e9b7b (patch)
tree22689c0eaa40827e8a67003b0b92292839edb1b6 /core/java/android
parentb07220c8ef82511a2e1de670d026171b99891155 (diff)
parenta5043ed7eac5dccf7ec58b9f7095fda3992951a4 (diff)
Merge "AppSecurityPermissions: Modify isDisplayablePermission" into jb-mr2-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/widget/AppSecurityPermissions.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java
index 9eb458e77636..7c961bd40c90 100644
--- a/core/java/android/widget/AppSecurityPermissions.java
+++ b/core/java/android/widget/AppSecurityPermissions.java
@@ -507,16 +507,25 @@ public class AppSecurityPermissions {
private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags,
int existingReqFlags) {
final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
- // Dangerous and normal permissions are always shown to the user.
- if (base == PermissionInfo.PROTECTION_DANGEROUS ||
- base == PermissionInfo.PROTECTION_NORMAL) {
+ final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL);
+ final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS);
+ 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;
}
+
// 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
// already granted, they will not be granted as part of the install.
- if ((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0
- && (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
+ if (isDevelopment && wasGranted) {
if (localLOGV) Log.i(TAG, "Special perm " + pInfo.name
+ ": protlevel=0x" + Integer.toHexString(pInfo.protectionLevel));
return true;