Merge "Should not switch to a user with removal in progress"
This commit is contained in:
committed by
Android (Google) Code Review
commit
26e228da83
@@ -366,8 +366,9 @@ public class UserInfo implements Parcelable {
|
||||
* @return true if this user can be switched to.
|
||||
**/
|
||||
public boolean supportsSwitchTo() {
|
||||
if (isEphemeral() && !isEnabled()) {
|
||||
// Don't support switching to an ephemeral user with removal in progress.
|
||||
if (partial || !isEnabled()) {
|
||||
// Don't support switching to disabled or partial users, which includes users with
|
||||
// removal in progress.
|
||||
return false;
|
||||
}
|
||||
if (preCreated) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.pm;
|
||||
|
||||
import static android.content.pm.UserInfo.FLAG_DEMO;
|
||||
import static android.content.pm.UserInfo.FLAG_DISABLED;
|
||||
import static android.content.pm.UserInfo.FLAG_EPHEMERAL;
|
||||
import static android.content.pm.UserInfo.FLAG_FULL;
|
||||
import static android.content.pm.UserInfo.FLAG_GUEST;
|
||||
@@ -166,6 +167,23 @@ public class UserManagerServiceUserInfoTest {
|
||||
assertTrue(mUserManagerService.isUserOfType(testId, typeName));
|
||||
}
|
||||
|
||||
/** Test UserInfo.supportsSwitchTo() for partial user. */
|
||||
@Test
|
||||
public void testSupportSwitchTo_partial() throws Exception {
|
||||
UserInfo userInfo = createUser(100, FLAG_FULL, null);
|
||||
userInfo.partial = true;
|
||||
assertFalse("Switching to a partial user should be disabled",
|
||||
userInfo.supportsSwitchTo());
|
||||
}
|
||||
|
||||
/** Test UserInfo.supportsSwitchTo() for disabled user. */
|
||||
@Test
|
||||
public void testSupportSwitchTo_disabled() throws Exception {
|
||||
UserInfo userInfo = createUser(100, FLAG_DISABLED, null);
|
||||
assertFalse("Switching to a DISABLED user should be disabled",
|
||||
userInfo.supportsSwitchTo());
|
||||
}
|
||||
|
||||
/** Test UserInfo.supportsSwitchTo() for precreated users. */
|
||||
@Test
|
||||
public void testSupportSwitchTo_preCreated() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user