summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/permission/utils/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/packageinstaller/permission/utils/Utils.java')
-rw-r--r--src/com/android/packageinstaller/permission/utils/Utils.java70
1 files changed, 58 insertions, 12 deletions
diff --git a/src/com/android/packageinstaller/permission/utils/Utils.java b/src/com/android/packageinstaller/permission/utils/Utils.java
index 856826d5..1cd984b1 100644
--- a/src/com/android/packageinstaller/permission/utils/Utils.java
+++ b/src/com/android/packageinstaller/permission/utils/Utils.java
@@ -25,9 +25,26 @@ import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
+import com.android.packageinstaller.permission.model.AppPermissionGroup;
+import com.android.packageinstaller.permission.model.PermissionApps.PermissionApp;
+
public class Utils {
+
private static final String LOG_TAG = "Utils";
+ public static final String OS_PKG = "android";
+
+ public static final String[] MODERN_PERMISSION_GROUPS = {
+ Manifest.permission_group.CALENDAR,
+ Manifest.permission_group.CAMERA,
+ Manifest.permission_group.CONTACTS,
+ Manifest.permission_group.LOCATION,
+ Manifest.permission_group.SENSORS,
+ Manifest.permission_group.SMS,
+ Manifest.permission_group.PHONE,
+ Manifest.permission_group.MICROPHONE,
+ };
+
private Utils() {
/* do nothing - hide constructor */
}
@@ -42,22 +59,51 @@ public class Utils {
}
public static boolean isModernPermissionGroup(String name) {
- switch (name) {
- case Manifest.permission_group.CALENDAR:
- case Manifest.permission_group.CAMERA:
- case Manifest.permission_group.CONTACTS:
- case Manifest.permission_group.LOCATION:
- case Manifest.permission_group.SENSORS:
- case Manifest.permission_group.SMS:
- case Manifest.permission_group.PHONE:
- case Manifest.permission_group.MICROPHONE: {
+ for (String modernGroup : MODERN_PERMISSION_GROUPS) {
+ if (modernGroup.equals(name)) {
return true;
}
+ }
+ return false;
+ }
- default: {
- return false;
- }
+ public static boolean shouldShowPermission(AppPermissionGroup group, boolean showLegacy) {
+ // We currently will not show permissions fixed by the system.
+ // which is what the system does for system components.
+ if (group.isSystemFixed()) {
+ return false;
+ }
+
+ // Yes this is possible. We have leftover permissions that
+ // are not in the final groups and we want to get rid of,
+ // therefore we do not have app ops for legacy support.
+ if (!group.hasRuntimePermission() && !group.hasAppOpPermission()) {
+ return false;
+ }
+
+ final boolean isPlatformPermission = group.getDeclaringPackage().equals(OS_PKG);
+ // Show legacy permissions only if the user chose that.
+ if (isPlatformPermission && !showLegacy
+ && !Utils.isModernPermissionGroup(group.getName())) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean shouldShowPermission(PermissionApp app) {
+ // We currently will not show permissions fixed by the system
+ // which is what the system does for system components.
+ if (app.isSystemFixed()) {
+ return false;
+ }
+
+ // Yes this is possible. We have leftover permissions that
+ // are not in the final groups and we want to get rid of,
+ // therefore we do not have app ops for legacy support.
+ if (!app.hasRuntimePermissions() && !app.hasAppOpPermissions()) {
+ return false;
}
+ return true;
}
public static Drawable applyTint(Context context, Drawable icon, int attr) {