diff options
| author | 2022-04-25 12:46:35 +0200 | |
|---|---|---|
| committer | 2022-04-25 16:24:51 +0200 | |
| commit | dd40b59c8da6af8e5a1cfc0191a999dc42bc9979 (patch) | |
| tree | 948c43d0bc6326d899894f456ab062e8a5af1420 | |
| parent | b80800cc9e497557eaef92361795370784cfa63f (diff) | |
Split-shade: prevent new shade expansion when shade already expanded
When not in split shade, we can be on QQS and then fully expand the
shade by swiping down on QQS.
When on split-shade, that logic is still there and causes the shade
to try to expand again even though it is already fully expanded.
This then puts the shade in a weird expanding state even though it is
already expanded and interacting with the shade/notifications doesn't
work.
Test: Manually
Fixes: 229829830
Change-Id: Ia2d3de4d2d09cff96f2621544ce3f9b73a7d36d3
2 files changed, 61 insertions, 1 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 29fdfdb65be2..1a4234c2ea0d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1735,6 +1735,11 @@ public class NotificationPanelViewController extends PanelViewController { return false; } + @VisibleForTesting + boolean isQsTracking() { + return mQsTracking; + } + @Override protected boolean isInContentBounds(float x, float y) { float stackScrollerX = mNotificationStackScrollLayoutController.getX(); @@ -2812,7 +2817,7 @@ public class NotificationPanelViewController extends PanelViewController { private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) { if (!isQsExpansionEnabled() || mCollapsedOnDown || (mKeyguardShowing && mKeyguardBypassController.getBypassEnabled()) - || (mKeyguardShowing && mShouldUseSplitNotificationShade)) { + || mShouldUseSplitNotificationShade) { return false; } View header = mKeyguardShowing || mQs == null ? mKeyguardStatusBar : mQs.getHeader(); 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 05fb1f5959ea..71f1f0b0f7cf 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 @@ -56,6 +56,7 @@ import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewParent; import android.view.ViewPropertyAnimator; import android.view.ViewStub; import android.view.accessibility.AccessibilityManager; @@ -99,6 +100,7 @@ import com.android.systemui.media.MediaHierarchyManager; import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.plugins.qs.QS; import com.android.systemui.qrcodescanner.controller.QRCodeScannerController; import com.android.systemui.screenrecord.RecordingController; import com.android.systemui.statusbar.CommandQueue; @@ -334,6 +336,12 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { private NotificationStackSizeCalculator mNotificationStackSizeCalculator; @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; + @Mock + private QS mQs; + @Mock + private View mQsHeader; + @Mock + private ViewParent mViewParent; private NotificationPanelViewController.PanelEventsEmitter mPanelEventsEmitter; private Optional<SysUIUnfoldComponent> mSysUIUnfoldComponent = Optional.empty(); private SysuiStatusBarStateController mStatusBarStateController; @@ -455,6 +463,9 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { return null; }).when(mNotificationShadeWindowController).batchApplyWindowLayoutParams(any()); + when(mView.getParent()).thenReturn(mViewParent); + when(mQs.getHeader()).thenReturn(mQsHeader); + mMainHandler = new Handler(Looper.getMainLooper()); mPanelEventsEmitter = new NotificationPanelViewController.PanelEventsEmitter(); @@ -984,6 +995,50 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { assertThat(mNotificationPanelViewController.mQsExpandImmediate).isTrue(); } + @Test + public void interceptTouchEvent_withinQs_shadeExpanded_startsQsTracking() { + mNotificationPanelViewController.mQs = mQs; + when(mQsFrame.getX()).thenReturn(0f); + when(mQsFrame.getWidth()).thenReturn(1000); + when(mQsHeader.getTop()).thenReturn(0); + when(mQsHeader.getBottom()).thenReturn(1000); + PanelViewController.TouchHandler touchHandler = + mNotificationPanelViewController.createTouchHandler(); + + mNotificationPanelViewController.setExpandedFraction(1f); + touchHandler.onInterceptTouchEvent( + createMotionEvent(/* x= */ 0, /* y= */ 0, MotionEvent.ACTION_DOWN)); + touchHandler.onInterceptTouchEvent( + createMotionEvent(/* x= */ 0, /* y= */ 500, MotionEvent.ACTION_MOVE)); + + assertThat(mNotificationPanelViewController.isQsTracking()).isTrue(); + } + + @Test + public void interceptTouchEvent_withinQs_shadeExpanded_inSplitShade_doesNotStartQsTracking() { + enableSplitShade(true); + mNotificationPanelViewController.mQs = mQs; + when(mQsFrame.getX()).thenReturn(0f); + when(mQsFrame.getWidth()).thenReturn(1000); + when(mQsHeader.getTop()).thenReturn(0); + when(mQsHeader.getBottom()).thenReturn(1000); + PanelViewController.TouchHandler touchHandler = + mNotificationPanelViewController.createTouchHandler(); + + mNotificationPanelViewController.setExpandedFraction(1f); + touchHandler.onInterceptTouchEvent( + createMotionEvent(/* x= */ 0, /* y= */ 0, MotionEvent.ACTION_DOWN)); + touchHandler.onInterceptTouchEvent( + createMotionEvent(/* x= */ 0, /* y= */ 500, MotionEvent.ACTION_MOVE)); + + assertThat(mNotificationPanelViewController.isQsTracking()).isFalse(); + } + + private static MotionEvent createMotionEvent(int x, int y, int action) { + return MotionEvent.obtain( + /* downTime= */ 0, /* eventTime= */ 0, action, x, y, /* metaState= */ 0); + } + private void triggerPositionClockAndNotifications() { mNotificationPanelViewController.closeQs(); } |