summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zhen Zhang <zzhen@google.com> 2022-06-08 09:18:25 -0700
committer Zhen Zhang <zzhen@google.com> 2022-06-08 22:44:38 -0700
commitaa5192a77023dae16f3a373d70de3c98f52b1b6c (patch)
tree2478d35dafe7576bf3c69f2060b499c83329c8d6
parent0dfb582d5a4da7dddf079c5a0f18bca77411c0de (diff)
Hide multi user switcher on keyguard screen when disabled
The visibility of multi user switcher on keyguard will be the same as quicksettings multiuser switcher with this change. Added corresponding test as well. Bug: 227232316 Test: Manually Test, multiuser switcher does not show when device is managed by finance DO; Test: atest NotificationPanelViewControllerTest Change-Id: I97baa995a422c071c925848b2c3f397851d3cea9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java34
2 files changed, 40 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 9afdfd651130..f06c7d5a2ae2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -958,14 +958,16 @@ public class NotificationPanelViewController extends PanelViewController {
});
}
- private void onFinishInflate() {
+ @VisibleForTesting
+ void onFinishInflate() {
loadDimens();
mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
FrameLayout userAvatarContainer = null;
KeyguardUserSwitcherView keyguardUserSwitcherView = null;
- if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled()) {
+ if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled(
+ mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user))) {
if (mKeyguardQsUserSwitchEnabled) {
ViewStub stub = mView.findViewById(R.id.keyguard_qs_user_switch_stub);
userAvatarContainer = (FrameLayout) stub.inflate();
@@ -1191,7 +1193,8 @@ public class NotificationPanelViewController extends PanelViewController {
return view;
}
- private void reInflateViews() {
+ @VisibleForTesting
+ void reInflateViews() {
if (DEBUG_LOGCAT) Log.d(TAG, "reInflateViews");
// Re-inflate the status view group.
KeyguardStatusView keyguardStatusView =
@@ -1212,7 +1215,8 @@ public class NotificationPanelViewController extends PanelViewController {
// Re-inflate the keyguard user switcher group.
updateUserSwitcherFlags();
- boolean isUserSwitcherEnabled = mUserManager.isUserSwitcherEnabled();
+ boolean isUserSwitcherEnabled = mUserManager.isUserSwitcherEnabled(
+ mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user));
boolean showQsUserSwitch = mKeyguardQsUserSwitchEnabled && isUserSwitcherEnabled;
boolean showKeyguardUserSwitcher =
!mKeyguardQsUserSwitchEnabled
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java
index f599e3b12c57..01c840263c1c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java
@@ -777,7 +777,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
updateSmallestScreenWidth(300);
when(mResources.getBoolean(
com.android.internal.R.bool.config_keyguardUserSwitcher)).thenReturn(true);
- when(mUserManager.isUserSwitcherEnabled()).thenReturn(true);
+ when(mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user)).thenReturn(false);
+ when(mUserManager.isUserSwitcherEnabled(false)).thenReturn(true);
updateSmallestScreenWidth(800);
@@ -785,6 +786,34 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
}
@Test
+ public void testFinishInflate_userSwitcherDisabled_doNotInflateUserSwitchView() {
+ givenViewAttached();
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_keyguardUserSwitcher)).thenReturn(true);
+ when(mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user)).thenReturn(false);
+ when(mUserManager.isUserSwitcherEnabled(false /* showEvenIfNotActionable */))
+ .thenReturn(false);
+
+ mNotificationPanelViewController.onFinishInflate();
+
+ verify(mUserSwitcherStubView, never()).inflate();
+ }
+
+ @Test
+ public void testReInflateViews_userSwitcherDisabled_doNotInflateUserSwitchView() {
+ givenViewAttached();
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_keyguardUserSwitcher)).thenReturn(true);
+ when(mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user)).thenReturn(false);
+ when(mUserManager.isUserSwitcherEnabled(false /* showEvenIfNotActionable */))
+ .thenReturn(false);
+
+ mNotificationPanelViewController.reInflateViews();
+
+ verify(mUserSwitcherStubView, never()).inflate();
+ }
+
+ @Test
public void testCanCollapsePanelOnTouch_trueForKeyGuard() {
mStatusBarStateController.setState(KEYGUARD);
@@ -1186,7 +1215,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
}
private void updateMultiUserSetting(boolean enabled) {
- when(mUserManager.isUserSwitcherEnabled()).thenReturn(enabled);
+ when(mResources.getBoolean(R.bool.qs_show_user_switcher_for_single_user)).thenReturn(false);
+ when(mUserManager.isUserSwitcherEnabled(false)).thenReturn(enabled);
final ArgumentCaptor<ContentObserver> observerCaptor =
ArgumentCaptor.forClass(ContentObserver.class);
verify(mContentResolver)