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

Commit 80b4859e authored by jovanak's avatar jovanak
Browse files

Prevents showing Guests in switcher.

We already show "Guest" icon for adding a guest.
No need to show "Guest" users.

Guest users are ephemeral. They get cleaned up by the system.

Bug: 77491605
Test: On mojave, adding of many Guest sessions and observing the switcher.
Change-Id: Id3e10e01b7dbf0070605d09777a2fb3bedf585c0
parent a153811a
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -91,8 +91,12 @@ public class UserGridRecyclerView extends RecyclerView implements
    private List<UserRecord> createUserRecords(List<UserInfo> userInfoList) {
        List<UserRecord> userRecords = new ArrayList<>();
        for (UserInfo userInfo : userInfoList) {
            if (userInfo.isGuest()) {
                // Don't display guests in the switcher.
                continue;
            }
            boolean isForeground = mUserManagerHelper.getForegroundUserId() == userInfo.id;
            UserRecord record = new UserRecord(userInfo, false /* isGuest */,
            UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
                    false /* isAddUser */, isForeground);
            userRecords.add(record);
        }
@@ -116,7 +120,7 @@ public class UserGridRecyclerView extends RecyclerView implements
    private UserRecord addGuestUserRecord() {
        UserInfo userInfo = new UserInfo();
        userInfo.name = mContext.getString(R.string.car_guest);
        return new UserRecord(userInfo, true /* isGuest */,
        return new UserRecord(userInfo, true /* isStartGuestSession */,
                false /* isAddUser */, false /* isForeground */);
    }

@@ -126,7 +130,7 @@ public class UserGridRecyclerView extends RecyclerView implements
    private UserRecord addUserRecord() {
        UserInfo userInfo = new UserInfo();
        userInfo.name = mContext.getString(R.string.car_add_user);
        return new UserRecord(userInfo, false /* isGuest */,
        return new UserRecord(userInfo, false /* isStartGuestSession */,
                true /* isAddUser */, false /* isForeground */);
    }

@@ -198,8 +202,8 @@ public class UserGridRecyclerView extends RecyclerView implements
                    mUserSelectionListener.onUserSelected(userRecord);
                }

                // If the user selects Guest, switch to Guest profile
                if (userRecord.mIsGuest) {
                // If the user selects Guest, start the guest session.
                if (userRecord.mIsStartGuestSession) {
                    mUserManagerHelper.switchToGuest(mGuestName);
                    return;
                }
@@ -313,14 +317,14 @@ public class UserGridRecyclerView extends RecyclerView implements
    public static final class UserRecord {

        public final UserInfo mInfo;
        public final boolean mIsGuest;
        public final boolean mIsStartGuestSession;
        public final boolean mIsAddUser;
        public final boolean mIsForeground;

        public UserRecord(UserInfo userInfo, boolean isGuest, boolean isAddUser,
        public UserRecord(UserInfo userInfo, boolean isStartGuestSession, boolean isAddUser,
                boolean isForeground) {
            mInfo = userInfo;
            mIsGuest = isGuest;
            mIsStartGuestSession = isStartGuestSession;
            mIsAddUser = isAddUser;
            mIsForeground = isForeground;
        }