Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78719a9e authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Android (Google) Code Review
Browse files

Merge "Remove allowedToRemoveOne boolean parameter from UM.getRemainingCreatableProfileCount()"

parents ceb990dc 7ac52f42
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9674,7 +9674,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();
+1 −1
Original line number Diff line number Diff line
@@ -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);
+2 −7
Original line number Diff line number Diff line
@@ -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();
        }
+6 −2
Original line number Diff line number Diff line
@@ -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.");