Disable multiuser toggle when more than 1 user is created
It makes more sense to have the toggle as on permanently as long as there are other users on the device. Otherwise if we toggle off "Allow multiple users", other users get hidden. Also with current behaviour the any admin can switch the toggle and this can block any other user, including main, from being able to use the device. Bug: 295183792 Test: atest MultiUserSwitchBarControllerTest && UserSettingsTest Change-Id: I8cb0671d780f45c17a9bb7c9a9d3b108128ead9d
This commit is contained in:
@@ -46,13 +46,18 @@ public class MultiUserSwitchBarController implements SwitchWidgetController.OnSw
|
||||
|
||||
|
||||
MultiUserSwitchBarController(Context context, SwitchWidgetController switchBar,
|
||||
OnMultiUserSwitchChangedListener listener) {
|
||||
boolean canUserSwitchToggle, OnMultiUserSwitchChangedListener listener) {
|
||||
mContext = context;
|
||||
mSwitchBar = switchBar;
|
||||
mListener = listener;
|
||||
mUserCapabilities = UserCapabilities.create(context);
|
||||
mSwitchBar.setChecked(mUserCapabilities.mUserSwitcherEnabled);
|
||||
|
||||
setToggleEnabled(canUserSwitchToggle);
|
||||
mSwitchBar.setListener(this);
|
||||
}
|
||||
|
||||
void setToggleEnabled(boolean canUserSwitchToggle) {
|
||||
if (mUserCapabilities.mDisallowSwitchUser) {
|
||||
mSwitchBar.setDisabledByAdmin(RestrictedLockUtilsInternal
|
||||
.checkIfRestrictionEnforced(mContext, UserManager.DISALLOW_USER_SWITCH,
|
||||
@@ -64,9 +69,8 @@ public class MultiUserSwitchBarController implements SwitchWidgetController.OnSw
|
||||
UserHandle.myUserId()));
|
||||
} else {
|
||||
mSwitchBar.setEnabled(!mUserCapabilities.mDisallowSwitchUser
|
||||
&& !mUserCapabilities.mIsGuest && mUserCapabilities.isAdmin());
|
||||
&& !mUserCapabilities.mIsGuest && canUserSwitchToggle);
|
||||
}
|
||||
mSwitchBar.setListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user