diff options
| -rw-r--r-- | core/api/test-current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/content/pm/UserInfo.java | 12 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 11 |
3 files changed, 22 insertions, 5 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 1346d0761b20..3e2724e50cd6 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2275,12 +2275,12 @@ package android.os { method public int getMainDisplayIdAssignedToUser(); method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.Set<java.lang.String> getPreInstallableSystemPackages(@NonNull String); method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public String getUserType(); - method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.content.pm.UserInfo> getUsers(boolean, boolean, boolean); + method @Deprecated @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.content.pm.UserInfo> getUsers(boolean, boolean, boolean); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean hasBaseUserRestriction(@NonNull String, @NonNull android.os.UserHandle); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean isUserTypeEnabled(@NonNull String); method public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported(); method public boolean isVisibleBackgroundUsersSupported(); - method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo preCreateUser(@NonNull String) throws android.os.UserManager.UserOperationException; + method @Deprecated @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo preCreateUser(@NonNull String) throws android.os.UserManager.UserOperationException; } public final class VibrationAttributes implements android.os.Parcelable { diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java index 81fc0293b685..23ba33698739 100644 --- a/core/java/android/content/pm/UserInfo.java +++ b/core/java/android/content/pm/UserInfo.java @@ -261,14 +261,17 @@ public class UserInfo implements Parcelable { public boolean guestToRemove; /** - * This is used to optimize the creation of an user, i.e. OEMs might choose to pre-create a + * This is used to optimize the creation of a user, i.e. OEMs might choose to pre-create a * number of users at the first boot, so the actual creation later is faster. * * <p>A {@code preCreated} user is not a real user yet, so it should not show up on regular * user operations (other than user creation per se). * - * <p>Once the pre-created is used to create a "real" user later on, {@code preCreate} is set to - * {@code false}. + * <p>Once the pre-created is used to create a "real" user later on, {@code preCreated} is set + * to {@code false}. + * + * <p><b>NOTE: Pre-created users are deprecated. This field remains to be able to recognize + * pre-created users in older versions, but will eventually be removed. */ public boolean preCreated; @@ -277,6 +280,9 @@ public class UserInfo implements Parcelable { * user. * * <p><b>NOTE: </b>only used for debugging purposes, it's not set when marshalled to a parcel. + * + * <p><b>NOTE: Pre-created users are deprecated. This field remains to be able to recognize + * pre-created users in older versions, but will eventually ve removed. */ public boolean convertedFromPreCreated; diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index b3604da49f5e..24e28e95cd98 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -3706,17 +3706,24 @@ public class UserManager { * {@link android.Manifest.permission#CREATE_USERS} suffices if flags are in * com.android.server.pm.UserManagerService#ALLOWED_FLAGS_FOR_CREATE_USERS_PERMISSION. * + * * @param userType the type of user, such as {@link UserManager#USER_TYPE_FULL_GUEST}. * @return the {@link UserInfo} object for the created user. * * @throws UserOperationException if the user could not be created. + * + * @deprecated Pre-created users are deprecated. This method should no longer be used, and will + * be removed once all the callers are removed. + * * @hide */ + @Deprecated @TestApi @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) public @NonNull UserInfo preCreateUser(@NonNull String userType) throws UserOperationException { + Log.w(TAG, "preCreateUser(): Pre-created user is deprecated."); try { return mService.preCreateUserWithThrow(userType); } catch (ServiceSpecificException e) { @@ -4296,8 +4303,12 @@ public class UserManager { /** * Returns information for all users on this device, based on the filtering parameters. * + * @deprecated Pre-created users are deprecated and no longer supported. + * Use {@link #getUsers()}, {@link #getUsers(boolean)}, or {@link #getAliveUsers()} + * instead. * @hide */ + @Deprecated @TestApi @RequiresPermission(anyOf = { android.Manifest.permission.MANAGE_USERS, |