Remove allowedToRemoveOne boolean parameter from UM.getRemainingCreatableProfileCount()

Bug: 217364189
Test: atest android.multiuser.cts.UserManagerTest
Change-Id: Idebeab6407eb90967dcd0ebbcfaba4b76a8f1263
This commit is contained in:
Yasin Kilicdere
2022-02-01 19:46:05 +00:00
parent 7315b7278c
commit 7ac52f42d2
4 changed files with 10 additions and 11 deletions

View File

@@ -9539,7 +9539,7 @@ package android.os {
method @NonNull public java.util.List<android.os.UserHandle> getAllProfiles();
method @NonNull public java.util.List<android.os.UserHandle> 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();

View File

@@ -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);

View File

@@ -4055,9 +4055,6 @@ public class UserManager {
* <p>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();
}

View File

@@ -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.");