From cd49a28e4f38aa70e5a26aa804c71051e260b695 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Tue, 31 May 2022 14:39:01 +0100 Subject: [PATCH] Fixing empty split shade after rotation from expanded QS on lockscreen In portrait, swipe from the top of the screen goes to expaned QS but state of StatusBar is KEYGUARD. That makes split shade confused, alphas and translations are all over the place. The solution is to force change state to SHADE_LOCKED which makes more sense in that case in split shade. Also fixing comments of StatusBarState. Fixes: 232396574 Test: Go to portrait shade -> go to expanded QS with swipe from the top -> rotate to split shade and see everything displayed correctly Test: NotificationPanelViewControllerTest Change-Id: Ib4fe90a7b784cfe755179518c6e19e8fd7c10436 --- .../systemui/statusbar/StatusBarState.java | 11 ++++--- .../NotificationPanelViewController.java | 29 ++++++++++++++----- .../NotificationPanelViewControllerTest.java | 10 +++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarState.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarState.java index 718bc5caf414b..f78b067279bd3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarState.java @@ -22,18 +22,21 @@ package com.android.systemui.statusbar; public class StatusBarState { /** - * The status bar is in the "normal" shade mode. + * The status bar is in the "normal", unlocked mode or the device is still locked but we're + * accessing camera from power button double-tap shortcut. */ public static final int SHADE = 0; /** - * Status bar is currently the Keyguard. + * Status bar is currently the Keyguard. In single column mode, when you swipe from the top of + * the keyguard to expand QS immediately, it's still KEYGUARD state. */ public static final int KEYGUARD = 1; /** - * Status bar is in the special mode, where it is fully interactive but still locked. So - * dismissing the shade will still show the bouncer. + * Status bar is in the special mode, where it was transitioned from lockscreen to shade. + * Depending on user's security settings, dismissing the shade will either show the + * bouncer or go directly to unlocked {@link #SHADE} mode. */ public static final int SHADE_LOCKED = 2; 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 ad3329a570395..614ec1c8c04b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1161,17 +1161,30 @@ public class NotificationPanelViewController extends PanelViewController { mKeyguardMediaController.refreshMediaPosition(); if (splitShadeChanged) { - // when we switch from split shade to regular shade we want to enforce setting qs to - // the default state: expanded for split shade and collapsed otherwise - if (!isOnKeyguard() && mPanelExpanded) { - setQsExpanded(mSplitShadeEnabled); - } - updateClockAppearance(); - updateQsState(); - mNotificationStackScrollLayoutController.updateFooter(); + onSplitShadeEnabledChanged(); } } + private void onSplitShadeEnabledChanged() { + // when we switch between split shade and regular shade we want to enforce setting qs to + // the default state: expanded for split shade and collapsed otherwise + if (!isOnKeyguard() && mPanelExpanded) { + setQsExpanded(mSplitShadeEnabled); + } + if (isOnKeyguard() && mQsExpanded && mSplitShadeEnabled) { + // In single column keyguard - when you swipe from the top - QS is fully expanded and + // StatusBarState is KEYGUARD. That state doesn't make sense for split shade, + // where notifications are always visible and we effectively go to fully expanded + // shade, that is SHADE_LOCKED. + // Also we might just be switching from regular expanded shade, so we don't want + // to force state transition if it's already correct. + mStatusBarStateController.setState(StatusBarState.SHADE_LOCKED, /* force= */false); + } + updateClockAppearance(); + updateQsState(); + mNotificationStackScrollLayoutController.updateFooter(); + } + private View reInflateStub(int viewId, int stubId, int layoutId, boolean enabled) { View view = mView.findViewById(viewId); if (view != null) { 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 018c4531b3828..c368c904ce9db 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 @@ -976,6 +976,16 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { verify(mTapAgainViewController).show(); } + @Test + public void testRotatingToSplitShadeWithQsExpanded_transitionsToShadeLocked() { + mStatusBarStateController.setState(KEYGUARD); + mNotificationPanelViewController.setQsExpanded(true); + + enableSplitShade(true); + + assertThat(mStatusBarStateController.getState()).isEqualTo(SHADE_LOCKED); + } + @Test public void testSwitchesToCorrectClockInSinglePaneShade() { mStatusBarStateController.setState(KEYGUARD);