summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
author Richard MacGregor <rmacgregor@google.com> 2025-03-03 13:25:52 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-03 13:25:52 -0800
commit555481407bbed98ef513979f9035e14068750d79 (patch)
tree7ffd542d5e9d73fd6a531f886a0001a6a969c14f /service
parent1e6bca7ffcac0f3401a1788e833139844984e258 (diff)
parent59675001a55932c51c97d61e303ed2233d5fcb33 (diff)
Merge "Add missing preconditions to get/setDefaultApplicationAsUser" into main
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/role/RoleService.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/service/java/com/android/role/RoleService.java b/service/java/com/android/role/RoleService.java
index e5d20ef9d..ac6703545 100644
--- a/service/java/com/android/role/RoleService.java
+++ b/service/java/com/android/role/RoleService.java
@@ -732,6 +732,9 @@ public class RoleService extends SystemService implements RoleUserState.Callback
@Override
@Nullable
public String getDefaultApplicationAsUser(@NonNull String roleName, @UserIdInt int userId) {
+ // The MANAGE_DEFAULT_APPLICATIONS permission is only available on U+
+ Preconditions.checkState(SdkLevel.isAtLeastU(),
+ "This API is only available on Android 34 and above");
UserUtils.enforceCrossUserPermission(userId, /* allowAll= */ false,
/* enforceForProfileGroup= */ false, "getDefaultApplicationAsUser",
getContext());
@@ -758,6 +761,9 @@ public class RoleService extends SystemService implements RoleUserState.Callback
public void setDefaultApplicationAsUser(@NonNull String roleName,
@Nullable String packageName, @RoleManager.ManageHoldersFlags int flags,
@UserIdInt int userId, @NonNull RemoteCallback callback) {
+ // The MANAGE_DEFAULT_APPLICATIONS permission is only available on U+
+ Preconditions.checkState(SdkLevel.isAtLeastU(),
+ "This API is only available on Android 34 and above");
boolean enforceForProfileGroup = isProfileGroupExclusiveRole(roleName, getContext());
UserUtils.enforceCrossUserPermission(userId, /* allowAll= */ false,
enforceForProfileGroup, "setDefaultApplicationAsUser", getContext());