summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
+ }
}