From 68d8d15adbdadb49ba6696971f37612a18434aa4 Mon Sep 17 00:00:00 2001 From: Adam Bookatz Date: Wed, 21 Feb 2024 18:19:24 -0800 Subject: Clarify "enabled" in UserManager Further documentation is added to clarify the commonly confused notion of a disabled profile. Test: none (just javadoc) Change-Id: I0db87722748b8226174cecebbe5b1836501e2726 --- core/java/android/content/pm/UserInfo.java | 7 +++++++ core/java/android/os/UserManager.java | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java index 3e9f260566bd..8a3a3ad56a7b 100644 --- a/core/java/android/content/pm/UserInfo.java +++ b/core/java/android/content/pm/UserInfo.java @@ -112,6 +112,12 @@ public class UserInfo implements Parcelable { /** * Indicates that this user is disabled. * + *

This is currently used to indicate that a Managed Profile, when created via + * DevicePolicyManager, has not yet been provisioned; once the DPC provisions it, a DPM call + * will manually set it to enabled. + * + *

Users that are slated for deletion are also generally set to disabled. + * *

Note: If an ephemeral user is disabled, it shouldn't be later re-enabled. Ephemeral users * are disabled as their removal is in progress to indicate that they shouldn't be re-entered. */ @@ -398,6 +404,7 @@ public class UserInfo implements Parcelable { return UserManager.isUserTypePrivateProfile(userType); } + /** See {@link #FLAG_DISABLED}*/ @UnsupportedAppUsage public boolean isEnabled() { return (flags & FLAG_DISABLED) != FLAG_DISABLED; diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index d6df8d940904..ae1c82b3166e 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -4641,6 +4641,9 @@ public class UserManager { * Sets the user as enabled, if such an user exists. * *

Note that the default is true, it's only that managed profiles might not be enabled. + * (Managed profiles created by DevicePolicyManager will start out disabled, and DPM will later + * toggle them to enabled once they are provisioned. This is the primary purpose of the + * {@link UserInfo#FLAG_DISABLED} flag.) * Also ephemeral users can be disabled to indicate that their removal is in progress and they * shouldn't be re-entered. Therefore ephemeral users should not be re-enabled once disabled. * @@ -5192,7 +5195,7 @@ public class UserManager { /** * Returns list of the profiles of userId including userId itself. - * Note that this returns only enabled. + * Note that this returns only {@link UserInfo#isEnabled() enabled} profiles. *

Note that this includes all profile types (not including Restricted profiles). * *

Requires {@link android.Manifest.permission#MANAGE_USERS} or -- cgit v1.2.3-59-g8ed1b