summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShijian Li <shijianli@google.com>2017-01-20 01:41:13 (GMT)
committerandroid-build-merger <android-build-merger@google.com>2017-01-20 01:41:13 (GMT)
commit3c17d8a8712aac95528bbb91e84d7a190a17c0a7 (patch)
treeec9fc62a2db32624cb1283461cdbb7fb8ca19fce
parentd0d2f348e5cf92fca5d4dcf566dcfad323b3bbae (diff)
parentb8e4193e57bcaca51b08a88f3a67ef1d0641b75a (diff)
downloadandroid_packages_apps_PackageInstaller-3c17d8a8712aac95528bbb91e84d7a190a17c0a7.zip
android_packages_apps_PackageInstaller-3c17d8a8712aac95528bbb91e84d7a190a17c0a7.tar.gz
android_packages_apps_PackageInstaller-3c17d8a8712aac95528bbb91e84d7a190a17c0a7.tar.bz2
Partial cherry-pick changes on permission model change.
am: b8e4193e57 Change-Id: I06ddf41de29c70df865434685ee7cb652cfddbbd
-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;
});