summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/packageinstaller/permission/model/AppPermissionGroup.java22
-rw-r--r--src/com/android/packageinstaller/permission/model/Permission.java4
-rw-r--r--src/com/android/packageinstaller/permission/model/PermissionApps.java17
-rw-r--r--src/com/android/packageinstaller/permission/ui/AppPermissionsFragment.java11
-rw-r--r--src/com/android/packageinstaller/permission/ui/PermissionAppsFragment.java11
5 files changed, 48 insertions, 17 deletions
diff --git a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
index 6bd15aff..8e86678d 100644
--- a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
+++ b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
@@ -207,6 +207,18 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
return mAppSupportsRuntimePermissions;
}
+
+ public boolean hasGrantedByDefaultPermission() {
+ final int permissionCount = mPermissions.size();
+ for (int i = 0; i < permissionCount; i++) {
+ Permission permission = mPermissions.valueAt(i);
+ if (permission.isGrantedByDefault()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public boolean hasAppOpPermission() {
final int permissionCount = mPermissions.size();
for (int i = 0; i < permissionCount; i++) {
@@ -258,15 +270,15 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
for (int i = 0; i < permissionCount; i++) {
Permission permission = mPermissions.valueAt(i);
if (mAppSupportsRuntimePermissions) {
- if (!permission.isGranted()) {
- return false;
+ if (permission.isGranted()) {
+ return true;
}
} else if (permission.isGranted() && permission.getAppOp()
- != AppOpsManager.OP_NONE && !permission.isAppOpAllowed()) {
- return false;
+ != AppOpsManager.OP_NONE && permission.isAppOpAllowed()) {
+ return true;
}
}
- return true;
+ return false;
}
public boolean grantRuntimePermissions(boolean fixedByTheUser) {
diff --git a/src/com/android/packageinstaller/permission/model/Permission.java b/src/com/android/packageinstaller/permission/model/Permission.java
index da234bdb..1be4e75b 100644
--- a/src/com/android/packageinstaller/permission/model/Permission.java
+++ b/src/com/android/packageinstaller/permission/model/Permission.java
@@ -88,6 +88,10 @@ public final class Permission {
return (mFlags & PackageManager.FLAG_PERMISSION_USER_SET) != 0;
}
+ public boolean isGrantedByDefault() {
+ return (mFlags & PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT) != 0;
+ }
+
public void setUserSet(boolean userSet) {
if (userSet) {
mFlags |= PackageManager.FLAG_PERMISSION_USER_SET;
diff --git a/src/com/android/packageinstaller/permission/model/PermissionApps.java b/src/com/android/packageinstaller/permission/model/PermissionApps.java
index b8ba650d..8c537155 100644
--- a/src/com/android/packageinstaller/permission/model/PermissionApps.java
+++ b/src/com/android/packageinstaller/permission/model/PermissionApps.java
@@ -159,16 +159,21 @@ public class PermissionApps {
for (int j = 0; j < app.requestedPermissions.length; j++) {
String requestedPerm = app.requestedPermissions[j];
- boolean requestsPermissionInGroup = false;
+ PermissionInfo requestedPermissionInfo = null;
for (PermissionInfo groupPermInfo : groupPermInfos) {
- if (groupPermInfo.name.equals(requestedPerm)) {
- requestsPermissionInGroup = true;
+ if (requestedPerm.equals(groupPermInfo.name)) {
+ requestedPermissionInfo = groupPermInfo;
break;
}
}
- if (!requestsPermissionInGroup) {
+ if (requestedPermissionInfo == null) {
+ continue;
+ }
+
+ if (requestedPermissionInfo.protectionLevel
+ != PermissionInfo.PROTECTION_DANGEROUS) {
continue;
}
@@ -319,6 +324,10 @@ public class PermissionApps {
return mAppPermissionGroup.isSystemFixed();
}
+ public boolean hasGrantedByDefaultPermissions() {
+ return mAppPermissionGroup.hasGrantedByDefaultPermission();
+ }
+
public boolean hasRuntimePermissions() {
return mAppPermissionGroup.hasRuntimePermission();
}
diff --git a/src/com/android/packageinstaller/permission/ui/AppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/AppPermissionsFragment.java
index 39f4cbaf..92ad7c8a 100644
--- a/src/com/android/packageinstaller/permission/ui/AppPermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/AppPermissionsFragment.java
@@ -213,6 +213,9 @@ public final class AppPermissionsFragment extends SettingsWithHeader
preference.setIcon(Utils.applyTint(getContext(), icon,
android.R.attr.colorControlNormal));
preference.setTitle(group.getLabel());
+ if (group.isPolicyFixed()) {
+ preference.setSummary(getString(R.string.permission_summary_enforced_by_policy));
+ }
preference.setPersistent(false);
preference.setEnabled(!group.isPolicyFixed());
preference.setChecked(group.areRuntimePermissionsGranted());
@@ -264,10 +267,10 @@ public final class AppPermissionsFragment extends SettingsWithHeader
if (newValue == Boolean.TRUE) {
group.grantRuntimePermissions(false);
} else {
- final boolean system = group.getApp().applicationInfo.isSystemApp();
- if (system || (!group.hasRuntimePermission() && !mHasConfirmedRevoke)) {
+ final boolean grantedByDefault = group.hasGrantedByDefaultPermission();
+ if (grantedByDefault || (!group.hasRuntimePermission() && !mHasConfirmedRevoke)) {
new AlertDialog.Builder(getContext())
- .setMessage(system ? R.string.system_warning
+ .setMessage(grantedByDefault ? R.string.system_warning
: R.string.old_sdk_deny_warning)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.grant_dialog_button_deny,
@@ -276,7 +279,7 @@ public final class AppPermissionsFragment extends SettingsWithHeader
public void onClick(DialogInterface dialog, int which) {
((SwitchPreference) preference).setChecked(false);
group.revokeRuntimePermissions(false);
- if (!system) {
+ if (!grantedByDefault) {
mHasConfirmedRevoke = true;
}
}
diff --git a/src/com/android/packageinstaller/permission/ui/PermissionAppsFragment.java b/src/com/android/packageinstaller/permission/ui/PermissionAppsFragment.java
index f749089b..d0fff16c 100644
--- a/src/com/android/packageinstaller/permission/ui/PermissionAppsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/PermissionAppsFragment.java
@@ -189,6 +189,9 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
pref.setKey(app.getKey());
pref.setIcon(app.getIcon());
pref.setTitle(app.getLabel());
+ if (app.isPolicyFixed()) {
+ pref.setSummary(getString(R.string.permission_summary_enforced_by_policy));
+ }
pref.setPersistent(false);
pref.setEnabled(!app.isPolicyFixed());
preferences.addPreference(pref);
@@ -214,10 +217,10 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
if (newValue == Boolean.TRUE) {
app.grantRuntimePermissions();
} else {
- final boolean system = app.getAppInfo().isSystemApp();
- if (system || (!app.hasRuntimePermissions() && !mHasConfirmedRevoke)) {
+ final boolean grantedByDefault = app.hasGrantedByDefaultPermissions();
+ if (grantedByDefault || (!app.hasRuntimePermissions() && !mHasConfirmedRevoke)) {
new AlertDialog.Builder(getContext())
- .setMessage(system ? R.string.system_warning
+ .setMessage(grantedByDefault ? R.string.system_warning
: R.string.old_sdk_deny_warning)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.grant_dialog_button_deny,
@@ -226,7 +229,7 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
public void onClick(DialogInterface dialog, int which) {
((SwitchPreference) preference).setChecked(false);
app.revokeRuntimePermissions();
- if (!system) {
+ if (!grantedByDefault) {
mHasConfirmedRevoke = true;
}
}