summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt26
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt10
4 files changed, 33 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
index 83f0711caa38..0e4f2244217a 100644
--- a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
@@ -117,7 +117,7 @@ constructor(
private val callbacks = mutableSetOf<UserCallback>()
private val userInfos =
combine(repository.userSwitcherSettings, repository.userInfos) { settings, userInfos ->
- userInfos.filter { !it.isGuest || canCreateGuestUser(settings) }
+ userInfos.filter { !it.isGuest || canCreateGuestUser(settings) }.filter { it.isFull }
}
/** List of current on-device users to select from. */
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
index 4b49420c99be..d87720991036 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
@@ -771,6 +771,28 @@ class UserInteractorTest : SysuiTestCase() {
)
}
+ @Test
+ fun `users - secondary user - managed profile is not included`() =
+ runBlocking(IMMEDIATE) {
+ var userInfos = createUserInfos(count = 3, includeGuest = false).toMutableList()
+ userInfos.add(
+ UserInfo(
+ 50,
+ "Work Profile",
+ /* iconPath= */ "",
+ /* flags= */ UserInfo.FLAG_MANAGED_PROFILE
+ )
+ )
+ userRepository.setUserInfos(userInfos)
+ userRepository.setSelectedUserInfo(userInfos[1])
+ userRepository.setSettings(UserSwitcherSettingsModel(isUserSwitcherEnabled = true))
+
+ var res: List<UserModel>? = null
+ val job = underTest.users.onEach { res = it }.launchIn(this)
+ assertThat(res?.size == 3).isTrue()
+ job.cancel()
+ }
+
private fun assertUsers(
models: List<UserModel>?,
count: Int,
@@ -893,9 +915,9 @@ class UserInteractorTest : SysuiTestCase() {
name,
/* iconPath= */ "",
/* flags= */ if (isPrimary) {
- UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN
+ UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL
} else {
- 0
+ UserInfo.FLAG_FULL
},
if (isGuest) {
UserManager.USER_TYPE_FULL_GUEST
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
index db348b8029a0..795ff17f92a4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt
@@ -281,7 +281,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
USER_ID_0,
USER_NAME_0.text!!,
/* iconPath */ "",
- /* flags */ 0,
+ /* flags */ UserInfo.FLAG_FULL,
/* userType */ UserManager.USER_TYPE_FULL_SYSTEM
)
@@ -290,7 +290,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
USER_ID_1,
USER_NAME_1.text!!,
/* iconPath */ "",
- /* flags */ 0,
+ /* flags */ UserInfo.FLAG_FULL,
/* userType */ UserManager.USER_TYPE_FULL_SYSTEM
)
@@ -299,7 +299,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
USER_ID_2,
USER_NAME_2.text!!,
/* iconPath */ "",
- /* flags */ 0,
+ /* flags */ UserInfo.FLAG_FULL,
/* userType */ UserManager.USER_TYPE_FULL_SYSTEM
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
index eac7fc21e505..1730b75c20d4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt
@@ -178,21 +178,21 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
/* id= */ 0,
/* name= */ "zero",
/* iconPath= */ "",
- /* flags= */ UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN,
+ /* flags= */ UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL,
UserManager.USER_TYPE_FULL_SYSTEM,
),
UserInfo(
/* id= */ 1,
/* name= */ "one",
/* iconPath= */ "",
- /* flags= */ 0,
+ /* flags= */ UserInfo.FLAG_FULL,
UserManager.USER_TYPE_FULL_SYSTEM,
),
UserInfo(
/* id= */ 2,
/* name= */ "two",
/* iconPath= */ "",
- /* flags= */ 0,
+ /* flags= */ UserInfo.FLAG_FULL,
UserManager.USER_TYPE_FULL_SYSTEM,
),
)
@@ -361,10 +361,10 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
/* iconPath= */ "",
/* flags= */ if (index == 0) {
// This is the primary user.
- UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN
+ UserInfo.FLAG_PRIMARY or UserInfo.FLAG_ADMIN or UserInfo.FLAG_FULL
} else {
// This isn't the primary user.
- 0
+ UserInfo.FLAG_FULL
},
UserManager.USER_TYPE_FULL_SYSTEM,
)