Merge "Update UserInfo.supportsSwitchToByUser to support Headless User Mode"

This commit is contained in:
Anthony Hugh
2019-10-21 17:26:55 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 14 deletions

View File

@@ -312,7 +312,7 @@ public class UserInfo implements Parcelable {
*/
public boolean supportsSwitchToByUser() {
// Hide the system user when it does not represent a human user.
boolean hideSystemUser = UserManager.isSplitSystemUser();
boolean hideSystemUser = UserManager.isHeadlessSystemUserMode();
return (!hideSystemUser || id != UserHandle.USER_SYSTEM) && supportsSwitchTo();
}

View File

@@ -55,7 +55,6 @@ import com.android.systemui.statusbar.phone.SystemUIDialog;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Displays a GridLayout with icons for the users in the system to allow switching between users.
@@ -109,21 +108,16 @@ public class UserGridRecyclerView extends RecyclerView {
* @return the adapter
*/
public void buildAdapter() {
List<UserRecord> userRecords = createUserRecords(getAllUsers());
List<UserRecord> userRecords = createUserRecords(getUsersForUserGrid());
mAdapter = new UserAdapter(mContext, userRecords);
super.setAdapter(mAdapter);
}
private List<UserInfo> getAllUsers() {
Stream<UserInfo> userListStream =
mUserManager.getUsers(/* excludeDying= */ true).stream();
if (UserManager.isHeadlessSystemUserMode()) {
userListStream =
userListStream.filter(userInfo -> userInfo.id != UserHandle.USER_SYSTEM);
}
userListStream = userListStream.filter(userInfo -> userInfo.supportsSwitchToByUser());
return userListStream.collect(Collectors.toList());
private List<UserInfo> getUsersForUserGrid() {
return mUserManager.getUsers(/* excludeDying= */ true)
.stream()
.filter(UserInfo::supportsSwitchToByUser)
.collect(Collectors.toList());
}
private List<UserRecord> createUserRecords(List<UserInfo> userInfoList) {
@@ -189,7 +183,7 @@ public class UserGridRecyclerView extends RecyclerView {
private void onUsersUpdate() {
mAdapter.clearUsers();
mAdapter.updateUsers(createUserRecords(getAllUsers()));
mAdapter.updateUsers(createUserRecords(getUsersForUserGrid()));
mAdapter.notifyDataSetChanged();
}