summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShijian Li <shijianli@google.com>2017-01-19 14:34:42 (GMT)
committerShijian Li <shijianli@google.com>2017-01-19 21:59:33 (GMT)
commitb8e4193e57bcaca51b08a88f3a67ef1d0641b75a (patch)
tree256bc5b059b7e4e09d248c4633e9a47c72f7478b
parent18f598e2a2d3b0398d3eeec3a0a026dd7c882c6d (diff)
downloadandroid_packages_apps_PackageInstaller-b8e4193e57bcaca51b08a88f3a67ef1d0641b75a.zip
android_packages_apps_PackageInstaller-b8e4193e57bcaca51b08a88f3a67ef1d0641b75a.tar.gz
android_packages_apps_PackageInstaller-b8e4193e57bcaca51b08a88f3a67ef1d0641b75a.tar.bz2
Partial cherry-pick changes on permission model change.
Meanwhile, aligned with handheld logic that revoking individually controlled permission is marked as user fixed. The original commit id I1d6cbc478c789e7680f41b92b9f3fa2504576ecd. Test: Manual test on a local build. Bug: 34440353 Change-Id: Ie3bb75225246eefef954926f94295181f4daebd0
-rw-r--r--src/com/android/packageinstaller/permission/model/AppPermissionGroup.java14
-rw-r--r--src/com/android/packageinstaller/permission/model/AppPermissions.java43
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java2
3 files changed, 26 insertions, 33 deletions
diff --git a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
index a660116..5a1a9d6 100644
--- a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
+++ b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
@@ -353,7 +353,7 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
// no longer has it fixed in a denied state.
if (permission.isUserFixed() || permission.isUserSet()) {
permission.setUserFixed(false);
- permission.setUserSet(true);
+ permission.setUserSet(false);
mPackageManager.updatePermissionFlags(permission.getName(),
mPackageInfo.packageName,
PackageManager.FLAG_PERMISSION_USER_FIXED
@@ -538,11 +538,11 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
final int permissionCount = mPermissions.size();
for (int i = 0; i < permissionCount; i++) {
Permission permission = mPermissions.valueAt(i);
- if (!permission.isUserFixed()) {
- return false;
+ if (permission.isUserFixed()) {
+ return true;
}
}
- return true;
+ return false;
}
public boolean isPolicyFixed() {
@@ -560,11 +560,11 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
final int permissionCount = mPermissions.size();
for (int i = 0; i < permissionCount; i++) {
Permission permission = mPermissions.valueAt(i);
- if (!permission.isUserSet()) {
- return false;
+ if (permission.isUserSet()) {
+ return true;
}
}
- return true;
+ return false;
}
public boolean isSystemFixed() {
diff --git a/src/com/android/packageinstaller/permission/model/AppPermissions.java b/src/com/android/packageinstaller/permission/model/AppPermissions.java
index 38f35f9..099e5b0 100644
--- a/src/com/android/packageinstaller/permission/model/AppPermissions.java
+++ b/src/com/android/packageinstaller/permission/model/AppPermissions.java
@@ -48,11 +48,11 @@ public final class AppPermissions {
private PackageInfo mPackageInfo;
- public AppPermissions(Context context, PackageInfo packageInfo, String[] permissions,
+ public AppPermissions(Context context, PackageInfo packageInfo, String[] filterPermissions,
boolean sortGroups, Runnable onErrorCallback) {
mContext = context;
mPackageInfo = packageInfo;
- mFilterPermissions = permissions;
+ mFilterPermissions = filterPermissions;
mAppLabel = BidiFormatter.getInstance().unicodeWrap(
packageInfo.applicationInfo.loadSafeLabel(
context.getPackageManager()).toString());
@@ -122,34 +122,13 @@ public final class AppPermissions {
if (!filterPermission.equals(requestedPerm)) {
continue;
}
-
- if (hasGroupForPermission(requestedPerm)) {
- break;
- }
-
- AppPermissionGroup group = AppPermissionGroup.create(mContext,
- mPackageInfo, requestedPerm);
- if (group == null) {
- break;
- }
-
- mGroups.add(group);
+ addPermissionGroupIfNeeded(requestedPerm);
break;
}
}
} else {
for (String requestedPerm : mPackageInfo.requestedPermissions) {
- if (hasGroupForPermission(requestedPerm)) {
- continue;
- }
-
- AppPermissionGroup group = AppPermissionGroup.create(mContext,
- mPackageInfo, requestedPerm);
- if (group == null) {
- continue;
- }
-
- mGroups.add(group);
+ addPermissionGroupIfNeeded(requestedPerm);
}
}
@@ -163,6 +142,20 @@ public final class AppPermissions {
}
}
+ private void addPermissionGroupIfNeeded(String permission) {
+ if (hasGroupForPermission(permission)) {
+ return;
+ }
+
+ AppPermissionGroup group = AppPermissionGroup.create(mContext,
+ mPackageInfo, permission);
+ if (group == null) {
+ return;
+ }
+
+ mGroups.add(group);
+ }
+
private boolean hasGroupForPermission(String permission) {
for (AppPermissionGroup group : mGroups) {
if (group.hasPermission(permission)) {
diff --git a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
index 9ad5253..3161567 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
@@ -210,7 +210,7 @@ public final class AppPermissionsFragmentWear extends PreferenceFragment {
if((Boolean) newVal) {
group.grantRuntimePermissions(false, new String[]{ perm.name });
} else {
- group.revokeRuntimePermissions(false, new String[]{ perm.name });
+ group.revokeRuntimePermissions(true, new String[]{ perm.name });
}
return true;
});