summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShijian Li <shijianli@google.com>2017-01-24 02:21:14 (GMT)
committerandroid-build-merger <android-build-merger@google.com>2017-01-24 02:21:14 (GMT)
commit656c1b183d844f5a4956fcd07fe7bcf6e1c24762 (patch)
tree134ca74a133109ff5788f37fc6bddffddb68ece9
parent60242bde6da9f399dfcf29e2bd65e61aca3c1fe0 (diff)
parent275897a5a576e8d16ebc245c0a299c5d9448a5a6 (diff)
downloadandroid_packages_apps_PackageInstaller-656c1b183d844f5a4956fcd07fe7bcf6e1c24762.zip
android_packages_apps_PackageInstaller-656c1b183d844f5a4956fcd07fe7bcf6e1c24762.tar.gz
android_packages_apps_PackageInstaller-656c1b183d844f5a4956fcd07fe7bcf6e1c24762.tar.bz2
Set USER_FIXED for all non-granted permissions as long as one in the group is changed.
am: 275897a5a5 Change-Id: Id4ddf57e660e0ea339f8bafa1aa02dcce0c0c894
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java23
-rw-r--r--src/com/android/packageinstaller/permission/utils/ArrayUtils.java18
2 files changed, 41 insertions, 0 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
index 3161567..4ef2742 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
@@ -42,6 +42,7 @@ import com.android.packageinstaller.permission.model.AppPermissions;
import com.android.packageinstaller.permission.model.Permission;
import com.android.packageinstaller.permission.utils.LocationUtils;
import com.android.packageinstaller.permission.utils.SafetyNetLogger;
+import com.android.packageinstaller.permission.utils.ArrayUtils;
import com.android.packageinstaller.permission.utils.Utils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -212,6 +213,28 @@ public final class AppPermissionsFragmentWear extends PreferenceFragment {
} else {
group.revokeRuntimePermissions(true, new String[]{ perm.name });
}
+
+ if (Utils.areGroupPermissionsIndividuallyControlled(getContext(), group.getName())
+ && group.hasRuntimePermission()) {
+ // As long as one permission is changed in individually controlled group
+ // permissions, we will set user_fixed for non-granted permissions in that group.
+ // This avoids the system to automatically grant runtime permissions based on the
+ // fact that one of dangerous permission in that group is already granted.
+ String[] revokedPermissionsToFix = null;
+ final int permissionCount = group.getPermissions().size();
+
+ for (int i = 0; i < permissionCount; i++) {
+ Permission current = group.getPermissions().get(i);
+ if (!current.isGranted() && !current.isUserFixed()) {
+ revokedPermissionsToFix = ArrayUtils.appendString(
+ revokedPermissionsToFix, current.getName());
+ }
+ }
+
+ if (revokedPermissionsToFix != null) {
+ group.revokeRuntimePermissions(true, revokedPermissionsToFix);
+ }
+ }
return true;
});
return pref;
diff --git a/src/com/android/packageinstaller/permission/utils/ArrayUtils.java b/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
index 4b7a394..2af641b 100644
--- a/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
+++ b/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
@@ -16,6 +16,8 @@
package com.android.packageinstaller.permission.utils;
+import android.text.TextUtils;
+
import java.util.Objects;
public final class ArrayUtils {
@@ -42,4 +44,20 @@ public final class ArrayUtils {
}
return -1;
}
+
+ public static String[] appendString(String[] cur, String val) {
+ if (cur == null) {
+ return new String[] { val };
+ }
+ final int N = cur.length;
+ for (int i = 0; i < N; i++) {
+ if (TextUtils.equals(cur[i], val)) {
+ return cur;
+ }
+ }
+ String[] ret = new String[N + 1];
+ System.arraycopy(cur, 0, ret, 0, N);
+ ret[N] = val;
+ return ret;
+ }
}