Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd40b59c authored by Christian Göllner's avatar Christian Göllner
Browse files

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
parent b80800cc
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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();
+55 −0
Original line number Diff line number Diff line
@@ -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();
    }