Refactored Settings calls to removeUserOrSetEphemeral().

Test: atest com.android.car.user.CarUserServiceTest \
      android.car.apitest.CarDevicePolicyManagerTest#testRemoveUser_whenDisallowed
Bug: 170887769

Change-Id: If797ace64c0fa0262116f649212bbcb1d61e2046
This commit is contained in:
Felipe Leme
2021-01-06 23:40:51 -08:00
parent aaf2ad7738
commit cc7f845fdd

View File

@@ -751,7 +751,8 @@ public class UserSettings extends SettingsPreferenceFragment
} }
try { try {
getContext().getSystemService(UserManager.class) getContext().getSystemService(UserManager.class)
.removeUserOrSetEphemeral(UserHandle.myUserId()); .removeUserOrSetEphemeral(UserHandle.myUserId(),
/* evenWhenDisallowed= */ false);
ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM); ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM);
} catch (RemoteException re) { } catch (RemoteException re) {
Log.e(TAG, "Unable to remove self user"); Log.e(TAG, "Unable to remove self user");