Merge "User switcher in now checks for whether the user can switch to other users."
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
index da6401c..67e512c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
@@ -98,6 +98,13 @@
private List<UserRecord> createUserRecords(List<UserInfo> userInfoList) {
List<UserRecord> userRecords = new ArrayList<>();
+
+ // If the foreground user CANNOT switch to other users, only display the foreground user.
+ if (!mCarUserManagerHelper.canForegroundUserSwitchUsers()) {
+ userRecords.add(createForegroundUserRecord());
+ return userRecords;
+ }
+
for (UserInfo userInfo : userInfoList) {
if (userInfo.isGuest()) {
// Don't display guests in the switcher.
@@ -122,6 +129,11 @@
return userRecords;
}
+ private UserRecord createForegroundUserRecord() {
+ return new UserRecord(mCarUserManagerHelper.getCurrentForegroundUserInfo(),
+ false /* isStartGuestSession */, false /* isAddUser */, true /* isForeground */);
+ }
+
/**
* Create guest user record
*/