Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8673cf09 authored by Yunke Zhou's avatar Yunke Zhou
Browse files

[Flexiglass] Show the current user in user switcher

`isPrimary` is true only for system user, which does not work with the
user switcher on HSUM. Hence we change it to show the current user only
when the user switcher is disabled.

Bug: 412922800
Test: Manual tested
Test: UserSwitcherInteractorTest
Flag: com.android.systemui.scene_container

Change-Id: Ide6379c8b5a3d9abb8775f0a891defb67614cf5f
parent 7560bbd4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1088,8 +1088,13 @@ class UserSwitcherInteractorTest : SysuiTestCase() {
            userRepository.setUserInfos(userInfos)
            userRepository.setSelectedUserInfo(userInfos[1])
            userRepository.setSettings(UserSwitcherSettingsModel(isUserSwitcherEnabled = false))

            val selectedUser = collectLastValue(underTest.selectedUser)
            assertThat(selectedUser()).isNotNull()
            assertUser(selectedUser(), id = 1, isSelected = true)

            val users = collectLastValue(underTest.users)
            assertThat(users()?.size == 1).isTrue()
            assertUser(users()?.firstOrNull(), id = 1, isSelected = true)
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -711,8 +711,8 @@ constructor(
        isUserSwitcherEnabled: Boolean,
    ): UserModel? {
        return when {
            // When the user switcher is not enabled in settings, we only show the primary user.
            !isUserSwitcherEnabled && !userInfo.isPrimary -> null
            // When the user switcher is not enabled in settings, we only show the current user.
            !isUserSwitcherEnabled && userInfo.id != selectedUserId -> null
            // We avoid showing disabled users.
            !userInfo.isEnabled -> null
            // We meet the conditions to return the UserModel.