diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 8e4775fda504a..f089546e26343 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -9539,7 +9539,7 @@ package android.os { method @NonNull public java.util.List getAllProfiles(); method @NonNull public java.util.List getEnabledProfiles(); method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public android.os.UserHandle getProfileParent(@NonNull android.os.UserHandle); - method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public int getRemainingCreatableProfileCount(@NonNull String, boolean); + method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public int getRemainingCreatableProfileCount(@NonNull String); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public int getRemainingCreatableUserCount(@NonNull String); method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public android.os.UserHandle getRestrictedProfileParent(); method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public String getSeedAccountName(); diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index d9c9a2b55abd5..bc7fb789b5380 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -63,7 +63,7 @@ interface IUserManager { boolean isUserTypeEnabled(in String userType); boolean canAddMoreUsersOfType(in String userType); int getRemainingCreatableUserCount(in String userType); - int getRemainingCreatableProfileCount(in String userType, int userId, boolean allowedToRemoveOne); + int getRemainingCreatableProfileCount(in String userType, int userId); boolean canAddMoreProfilesToUser(in String userType, int userId, boolean allowedToRemoveOne); boolean canAddMoreManagedProfiles(int userId, boolean allowedToRemoveOne); UserInfo getProfileParent(int userId); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 7b8d34b3b5704..2bd1dbb238e83 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -4055,9 +4055,6 @@ public class UserManager { *

Note that is applicable to any profile type (currently not including Restricted profiles). * * @param userType the type of profile, such as {@link UserManager#USER_TYPE_PROFILE_MANAGED}. - * @param allowedToRemoveOne whether removing an existing profile of given type -if there is- - * from the context user to make up space should be taken into account - * for the calculation. * @return how many additional profiles can be created. * @hide */ @@ -4068,13 +4065,11 @@ public class UserManager { android.Manifest.permission.QUERY_USERS }) @UserHandleAware - public int getRemainingCreatableProfileCount(@NonNull String userType, - boolean allowedToRemoveOne) { + public int getRemainingCreatableProfileCount(@NonNull String userType) { Objects.requireNonNull(userType, "userType must not be null"); try { // TODO(b/142482943): Perhaps let the following code apply to restricted users too. - return mService.getRemainingCreatableProfileCount(userType, mUserId, - allowedToRemoveOne); + return mService.getRemainingCreatableProfileCount(userType, mUserId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index b07cd1063ed2a..652080a3f11d3 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -2515,13 +2515,17 @@ public class UserManagerService extends IUserManager.Stub { return 0 < getRemainingCreatableProfileCount(userType, userId, allowedToRemoveOne); } + @Override + public int getRemainingCreatableProfileCount(@NonNull String userType, @UserIdInt int userId) { + return getRemainingCreatableProfileCount(userType, userId, false); + } + /** * Returns the remaining number of profiles of the given type that can be added to the given * user. (taking into account the total number of users on the device as well as how many * profiles exist of that type both in general and for the given user) */ - @Override - public int getRemainingCreatableProfileCount(@NonNull String userType, @UserIdInt int userId, + private int getRemainingCreatableProfileCount(@NonNull String userType, @UserIdInt int userId, boolean allowedToRemoveOne) { checkQueryOrCreateUsersPermission( "get the remaining number of profiles that can be added to the given user.");