diff options
author | 2024-11-01 12:36:16 +0000 | |
---|---|---|
committer | 2024-11-01 12:36:16 +0000 | |
commit | b5a2cfc3b9ebe0d3721bf62aff76f366e0e31cf1 (patch) | |
tree | a100ecd1f3ce8b9dbd73ad85b85c8d0ff06d16b1 /PermissionController/role-controller/java | |
parent | 2258d6daf8744e3e7598bd34d1b76c657b5bf58e (diff) |
Revert "Add Cross-user role support xml parsing"
This reverts commit 2258d6daf8744e3e7598bd34d1b76c657b5bf58e.
Reason for revert: Likely culprit for b/376805931 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Change-Id: Iffb5d707c1505e482dfa1f10ed543a2840611262
Diffstat (limited to 'PermissionController/role-controller/java')
2 files changed, 28 insertions, 98 deletions
diff --git a/PermissionController/role-controller/java/com/android/role/controller/model/Role.java b/PermissionController/role-controller/java/com/android/role/controller/model/Role.java index 570ef034a..2f2431ece 100644 --- a/PermissionController/role-controller/java/com/android/role/controller/model/Role.java +++ b/PermissionController/role-controller/java/com/android/role/controller/model/Role.java @@ -38,7 +38,6 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; -import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; @@ -50,8 +49,6 @@ import com.android.role.controller.util.PackageUtils; import com.android.role.controller.util.RoleManagerCompat; import com.android.role.controller.util.UserUtils; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -86,27 +83,6 @@ public class Role { private static final String CERTIFICATE_SEPARATOR = ":"; - @Retention(RetentionPolicy.SOURCE) - @IntDef({ - EXCLUSIVITY_NONE, - EXCLUSIVITY_USER, - EXCLUSIVITY_PROFILE_GROUP - }) - public @interface Exclusivity {} - - /** - * Does not enforce any exclusivity, which means multiple apps may hold this role in a user. - */ - public static final int EXCLUSIVITY_NONE = 0; - - /** Enforces exclusivity within one user. */ - public static final int EXCLUSIVITY_USER = 1; - - /** - * Enforces exclusivity across all users (including profile users) in the same profile group. - */ - public static final int EXCLUSIVITY_PROFILE_GROUP = 2; - /** * The name of this role. Must be unique. */ @@ -134,10 +110,9 @@ public class Role { private final int mDescriptionResource; /** - * The exclusivity of this role, i.e. whether this role allows multiple holders, or allows at - * most one holder within a user or a profile group. + * Whether this role is exclusive, i.e. allows at most one holder. */ - private final int mExclusivity; + private final boolean mExclusive; /** * Whether this role should fall back to the default holder. @@ -211,8 +186,8 @@ public class Role { /** * Whether the UI for this role will show the "None" item. Only valid if this role is - * {@link #isExclusive()}, and {@link #getFallbackHolder(Context)} should - * also return empty to allow actually selecting "None". + * {@link #mExclusive exclusive}, and {@link #getFallbackHolder(Context)} should also return + * empty to allow actually selecting "None". */ private final boolean mShowNone; @@ -266,14 +241,14 @@ public class Role { public Role(@NonNull String name, boolean allowBypassingQualification, @Nullable RoleBehavior behavior, @Nullable String defaultHoldersResourceName, - @StringRes int descriptionResource, @Exclusivity int exclusivity, - boolean fallBackToDefaultHolder, @Nullable Supplier<Boolean> featureFlag, - @StringRes int labelResource, int maxSdkVersion, int minSdkVersion, - boolean onlyGrantWhenAdded, boolean overrideUserWhenGranting, - @StringRes int requestDescriptionResource, @StringRes int requestTitleResource, - boolean requestable, @StringRes int searchKeywordsResource, - @StringRes int shortLabelResource, boolean showNone, boolean statik, boolean systemOnly, - boolean visible, @NonNull List<RequiredComponent> requiredComponents, + @StringRes int descriptionResource, boolean exclusive, boolean fallBackToDefaultHolder, + @Nullable Supplier<Boolean> featureFlag, @StringRes int labelResource, + int maxSdkVersion, int minSdkVersion, boolean onlyGrantWhenAdded, + boolean overrideUserWhenGranting, @StringRes int requestDescriptionResource, + @StringRes int requestTitleResource, boolean requestable, + @StringRes int searchKeywordsResource, @StringRes int shortLabelResource, + boolean showNone, boolean statik, boolean systemOnly, boolean visible, + @NonNull List<RequiredComponent> requiredComponents, @NonNull List<Permission> permissions, @NonNull List<Permission> appOpPermissions, @NonNull List<AppOp> appOps, @NonNull List<PreferredActivity> preferredActivities, @Nullable String uiBehaviorName) { @@ -282,7 +257,7 @@ public class Role { mBehavior = behavior; mDefaultHoldersResourceName = defaultHoldersResourceName; mDescriptionResource = descriptionResource; - mExclusivity = exclusivity; + mExclusive = exclusive; mFallBackToDefaultHolder = fallBackToDefaultHolder; mFeatureFlag = featureFlag; mLabelResource = labelResource; @@ -323,13 +298,7 @@ public class Role { } public boolean isExclusive() { - // TODO(b/373390494): Allow RoleBehavior to override this getExclusivity - return mExclusivity != EXCLUSIVITY_NONE; - } - - public int getExclusivity() { - // TODO(b/373390494): Allow RoleBehavior to override this - return mExclusivity; + return mExclusive; } @Nullable @@ -384,8 +353,6 @@ public class Role { * @see #mShowNone */ public boolean shouldShowNone() { - // TODO(b/373390494): Ensure RoleBehavior override doesn't conflict with this. - // mShowNone can only be true if isExclusive=true return mShowNone; } @@ -1074,7 +1041,7 @@ public class Role { */ @Nullable public Intent getRestrictionIntentAsUser(@NonNull UserHandle user, @NonNull Context context) { - if (SdkLevel.isAtLeastU() && isExclusive()) { + if (SdkLevel.isAtLeastU() && mExclusive) { UserManager userManager = context.getSystemService(UserManager.class); if (userManager.hasUserRestrictionForUser(UserManager.DISALLOW_CONFIG_DEFAULT_APPS, user)) { @@ -1137,7 +1104,7 @@ public class Role { + ", mBehavior=" + mBehavior + ", mDefaultHoldersResourceName=" + mDefaultHoldersResourceName + ", mDescriptionResource=" + mDescriptionResource - + ", mExclusivity=" + mExclusivity + + ", mExclusive=" + mExclusive + ", mFallBackToDefaultHolder=" + mFallBackToDefaultHolder + ", mFeatureFlag=" + mFeatureFlag + ", mLabelResource=" + mLabelResource diff --git a/PermissionController/role-controller/java/com/android/role/controller/model/RoleParser.java b/PermissionController/role-controller/java/com/android/role/controller/model/RoleParser.java index 3a8c90888..a0705cd5e 100644 --- a/PermissionController/role-controller/java/com/android/role/controller/model/RoleParser.java +++ b/PermissionController/role-controller/java/com/android/role/controller/model/RoleParser.java @@ -89,7 +89,6 @@ public class RoleParser { private static final String ATTRIBUTE_DEFAULT_HOLDERS = "defaultHolders"; private static final String ATTRIBUTE_DESCRIPTION = "description"; private static final String ATTRIBUTE_EXCLUSIVE = "exclusive"; - private static final String ATTRIBUTE_EXCLUSIVITY = "exclusivity"; private static final String ATTRIBUTE_FALL_BACK_TO_DEFAULT_HOLDER = "fallBackToDefaultHolder"; private static final String ATTRIBUTE_FEATURE_FLAG = "featureFlag"; private static final String ATTRIBUTE_LABEL = "label"; @@ -136,10 +135,6 @@ public class RoleParser { sModeNameToMode.put(MODE_NAME_FOREGROUND, AppOpsManager.MODE_FOREGROUND); } - private static final String EXCLUSIVITY_NONE = "none"; - private static final String EXCLUSIVITY_USER = "user"; - private static final String EXCLUSIVITY_PROFILE_GROUP = "profileGroup"; - private static final Supplier<Boolean> sFeatureFlagFallback = () -> false; private static final ArrayMap<Class<?>, Class<?>> sPrimitiveToWrapperClass = new ArrayMap<>(); @@ -418,45 +413,13 @@ public class RoleParser { shortLabelResource = 0; } - int exclusivity; - if (com.android.permission.flags.Flags.crossUserRoleEnabled()) { - String exclusivityName = requireAttributeValue(parser, ATTRIBUTE_EXCLUSIVITY, TAG_ROLE); - if (exclusivityName == null) { - skipCurrentTag(parser); - return null; - } - switch (exclusivityName) { - case EXCLUSIVITY_NONE: - exclusivity = Role.EXCLUSIVITY_NONE; - break; - case EXCLUSIVITY_USER: - exclusivity = Role.EXCLUSIVITY_USER; - break; - case EXCLUSIVITY_PROFILE_GROUP: - // TODO(b/372743073): change to isAtLeastB once available - // EXCLUSIVITY_PROFILE behavior only available for B+ - // fallback to default of EXCLUSIVITY_USER - exclusivity = SdkLevel.isAtLeastV() - ? Role.EXCLUSIVITY_PROFILE_GROUP - : Role.EXCLUSIVITY_USER; - break; - default: - throwOrLogMessage("Invalid value for \"exclusivity\" on <role>: " + name - + ", exclusivity: " + exclusivityName); - skipCurrentTag(parser); - return null; - } - } else { - Boolean exclusive = - requireAttributeBooleanValue(parser, ATTRIBUTE_EXCLUSIVE, true, TAG_ROLE); - if (exclusive == null) { - skipCurrentTag(parser); - return null; - } - exclusivity = exclusive ? Role.EXCLUSIVITY_USER : Role.EXCLUSIVITY_NONE; + Boolean exclusive = requireAttributeBooleanValue(parser, ATTRIBUTE_EXCLUSIVE, true, + TAG_ROLE); + if (exclusive == null) { + skipCurrentTag(parser); + return null; } - boolean fallBackToDefaultHolder = getAttributeBooleanValue(parser, ATTRIBUTE_FALL_BACK_TO_DEFAULT_HOLDER, false); @@ -507,7 +470,7 @@ public class RoleParser { 0); boolean showNone = getAttributeBooleanValue(parser, ATTRIBUTE_SHOW_NONE, false); - if (showNone && exclusivity == Role.EXCLUSIVITY_NONE) { + if (showNone && !exclusive) { throwOrLogMessage("showNone=\"true\" is invalid for a non-exclusive role: " + name); skipCurrentTag(parser); return null; @@ -604,12 +567,12 @@ public class RoleParser { preferredActivities = Collections.emptyList(); } return new Role(name, allowBypassingQualification, behavior, defaultHoldersResourceName, - descriptionResource, exclusivity, fallBackToDefaultHolder, featureFlag, - labelResource, maxSdkVersion, minSdkVersion, onlyGrantWhenAdded, - overrideUserWhenGranting, requestDescriptionResource, requestTitleResource, - requestable, searchKeywordsResource, shortLabelResource, showNone, statik, - systemOnly, visible, requiredComponents, permissions, appOpPermissions, appOps, - preferredActivities, uiBehaviorName); + descriptionResource, exclusive, fallBackToDefaultHolder, featureFlag, labelResource, + maxSdkVersion, minSdkVersion, onlyGrantWhenAdded, overrideUserWhenGranting, + requestDescriptionResource, requestTitleResource, requestable, + searchKeywordsResource, shortLabelResource, showNone, statik, systemOnly, visible, + requiredComponents, permissions, appOpPermissions, appOps, preferredActivities, + uiBehaviorName); } @NonNull |