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

Commit e21406e9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Renamed removeUserOrSetEphemeral completely"

parents 14da7def add9e6f1
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -4786,33 +4786,6 @@ public class UserManager {
        }
    }

    /**
     * Immediately removes the user or, if the user cannot be removed, such as when the user is
     * the current user, then set the user as ephemeral so that it will be removed when it is
     * stopped.
     *
     * @param evenWhenDisallowed when {@code true}, user is removed even if the caller has the
     * {@link #DISALLOW_REMOVE_USER} or {@link #DISALLOW_REMOVE_MANAGED_PROFILE} restriction
     *
     * @return the {@link RemoveResult} code
     *
     * @deprecated  TODO(b/199446770): remove this call after converting all calls to
     * removeUserWhenPossible(UserHandle, boolean)
     *
     * @hide
     */
    @Deprecated
    @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS,
            Manifest.permission.CREATE_USERS})
    public @RemoveResult int removeUserOrSetEphemeral(@UserIdInt int userId,
            boolean evenWhenDisallowed) {
        try {
            return mService.removeUserWhenPossible(userId, evenWhenDisallowed);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Updates the user's name.
     *
+6 −6
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_restrictedReturnsError() throws Exception {
    public void testRemoveUserWhenPossible_restrictedReturnsError() throws Exception {
        final int currentUser = ActivityManager.getCurrentUser();
        final UserInfo user1 = createUser("User 1", /* flags= */ 0);
        mUserManager.setUserRestriction(UserManager.DISALLOW_REMOVE_USER, /* value= */ true,
@@ -328,7 +328,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_evenWhenRestricted() throws Exception {
    public void testRemoveUserWhenPossible_evenWhenRestricted() throws Exception {
        final int currentUser = ActivityManager.getCurrentUser();
        final UserInfo user1 = createUser("User 1", /* flags= */ 0);
        mUserManager.setUserRestriction(UserManager.DISALLOW_REMOVE_USER, /* value= */ true,
@@ -351,7 +351,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_systemUserReturnsError() throws Exception {
    public void testRemoveUserWhenPossible_systemUserReturnsError() throws Exception {
        assertThat(mUserManager.removeUserWhenPossible(UserHandle.SYSTEM,
                /* overrideDevicePolicy= */ false)).isEqualTo(UserManager.REMOVE_RESULT_ERROR);

@@ -360,7 +360,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_invalidUserReturnsError() throws Exception {
    public void testRemoveUserWhenPossible_invalidUserReturnsError() throws Exception {
        assertThat(hasUser(Integer.MAX_VALUE)).isFalse();
        assertThat(mUserManager.removeUserWhenPossible(UserHandle.of(Integer.MAX_VALUE),
                /* overrideDevicePolicy= */ false)).isEqualTo(UserManager.REMOVE_RESULT_ERROR);
@@ -368,7 +368,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_currentUserSetEphemeral() throws Exception {
    public void testRemoveUserWhenPossible_currentUserSetEphemeral() throws Exception {
        final int startUser = ActivityManager.getCurrentUser();
        final UserInfo user1 = createUser("User 1", /* flags= */ 0);
        // Switch to the user just created.
@@ -392,7 +392,7 @@ public final class UserManagerTest {

    @MediumTest
    @Test
    public void testRemoveUserOrSetEphemeral_nonCurrentUserRemoved() throws Exception {
    public void testRemoveUserWhenPossible_nonCurrentUserRemoved() throws Exception {
        final UserInfo user1 = createUser("User 1", /* flags= */ 0);
        synchronized (mUserRemoveLock) {
            assertThat(mUserManager.removeUserWhenPossible(user1.getUserHandle(),