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

Commit 709cff4f authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[Flexiglass] Don't expand the shade by dragging on a notification over lockscreen" into main

parents e878a8ce c7a252d5
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_ALL;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;

import static com.google.common.truth.Truth.assertThat;

import static kotlinx.coroutines.flow.FlowKt.emptyFlow;

import static org.mockito.ArgumentMatchers.any;
@@ -761,6 +763,54 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
        ));
    }

    @Test
    @EnableSceneContainer
    public void onTouchEvent_lockScreenExpandSwallowsIt() {
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.getExpandHelper()).thenReturn(mExpandHelper);
        when(mNotificationStackScrollLayout.isExpanded()).thenReturn(true);
        NotificationStackScrollLayoutController.TouchHandler touchHandler =
                mController.getTouchHandler();

        MotionEvent event = MotionEvent.obtain(
                /* downTime= */ 0,
                /* eventTime= */ 0,
                MotionEvent.ACTION_DOWN,
                0,
                0,
                /* metaState= */ 0
        );
        when(mDragDownHelper.onTouchEvent(event)).thenReturn(true);
        boolean touchHandled = touchHandler.onTouchEvent(event);

        assertThat(touchHandled).isTrue();
        verify(mNotificationStackScrollLayout, never()).onScrollTouch(any());
    }

    @Test
    @EnableSceneContainer
    public void onInterceptTouchEvent_lockScreenExpandSwallowsIt() {
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.getExpandHelper()).thenReturn(mExpandHelper);
        when(mNotificationStackScrollLayout.isExpanded()).thenReturn(true);
        NotificationStackScrollLayoutController.TouchHandler touchHandler =
                mController.getTouchHandler();

        MotionEvent event = MotionEvent.obtain(
                /* downTime= */ 0,
                /* eventTime= */ 0,
                MotionEvent.ACTION_DOWN,
                0,
                0,
                /* metaState= */ 0
        );
        when(mDragDownHelper.onInterceptTouchEvent(event)).thenReturn(true);
        boolean touchIntercepted = touchHandler.onInterceptTouchEvent(event);

        assertThat(touchIntercepted).isTrue();
        verify(mNotificationStackScrollLayout, never()).onInterceptTouchEventScroll(event);
    }

    private LogMaker logMatcher(int category, int type) {
        return argThat(new LogMatcher(category, type));
    }
+17 −11
Original line number Diff line number Diff line
@@ -2093,16 +2093,19 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    && !mView.getOnlyScrollingInThisMotion() && guts == null && !skipForDragging) {
                expandWantsIt = mView.getExpandHelper().onInterceptTouchEvent(ev);
            }
            boolean scrollWantsIt = false;
            if (mLongPressedView == null && !mSwipeHelper.isSwiping()
                    && !mView.isExpandingNotification() && !skipForDragging) {
                scrollWantsIt = mView.onInterceptTouchEventScroll(ev);
            }
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt =
                        getLockscreenExpandTouchHelper().onInterceptTouchEvent(ev);
            }
            boolean scrollWantsIt = false;
            if (mLongPressedView == null
                    && !mSwipeHelper.isSwiping() // horizontal swipe to dismiss
                    && !mView.isExpandingNotification() // vertical swipe to expand
                    && !lockscreenExpandWantsIt // vertical swipe to expand over lockscreen
                    && !skipForDragging) {
                scrollWantsIt = mView.onInterceptTouchEventScroll(ev);
            }
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onInterceptTouchEvent(ev);
@@ -2111,6 +2114,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
            if (mLongPressedView == null && !mView.isBeingDragged()
                    && !mView.isExpandingNotification()
                    && !mView.getExpandedInThisMotion()
                    && !lockscreenExpandWantsIt
                    && !mView.getOnlyScrollingInThisMotion()
                    && !mView.getDisallowDismissInThisMotion()
                    && !skipForDragging) {
@@ -2174,26 +2178,28 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    }
                }
            }
            // true when a notification is being dragged to expand over the lockscreen
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt = getLockscreenExpandTouchHelper().onTouchEvent(ev);
            }
            boolean horizontalSwipeWantsIt = false;
            boolean scrollerWantsIt = false;
            // NOTE: the order of these is important. If reversed, onScrollTouch will reset on an
            // UP event, causing horizontalSwipeWantsIt to be set to true on vertical swipes.
            if (mLongPressedView == null && !mView.isBeingDragged()
                    && !expandingNotification
                    && !lockscreenExpandWantsIt
                    && !mView.getExpandedInThisMotion()
                    && !onlyScrollingInThisMotion
                    && !mView.getDisallowDismissInThisMotion()) {
                horizontalSwipeWantsIt = mSwipeHelper.onTouchEvent(ev);
            }
            if (mLongPressedView == null && mView.isExpanded() && !mSwipeHelper.isSwiping()
                    && !expandingNotification && !mView.getDisallowScrollingInThisMotion()) {
                    && !expandingNotification && !lockscreenExpandWantsIt
                    && !mView.getDisallowScrollingInThisMotion()) {
                scrollerWantsIt = mView.onScrollTouch(ev);
            }
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt =
                        getLockscreenExpandTouchHelper().onTouchEvent(ev);
            }
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onTouchEvent(ev);