Merge "Deprecate user pre-creation methods in UserManager." into udc-dev

This commit is contained in:
BK Choi
2023-04-06 18:01:39 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 5 deletions

View File

@@ -2277,12 +2277,12 @@ package android.os {
method public int getMainDisplayIdAssignedToUser(); 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 @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, 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 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 @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean isUserTypeEnabled(@NonNull String);
method public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported(); method public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported();
method public boolean isVisibleBackgroundUsersSupported(); 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 { public final class VibrationAttributes implements android.os.Parcelable {

View File

@@ -261,14 +261,17 @@ public class UserInfo implements Parcelable {
public boolean guestToRemove; 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. * 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 * <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). * 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 * <p>Once the pre-created is used to create a "real" user later on, {@code preCreated} is set
* {@code false}. * 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; public boolean preCreated;
@@ -277,6 +280,9 @@ public class UserInfo implements Parcelable {
* user. * user.
* *
* <p><b>NOTE: </b>only used for debugging purposes, it's not set when marshalled to a parcel. * <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; public boolean convertedFromPreCreated;

View File

@@ -3706,17 +3706,24 @@ public class UserManager {
* {@link android.Manifest.permission#CREATE_USERS} suffices if flags are in * {@link android.Manifest.permission#CREATE_USERS} suffices if flags are in
* com.android.server.pm.UserManagerService#ALLOWED_FLAGS_FOR_CREATE_USERS_PERMISSION. * 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}. * @param userType the type of user, such as {@link UserManager#USER_TYPE_FULL_GUEST}.
* @return the {@link UserInfo} object for the created user. * @return the {@link UserInfo} object for the created user.
* *
* @throws UserOperationException if the user could not be created. * @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 * @hide
*/ */
@Deprecated
@TestApi @TestApi
@RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS,
Manifest.permission.CREATE_USERS}) Manifest.permission.CREATE_USERS})
public @NonNull UserInfo preCreateUser(@NonNull String userType) public @NonNull UserInfo preCreateUser(@NonNull String userType)
throws UserOperationException { throws UserOperationException {
Log.w(TAG, "preCreateUser(): Pre-created user is deprecated.");
try { try {
return mService.preCreateUserWithThrow(userType); return mService.preCreateUserWithThrow(userType);
} catch (ServiceSpecificException e) { } catch (ServiceSpecificException e) {
@@ -4296,8 +4303,12 @@ public class UserManager {
/** /**
* Returns information for all users on this device, based on the filtering parameters. * 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 * @hide
*/ */
@Deprecated
@TestApi @TestApi
@RequiresPermission(anyOf = { @RequiresPermission(anyOf = {
android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_USERS,