Loading core/java/android/content/pm/UserInfo.java +3 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading Loading
core/java/android/content/pm/UserInfo.java +3 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading