From 4e4b072c3602934154e44144783d7f3b4875f633 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 14 Jun 2019 10:54:35 -0400 Subject: [PATCH] Hide MultiUserSwitch when guestEnabled && no_add_users If the device is guestEnabled but the user cannot add new users (either by system or by device policy), do not show MultiUserSwitch Even if the user set the setting USER_SWITCHER_ENABLED to true by accidentally going to "Multiple Users", it doesn't make sense to show it in devices with a single user that cannot add users. We still set the setting to true by default (even if it may be disabled by policy), as the setting should reflect what the user sees in that screen. Test: manual * Set the user restrictions for user 0 as per in BR in b/134569467. Including policy as well as modifying /data/system/users/0.xml * Go to Multiple Users, see that it matches screenshot with setting enabled * See that the issue is that guests are enabled, even though the user cannot add guests and that's why MultiUserSwitch is showing. Fixes: 134569467 Change-Id: If7c596769faa577d6d9ba8943722fb6e6734f7c2 --- .../com/android/systemui/statusbar/phone/MultiUserSwitch.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index 443cc4397bd35..c0a1b123fe775 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -112,7 +112,9 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener final boolean guestEnabled = !mContext.getSystemService(DevicePolicyManager.class) .getGuestUserDisabled(null); - return mUserSwitcherController.getSwitchableUserCount() > 1 || guestEnabled + return mUserSwitcherController.getSwitchableUserCount() > 1 + // If we cannot add guests even if they are enabled, do not show + || (guestEnabled && !mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER)) || mContext.getResources().getBoolean(R.bool.qs_show_user_switcher_for_single_user); }