Swap for more framework APIs
Swap CarUserManagerHelper.isUserLimitReached() with !UserManager.canAddMoreUsers(). Swap CarUserManagerHelper.canForegroundUserAddUsers() with UserManager.hasUserRestriction(). Implementation is the essentially the same, but UserManager APIs are better supported across the system. Bug: 131776619 Test: atest CarSettingsRoboTests Test: Manually play with UserPicker and changing max user size Test: adb shell pm set-user-restriction --user 10 no_add_user 1 Then verify add user button does not appear in UserPicker Change-Id: I8b44ada6423f2a14c11170d890740034c8e9d34f
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.car;
|
||||
|
||||
import static android.content.DialogInterface.BUTTON_NEGATIVE;
|
||||
import static android.content.DialogInterface.BUTTON_POSITIVE;
|
||||
import static android.os.UserManager.DISALLOW_ADD_USER;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
@@ -145,7 +146,8 @@ public class UserGridRecyclerView extends RecyclerView {
|
||||
userRecords.add(createStartGuestUserRecord());
|
||||
|
||||
// Add add user record if the foreground user can add users
|
||||
if (mCarUserManagerHelper.canForegroundUserAddUsers()) {
|
||||
UserHandle fgUserHandle = UserHandle.of(ActivityManager.getCurrentUser());
|
||||
if (!mUserManager.hasUserRestriction(DISALLOW_ADD_USER, fgUserHandle)) {
|
||||
userRecords.add(createAddUserRecord());
|
||||
}
|
||||
|
||||
@@ -285,7 +287,7 @@ public class UserGridRecyclerView extends RecyclerView {
|
||||
}
|
||||
|
||||
private void handleAddUserClicked() {
|
||||
if (mCarUserManagerHelper.isUserLimitReached()) {
|
||||
if (!mUserManager.canAddMoreUsers()) {
|
||||
mAddUserView.setEnabled(true);
|
||||
showMaxUserLimitReachedDialog();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user