Loading core/java/android/os/UserManager.java +0 −27 Original line number Diff line number Diff line Loading @@ -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. * Loading services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading @@ -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); Loading @@ -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); Loading @@ -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. Loading @@ -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(), Loading Loading
core/java/android/os/UserManager.java +0 −27 Original line number Diff line number Diff line Loading @@ -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. * Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading @@ -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); Loading @@ -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); Loading @@ -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. Loading @@ -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(), Loading