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

Commit 472e4156 authored by Denis Kuznetsov's avatar Denis Kuznetsov
Browse files

Control user switching UI visibility according to config

Bug: 375394047
Test: atest UserDetailsSettingsTest UserSettingsTest
Test: build platform with config overrides, check the result
Flag: EXEMPT Desktop-only change
Change-Id: Iaf1ac6c98a648066bf77b069039dcd59e243835f
parent a3cdf474
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public class UserCapabilities {
    boolean mIsAdmin;
    boolean mIsGuest;
    boolean mIsEphemeral;
    boolean mUserSwitchingUiEnabled;
    boolean mUserSwitcherEnabled;
    boolean mCanAddGuest;
    boolean mDisallowAddUser;
@@ -68,7 +69,8 @@ public class UserCapabilities {
        caps.mCanAddRestrictedProfile =
                offerRestricted && !dpm.isDeviceManaged() && userManager.isUserTypeEnabled(
                        UserManager.USER_TYPE_FULL_RESTRICTED);

        caps.mUserSwitchingUiEnabled = context.getResources().getBoolean(
                com.android.internal.R.bool.config_allowChangeUserSwitcherEnabled);
        caps.updateAddUserCapabilities(context);
        return caps;
    }
@@ -134,6 +136,7 @@ public class UserCapabilities {
                ", mEnforcedAdmin=" + mEnforcedAdmin +
                ", mDisallowSwitchUser=" + mDisallowSwitchUser +
                ", mDisallowAddUserSetByAdmin=" + mDisallowAddUserSetByAdmin +
                ", mUserSwitchingUiEnabled=" + mUserSwitchingUiEnabled +
                ", mUserSwitcherEnabled=" + mUserSwitcherEnabled +
                '}';
    }
+2 −0
Original line number Diff line number Diff line
@@ -354,6 +354,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment

        mGrantAdminPref.setChecked(mUserInfo.isAdmin());

        mSwitchUserPref.setVisible(mUserCaps.mUserSwitchingUiEnabled);

        mSwitchUserPref.setTitle(
                context.getString(com.android.settingslib.R.string.user_switch_to_user,
                        mUserInfo.name));
+1 −1
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ public class UserSettings extends SettingsPreferenceFragment
        final SettingsActivity activity = (SettingsActivity) getActivity();
        final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
        switchBar.setTitle(getContext().getString(R.string.multiple_users_main_switch_title));
        if (!mUserCaps.mIsGuest) {
        if (!mUserCaps.mIsGuest && mUserCaps.mUserSwitchingUiEnabled) {
            switchBar.show();
        } else {
            switchBar.hide();