diff options
4 files changed, 29 insertions, 146 deletions
diff --git a/PermissionController/res/xml/roles.xml b/PermissionController/res/xml/roles.xml index 2f9ac3148..b067c41b5 100644 --- a/PermissionController/res/xml/roles.xml +++ b/PermissionController/res/xml/roles.xml @@ -107,7 +107,6 @@ defaultHolders="config_defaultAssistant" description="@string/role_assistant_description" exclusive="true" - exclusivity="user" fallBackToDefaultHolder="true" showNone="true" label="@string/role_assistant_label" @@ -174,7 +173,6 @@ defaultHolders="config_defaultBrowser" description="@string/role_browser_description" exclusive="true" - exclusivity="user" label="@string/role_browser_label" overrideUserWhenGranting="true" requestDescription="@string/role_browser_request_description" @@ -218,7 +216,6 @@ defaultHolders="config_defaultDialer" description="@string/role_dialer_description" exclusive="true" - exclusivity="user" fallBackToDefaultHolder="true" label="@string/role_dialer_label" overrideUserWhenGranting="true" @@ -307,7 +304,6 @@ defaultHolders="config_defaultSms" description="@string/role_sms_description" exclusive="true" - exclusivity="user" label="@string/role_sms_label" overrideUserWhenGranting="true" requestDescription="@string/role_sms_request_description" @@ -398,7 +394,6 @@ behavior="EmergencyRoleBehavior" description="@string/role_emergency_description" exclusive="true" - exclusivity="user" label="@string/role_emergency_label" overrideUserWhenGranting="true" requestDescription="@string/role_emergency_request_description" @@ -431,7 +426,6 @@ behavior="HomeRoleBehavior" description="@string/role_home_description" exclusive="true" - exclusivity="user" label="@string/role_home_label" overrideUserWhenGranting="true" requestDescription="@string/role_home_request_description" @@ -478,7 +472,6 @@ defaultHolders="config_defaultCallRedirection" description="@string/role_call_redirection_description" exclusive="true" - exclusivity="user" label="@string/role_call_redirection_label" overrideUserWhenGranting="true" requestDescription="@string/role_call_redirection_request_description" @@ -500,7 +493,6 @@ defaultHolders="config_defaultCallScreening" description="@string/role_call_screening_description" exclusive="true" - exclusivity="user" label="@string/role_call_screening_label" overrideUserWhenGranting="true" requestDescription="@string/role_call_screening_request_description" @@ -526,7 +518,6 @@ name="android.app.role.SYSTEM_GALLERY" defaultHolders="config_systemGallery" exclusive="true" - exclusivity="user" static="true" systemOnly="true" visible="false"> @@ -546,7 +537,6 @@ behavior="v31.AutomotiveRoleBehavior" defaultHolders="config_systemAutomotiveCluster" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -564,7 +554,6 @@ behavior="v31.CompanionDeviceWatchRoleBehavior" description="@string/role_watch_description" exclusive="false" - exclusivity="none" minSdkVersion="31" systemOnly="false" visible="false"> @@ -593,7 +582,6 @@ name="android.app.role.SYSTEM_AUTOMOTIVE_PROJECTION" defaultHolders="config_systemAutomotiveProjection" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -631,7 +619,6 @@ behavior="v31.SystemShellRoleBehavior" defaultHolders="config_systemShell" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -727,7 +714,6 @@ name="android.app.role.SYSTEM_CONTACTS" defaultHolders="config_systemContacts" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -744,7 +730,6 @@ allowBypassingQualification="true" defaultHolders="config_systemSpeechRecognizer" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -766,7 +751,6 @@ name="android.app.role.SYSTEM_WIFI_COEX_MANAGER" defaultHolders="config_systemWifiCoexManager" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -781,7 +765,6 @@ name="android.app.role.SYSTEM_WELLBEING" defaultHolders="config_systemWellbeing" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -810,7 +793,6 @@ behavior="v31.TelevisionRoleBehavior" defaultHolders="config_systemTelevisionNotificationHandler" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -829,7 +811,6 @@ name="android.app.role.SYSTEM_COMPANION_DEVICE_PROVIDER" defaultHolders="config_systemCompanionDeviceProvider" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -865,7 +846,6 @@ name="android.app.role.SYSTEM_UI_INTELLIGENCE" defaultHolders="config_systemUiIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -921,7 +901,6 @@ name="android.app.role.SYSTEM_AMBIENT_AUDIO_INTELLIGENCE" defaultHolders="config_systemAmbientAudioIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -968,7 +947,6 @@ name="android.app.role.SYSTEM_AUDIO_INTELLIGENCE" defaultHolders="config_systemAudioIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1015,7 +993,6 @@ name="android.app.role.SYSTEM_NOTIFICATION_INTELLIGENCE" defaultHolders="config_systemNotificationIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1058,7 +1035,6 @@ name="android.app.role.SYSTEM_TEXT_INTELLIGENCE" defaultHolders="config_systemTextIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1099,7 +1075,6 @@ name="android.app.role.SYSTEM_VISUAL_INTELLIGENCE" defaultHolders="config_systemVisualIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1125,7 +1100,6 @@ name="android.app.role.SYSTEM_DOCUMENT_MANAGER" behavior="v33.DocumentManagerRoleBehavior" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1158,7 +1132,6 @@ allowBypassingQualification="true" defaultHolders="config_systemActivityRecognizer" exclusive="false" - exclusivity="none" static="true" systemOnly="true" visible="false"> @@ -1178,7 +1151,6 @@ name="android.app.role.SYSTEM_UI" defaultHolders="config_systemUi" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1205,7 +1177,6 @@ behavior="v31.TelevisionRoleBehavior" defaultHolders="config_systemTelevisionRemoteService" exclusive="true" - exclusivity="user" minSdkVersion="31" static="true" systemOnly="true" @@ -1225,7 +1196,6 @@ behavior="v33.CompanionDeviceAppStreamingRoleBehavior" description="@string/role_app_streaming_description" exclusive="false" - exclusivity="none" minSdkVersion="33" systemOnly="true" visible="false"> @@ -1250,7 +1220,6 @@ behavior="v33.CompanionDeviceComputerRoleBehavior" description="@string/role_companion_device_computer_description" exclusive="false" - exclusivity="none" minSdkVersion="33" systemOnly="true" visible="false"> @@ -1270,7 +1239,6 @@ name="android.app.role.COMPANION_DEVICE_GLASSES" behavior="v34.CompanionDeviceGlassesRoleBehavior" exclusive="false" - exclusivity="none" minSdkVersion="34" systemOnly="false" visible="false"> @@ -1297,7 +1265,6 @@ name="android.app.role.COMPANION_DEVICE_NEARBY_DEVICE_STREAMING" allowBypassingQualification="true" exclusive="false" - exclusivity="none" minSdkVersion="34" systemOnly="true" visible="false"> @@ -1311,7 +1278,6 @@ name="android.app.role.SYSTEM_SUPERVISION" defaultHolders="config_systemSupervision" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1334,7 +1300,6 @@ behavior="v33.DevicePolicyManagementRoleBehavior" defaultHolders="config_devicePolicyManagement" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="false" @@ -1447,7 +1412,6 @@ name="android.app.role.SYSTEM_APP_PROTECTION_SERVICE" defaultHolders="config_systemAppProtectionService" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1476,7 +1440,6 @@ behavior="v31.AutomotiveRoleBehavior" defaultHolders="config_systemAutomotiveCalendarSyncManager" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1498,7 +1461,6 @@ defaultHolders="config_defaultAutomotiveNavigation" description="@string/role_automotive_navigation_description" exclusive="true" - exclusivity="user" label="@string/role_automotive_navigation_label" minSdkVersion="33" overrideUserWhenGranting="true" @@ -1572,7 +1534,6 @@ name="android.app.role.SYSTEM_SETTINGS_INTELLIGENCE" defaultHolders="config_systemSettingsIntelligence" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1590,7 +1551,6 @@ name="android.app.role.SYSTEM_BLUETOOTH_STACK" defaultHolders="config_systemBluetoothStack" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1615,7 +1575,6 @@ <role name="android.app.role.FINANCED_DEVICE_KIOSK" exclusive="true" - exclusivity="user" minSdkVersion="34" visible="false"> <permissions> @@ -1631,7 +1590,6 @@ name="android.app.role.SYSTEM_FINANCED_DEVICE_CONTROLLER" defaultHolders="config_systemFinancedDeviceController" exclusive="true" - exclusivity="user" minSdkVersion="34" static="true" systemOnly="true" @@ -1659,7 +1617,6 @@ behavior="v33.SystemWearHealthServiceRoleBehavior" defaultHolders="config_systemWearHealthService" exclusive="true" - exclusivity="user" minSdkVersion="33" static="true" systemOnly="true" @@ -1687,7 +1644,6 @@ defaultHolders="config_defaultNotes" description="@string/role_notes_description" exclusive="true" - exclusivity="user" label="@string/role_notes_label" minSdkVersion="34" overrideUserWhenGranting="true" @@ -1729,7 +1685,6 @@ allowBypassingQualification="true" defaultHolders="config_systemCallStreaming" exclusive="true" - exclusivity="user" minSdkVersion="34" static="true" systemOnly="true" @@ -1752,7 +1707,6 @@ behavior="v35.RetailDemoRoleBehavior" defaultHolders="config_defaultRetailDemo" exclusive="true" - exclusivity="user" minSdkVersion="35" static="true" visible="false"> @@ -1779,7 +1733,6 @@ defaultHolders="config_defaultWallet" description="@string/role_wallet_description" exclusive="true" - exclusivity="user" label="@string/role_wallet_label" minSdkVersion="35" overrideUserWhenGranting="true" @@ -1790,4 +1743,5 @@ shortLabel="@string/role_wallet_short_label" uiBehavior="v35.WalletRoleUiBehavior"/> + </roles> diff --git a/PermissionController/role-controller/Android.bp b/PermissionController/role-controller/Android.bp index dfcc83a08..166823b08 100644 --- a/PermissionController/role-controller/Android.bp +++ b/PermissionController/role-controller/Android.bp @@ -31,7 +31,6 @@ java_library { "android.companion.virtualdevice.flags-aconfig-java-export", "android.permission.flags-aconfig-java-export", "android.os.flags-aconfig-java-export", - "com.android.permission.flags-aconfig-java-export", ], apex_available: [ "com.android.permission", 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 |