diff options
| author | 2023-05-15 11:13:57 +0000 | |
|---|---|---|
| committer | 2023-05-15 11:13:57 +0000 | |
| commit | cc0f84d21205b65520a1646fc84374f5ba22766f (patch) | |
| tree | dcb7dbc0bc9f7ac054bcc0a6344f71a9a632311c | |
| parent | 9a50b8adbc03d694d35613bf19715c44556b1325 (diff) | |
| parent | bffcecfa07368f2886c6293ca2bda18bb48be3ec (diff) | |
Merge "Fixing broken shade after unfolding during expanding QS" into udc-dev
10 files changed, 74 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java index 233667335b72..9235fcc8202f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java @@ -84,7 +84,7 @@ public class DebugDrawable extends Drawable { Color.YELLOW, "calculatePanelHeightShade()"); drawDebugInfo(canvas, (int) mQsController.calculateNotificationsTopPadding( - mNotificationPanelViewController.isExpanding(), + mNotificationPanelViewController.isExpandingOrCollapsing(), mNotificationPanelViewController.getKeyguardNotificationStaticPadding(), mNotificationPanelViewController.getExpandedFraction()), Color.MAGENTA, "calculateNotificationsTopPadding()"); diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index af12bc2ca9f8..e837786ccd89 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -233,7 +233,6 @@ import javax.inject.Inject; import javax.inject.Provider; import kotlin.Unit; - import kotlinx.coroutines.CoroutineDispatcher; @CentralSurfacesComponent.CentralSurfacesScope @@ -415,7 +414,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private final KeyguardClockPositionAlgorithm.Result mClockPositionResult = new KeyguardClockPositionAlgorithm.Result(); - private boolean mIsExpanding; + /** + * Indicates shade (or just QS) is expanding or collapsing but doesn't fully cover KEYGUARD + * state when shade can be expanded with swipe down or swipe down from the top to full QS. + */ + private boolean mIsExpandingOrCollapsing; /** * Indicates drag starting height when swiping down or up on heads-up notifications. @@ -1862,7 +1865,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void expandToNotifications() { - if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpanding())) { + if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpandingOrCollapsing())) { return; } if (mQsController.getExpanded()) { @@ -2269,7 +2272,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump void requestScrollerTopPaddingUpdate(boolean animate) { mNotificationStackScrollLayoutController.updateTopPadding( - mQsController.calculateNotificationsTopPadding(mIsExpanding, + mQsController.calculateNotificationsTopPadding(mIsExpandingOrCollapsing, getKeyguardNotificationStaticPadding(), mExpandedFraction), animate); if (isKeyguardShowing() && mKeyguardBypassController.getBypassEnabled()) { @@ -2322,7 +2325,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } int maxHeight; if (mQsController.isExpandImmediate() || mQsController.getExpanded() - || mIsExpanding && mQsController.getExpandedWhenExpandingStarted() + || mIsExpandingOrCollapsing && mQsController.getExpandedWhenExpandingStarted() || mPulsing || mSplitShadeEnabled) { maxHeight = mQsController.calculatePanelHeightExpanded( mClockPositionResult.stackScrollerPadding); @@ -2342,8 +2345,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return maxHeight; } - public boolean isExpanding() { - return mIsExpanding; + @Override + public boolean isExpandingOrCollapsing() { + float lockscreenExpansionProgress = mQsController.getLockscreenShadeDragProgress(); + return mIsExpandingOrCollapsing + || (0 < lockscreenExpansionProgress && lockscreenExpansionProgress < 1); } private void onHeightUpdated(float expandedHeight) { @@ -2355,7 +2361,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mExpandedFraction, isExpanded(), mTracking, mExpansionDragDownAmountPx); } if (!mQsController.getExpanded() || mQsController.isExpandImmediate() - || mIsExpanding && mQsController.getExpandedWhenExpandingStarted()) { + || mIsExpandingOrCollapsing && mQsController.getExpandedWhenExpandingStarted()) { // Updating the clock position will set the top padding which might // trigger a new panel height and re-position the clock. // This is a circular dependency and should be avoided, otherwise we'll have @@ -2493,7 +2499,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mNotificationStackScrollLayoutController.onExpansionStopped(); mHeadsUpManager.onExpandingFinished(); mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed()); - mIsExpanding = false; + mIsExpandingOrCollapsing = false; mMediaHierarchyManager.setCollapsingShadeFromQS(false); mMediaHierarchyManager.setQsExpanded(mQsController.getExpanded()); if (isFullyCollapsed()) { @@ -3199,7 +3205,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mDisplayTopInset="); ipw.println(mDisplayTopInset); ipw.print("mDisplayRightInset="); ipw.println(mDisplayRightInset); ipw.print("mDisplayLeftInset="); ipw.println(mDisplayLeftInset); - ipw.print("mIsExpanding="); ipw.println(mIsExpanding); + ipw.print("mIsExpandingOrCollapsing="); ipw.println(mIsExpandingOrCollapsing); ipw.print("mHeadsUpStartHeight="); ipw.println(mHeadsUpStartHeight); ipw.print("mListenForHeadsUp="); ipw.println(mListenForHeadsUp); ipw.print("mNavigationBarBottomHeight="); ipw.println(mNavigationBarBottomHeight); @@ -3431,7 +3437,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump void notifyExpandingStarted() { if (!mExpanding) { mExpanding = true; - mIsExpanding = true; + mIsExpandingOrCollapsing = true; mQsController.onExpandingStarted(mQsController.getFullyExpanded()); } } @@ -3792,7 +3798,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } else if (mBarState == SHADE_LOCKED) { return true; } else { - // case of two finger swipe from the top of keyguard + // case of swipe from the top of keyguard to expanded QS return mQsController.computeExpansionFraction() == 1; } } @@ -4044,7 +4050,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump * shade QS are always expanded */ private void closeQsIfPossible() { - boolean openOrOpening = isShadeFullyExpanded() || isExpanding(); + boolean openOrOpening = isShadeFullyExpanded() || isExpandingOrCollapsing(); if (!(mSplitShadeEnabled && openOrOpening)) { mQsController.closeQs(); } @@ -4767,7 +4773,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // If pulse is expanding already, let's give it the touch. There are situations // where the panel starts expanding even though we're also pulsing - boolean pulseShouldGetTouch = (!mIsExpanding + boolean pulseShouldGetTouch = (!mIsExpandingOrCollapsing && !mQsController.shouldQuickSettingsIntercept(mDownX, mDownY, 0)) || mPulseExpansionHandler.isExpanding(); if (pulseShouldGetTouch && mPulseExpansionHandler.onTouchEvent(event)) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java index e08bc33c1ccd..d0a3cbbf0b02 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java @@ -78,6 +78,11 @@ public interface ShadeController { boolean isShadeFullyOpen(); /** + * Returns whether shade or QS are currently opening or collapsing. + */ + boolean isExpandingOrCollapsing(); + + /** * Add a runnable for NotificationPanelView to post when the panel is expanded. * * @param action the action to post diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index c71467b99961..d00dab633014 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -164,6 +164,11 @@ public final class ShadeControllerImpl implements ShadeController { } @Override + public boolean isExpandingOrCollapsing() { + return mNotificationPanelViewController.isExpandingOrCollapsing(); + } + + @Override public void postOnShadeExpanded(Runnable executable) { mNotificationPanelViewController.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt index d5a9e953c914..f75047c2072a 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt @@ -48,7 +48,7 @@ interface ShadeViewController { fun expandToNotifications() /** Returns whether the shade is expanding or collapsing itself or quick settings. */ - val isExpanding: Boolean + val isExpandingOrCollapsing: Boolean /** * Returns whether the shade height is greater than zero (i.e. partially or fully expanded), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java index 37e77766c889..0ccc81981e58 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java @@ -339,7 +339,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba mHeadsUpManager.unpinAll(true /* userUnpinned */); mMetricsLogger.count("panel_open", 1); } else if (!mQsController.getExpanded() - && !mShadeViewController.isExpanding()) { + && !mShadeViewController.isExpandingOrCollapsing()) { mQsController.flingQs(0 /* velocity */, ShadeViewController.FLING_EXPAND); mMetricsLogger.count("panel_open_qs", 1); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 263566e69c88..5c99f34ce2df 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1224,6 +1224,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // By default turning off the screen also closes the shade. // We want to make sure that the shade status is kept after folding/unfolding. boolean isShadeOpen = mShadeController.isShadeFullyOpen(); + boolean isShadeExpandingOrCollapsing = mShadeController.isExpandingOrCollapsing(); boolean leaveOpen = isShadeOpen && !willGoToSleep && mState == SHADE; if (DEBUG) { Log.d(TAG, String.format( @@ -1231,14 +1232,15 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { + "isFolded=%s, " + "willGoToSleep=%s, " + "isShadeOpen=%s, " + + "isShadeExpandingOrCollapsing=%s, " + "leaveOpen=%s", - isFolded, willGoToSleep, isShadeOpen, leaveOpen)); + isFolded, willGoToSleep, isShadeOpen, isShadeExpandingOrCollapsing, leaveOpen)); } if (leaveOpen) { // below makes shade stay open when going from folded to unfolded mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } - if (mState != SHADE && isShadeOpen) { + if (mState != SHADE && (isShadeOpen || isShadeExpandingOrCollapsing)) { // When device state changes on KEYGUARD/SHADE_LOCKED we don't want to keep the state of // the shade and instead we open clean state of keyguard with shade closed. // Normally some parts of QS state (like expanded/collapsed) are persisted and diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index f2fbd7d52ac3..414a2ba1ad91 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -488,7 +488,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb final boolean hideBouncerOverDream = mDreamOverlayStateController.isOverlayActive() && (mShadeViewController.isExpanded() - || mShadeViewController.isExpanding()); + || mShadeViewController.isExpandingOrCollapsing()); final boolean isUserTrackingStarted = event.getFraction() != EXPANSION_HIDDEN && event.getTracking(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 48e0b53fc931..c5495e1fd024 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -902,6 +902,13 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test + public void isExpandingOrCollapsing_returnsTrue_whenQsLockscreenDragInProgress() { + when(mQsController.getLockscreenShadeDragProgress()).thenReturn(0.5f); + assertThat(mNotificationPanelViewController.isExpandingOrCollapsing()).isTrue(); + } + + + @Test public void getMaxPanelTransitionDistance_inSplitShade_withHeadsUp_returnsBiggerValue() { enableSplitShade(true); mNotificationPanelViewController.expandToQs(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index c83769d84d2a..cf6d5b55137d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -335,6 +335,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { private final FakeFeatureFlags mFeatureFlags = new FakeFeatureFlags(); private final InitController mInitController = new InitController(); private final DumpManager mDumpManager = new DumpManager(); + private final ScreenLifecycle mScreenLifecycle = new ScreenLifecycle(mDumpManager); @Before public void setup() throws Exception { @@ -487,7 +488,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mUserSwitcherController, mBatteryController, mColorExtractor, - new ScreenLifecycle(mDumpManager), + mScreenLifecycle, mWakefulnessLifecycle, mStatusBarStateController, Optional.of(mBubbles), @@ -554,6 +555,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { return mViewRootImpl; } }; + mScreenLifecycle.addObserver(mCentralSurfaces.mScreenObserver); mCentralSurfaces.initShadeVisibilityListener(); when(mViewRootImpl.getOnBackInvokedDispatcher()) .thenReturn(mOnBackInvokedDispatcher); @@ -1253,6 +1255,32 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test + public void deviceStateChange_unfolded_shadeExpanding_onKeyguard_closesQS() { + setFoldedStates(FOLD_STATE_FOLDED); + setGoToSleepStates(FOLD_STATE_FOLDED); + mCentralSurfaces.setBarStateForTest(KEYGUARD); + when(mNotificationPanelViewController.isExpandingOrCollapsing()).thenReturn(true); + + setDeviceState(FOLD_STATE_UNFOLDED); + mScreenLifecycle.dispatchScreenTurnedOff(); + + verify(mQuickSettingsController).closeQs(); + } + + @Test + public void deviceStateChange_unfolded_shadeExpanded_onKeyguard_closesQS() { + setFoldedStates(FOLD_STATE_FOLDED); + setGoToSleepStates(FOLD_STATE_FOLDED); + mCentralSurfaces.setBarStateForTest(KEYGUARD); + when(mNotificationPanelViewController.isShadeFullyExpanded()).thenReturn(true); + + setDeviceState(FOLD_STATE_UNFOLDED); + mScreenLifecycle.dispatchScreenTurnedOff(); + + verify(mQuickSettingsController).closeQs(); + } + + @Test public void startActivityDismissingKeyguard_isShowingAndIsOccluded() { when(mKeyguardStateController.isShowing()).thenReturn(true); when(mKeyguardStateController.isOccluded()).thenReturn(true); |