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

Commit 333522ba authored by Justin Weir's avatar Justin Weir
Browse files

Touch handling and other tiny cleanups in NPVC

The interface used for the touch handling handoff between Status Bar
and Shade is nearly the same as Gefingerpoken, so this change will
remove the redundancy. It also removes the usage of the view as an
an unnecessary middleman by passing events directly to the Shade
touch handler. Also includes some trivial warning cleanup. This was
originally the first in a chain of CLs attempting to fix multitouch
in the shade, but the follow up CL was too risky for QPR.

Bug: 132458655
Test: manual and atest
Change-Id: Iabb3484e43573b6e4f7755d1abe0a76512828834
parent dc94ae96
Loading
Loading
Loading
Loading
+25 −38
Original line number Original line Diff line number Diff line
@@ -119,6 +119,7 @@ import com.android.keyguard.dagger.KeyguardStatusViewComponent;
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
import com.android.systemui.DejankUtils;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.Dumpable;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.Interpolators;
@@ -162,14 +163,12 @@ import com.android.systemui.plugins.FalsingManager.FalsingTapListener;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.screenrecord.RecordingController;
import com.android.systemui.shade.transition.ShadeTransitionController;
import com.android.systemui.shade.transition.ShadeTransitionController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.NotificationShelfController;
@@ -357,6 +356,7 @@ public final class NotificationPanelViewController implements Dumpable {
    private final AlternateBouncerInteractor mAlternateBouncerInteractor;
    private final AlternateBouncerInteractor mAlternateBouncerInteractor;
    private final QuickSettingsController mQsController;
    private final QuickSettingsController mQsController;
    private final InteractionJankMonitor mInteractionJankMonitor;
    private final InteractionJankMonitor mInteractionJankMonitor;
    private final TouchHandler mTouchHandler = new TouchHandler();


    private long mDownTime;
    private long mDownTime;
    private boolean mTouchSlopExceededBeforeDown;
    private boolean mTouchSlopExceededBeforeDown;
@@ -541,7 +541,7 @@ public final class NotificationPanelViewController implements Dumpable {
    private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
    private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
    private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
    private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
    private float mMinExpandHeight;
    private float mMinExpandHeight;
    private ShadeHeightLogger mShadeHeightLogger;
    private final ShadeHeightLogger mShadeHeightLogger;
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mHasVibratedOnOpen = false;
    private boolean mHasVibratedOnOpen = false;
    private int mFixedDuration = NO_FIXED_DURATION;
    private int mFixedDuration = NO_FIXED_DURATION;
@@ -586,15 +586,15 @@ public final class NotificationPanelViewController implements Dumpable {
    private boolean mGestureWaitForTouchSlop;
    private boolean mGestureWaitForTouchSlop;
    private boolean mIgnoreXTouchSlop;
    private boolean mIgnoreXTouchSlop;
    private boolean mExpandLatencyTracking;
    private boolean mExpandLatencyTracking;
    private DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel;
    private final DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel;
    private OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel;
    private final OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel;
    private LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel;
    private final LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel;
    private GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel;
    private final GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel;
    private LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel;
    private final LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel;


    private KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private final KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private final KeyguardInteractor mKeyguardInteractor;
    private final KeyguardInteractor mKeyguardInteractor;
    private CoroutineDispatcher mMainDispatcher;
    private final CoroutineDispatcher mMainDispatcher;
    private boolean mIsOcclusionTransitionRunning = false;
    private boolean mIsOcclusionTransitionRunning = false;
    private int mDreamingToLockscreenTransitionTranslationY;
    private int mDreamingToLockscreenTransitionTranslationY;
    private int mOccludedToLockscreenTransitionTranslationY;
    private int mOccludedToLockscreenTransitionTranslationY;
@@ -708,12 +708,10 @@ public final class NotificationPanelViewController implements Dumpable {
            QuickSettingsController quickSettingsController,
            QuickSettingsController quickSettingsController,
            FragmentService fragmentService,
            FragmentService fragmentService,
            ContentResolver contentResolver,
            ContentResolver contentResolver,
            RecordingController recordingController,
            ShadeHeaderController shadeHeaderController,
            ShadeHeaderController shadeHeaderController,
            ScreenOffAnimationController screenOffAnimationController,
            ScreenOffAnimationController screenOffAnimationController,
            LockscreenGestureLogger lockscreenGestureLogger,
            LockscreenGestureLogger lockscreenGestureLogger,
            ShadeExpansionStateManager shadeExpansionStateManager,
            ShadeExpansionStateManager shadeExpansionStateManager,
            NotificationRemoteInputManager remoteInputManager,
            Optional<SysUIUnfoldComponent> unfoldComponent,
            Optional<SysUIUnfoldComponent> unfoldComponent,
            SysUiState sysUiState,
            SysUiState sysUiState,
            Provider<KeyguardBottomAreaViewController> keyguardBottomAreaViewControllerProvider,
            Provider<KeyguardBottomAreaViewController> keyguardBottomAreaViewControllerProvider,
@@ -771,7 +769,7 @@ public final class NotificationPanelViewController implements Dumpable {
        });
        });


        mView.addOnLayoutChangeListener(new ShadeLayoutChangeListener());
        mView.addOnLayoutChangeListener(new ShadeLayoutChangeListener());
        mView.setOnTouchListener(createTouchHandler());
        mView.setOnTouchListener(getTouchHandler());
        mView.setOnConfigurationChangedListener(config -> loadDimens());
        mView.setOnConfigurationChangedListener(config -> loadDimens());


        mResources = mView.getResources();
        mResources = mView.getResources();
@@ -1643,10 +1641,6 @@ public final class NotificationPanelViewController implements Dumpable {
        return mDozing && mDozeParameters.getAlwaysOn();
        return mDozing && mDozeParameters.getAlwaysOn();
    }
    }


    boolean isDozing() {
        return mDozing;
    }

    private boolean hasVisibleNotifications() {
    private boolean hasVisibleNotifications() {
        return mNotificationStackScrollLayoutController
        return mNotificationStackScrollLayoutController
                .getVisibleNotificationCount() != 0
                .getVisibleNotificationCount() != 0
@@ -3336,8 +3330,8 @@ public final class NotificationPanelViewController implements Dumpable {
    }
    }


    @VisibleForTesting
    @VisibleForTesting
    TouchHandler createTouchHandler() {
    TouchHandler getTouchHandler() {
        return new TouchHandler();
        return mTouchHandler;
    }
    }


    public NotificationStackScrollLayoutController getNotificationStackScrollLayoutController() {
    public NotificationStackScrollLayoutController getNotificationStackScrollLayoutController() {
@@ -3985,14 +3979,14 @@ public final class NotificationPanelViewController implements Dumpable {
        return mView.post(action);
        return mView.post(action);
    }
    }


    /** */
    /** Sends an external (e.g. Status Bar) intercept touch event to the Shade touch handler. */
    public boolean sendInterceptTouchEventToView(MotionEvent event) {
    public boolean handleExternalInterceptTouch(MotionEvent event) {
        return mView.onInterceptTouchEvent(event);
        return mTouchHandler.onInterceptTouchEvent(event);
    }
    }


    /** */
    /** Sends an external (e.g. Status Bar) touch event to the Shade touch handler. */
    public boolean sendTouchEventToView(MotionEvent event) {
    public boolean handleExternalTouch(MotionEvent event) {
        return mView.dispatchTouchEvent(event);
        return mTouchHandler.onTouchEvent(event);
    }
    }


    /** */
    /** */
@@ -4010,14 +4004,6 @@ public final class NotificationPanelViewController implements Dumpable {
        return mView.isEnabled();
        return mView.isEnabled();
    }
    }


    int getDisplayRightInset() {
        return mDisplayRightInset;
    }

    int getDisplayLeftInset() {
        return mDisplayLeftInset;
    }

    float getOverStretchAmount() {
    float getOverStretchAmount() {
        return mOverStretchAmount;
        return mOverStretchAmount;
    }
    }
@@ -4026,10 +4012,6 @@ public final class NotificationPanelViewController implements Dumpable {
        return mMinFraction;
        return mMinFraction;
    }
    }


    boolean getCollapsedOnDown() {
        return mCollapsedOnDown;
    }

    int getNavigationBarBottomHeight() {
    int getNavigationBarBottomHeight() {
        return mNavigationBarBottomHeight;
        return mNavigationBarBottomHeight;
    }
    }
@@ -4593,7 +4575,7 @@ public final class NotificationPanelViewController implements Dumpable {
    }
    }


    /** Handles MotionEvents for the Shade. */
    /** Handles MotionEvents for the Shade. */
    public final class TouchHandler implements View.OnTouchListener {
    public final class TouchHandler implements View.OnTouchListener, Gefingerpoken {
        private long mLastTouchDownTime = -1L;
        private long mLastTouchDownTime = -1L;


        /** @see ViewGroup#onInterceptTouchEvent(MotionEvent) */
        /** @see ViewGroup#onInterceptTouchEvent(MotionEvent) */
@@ -4739,6 +4721,11 @@ public final class NotificationPanelViewController implements Dumpable {


        @Override
        @Override
        public boolean onTouch(View v, MotionEvent event) {
        public boolean onTouch(View v, MotionEvent event) {
            return onTouchEvent(event);
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (event.getDownTime() == mLastTouchDownTime) {
                if (event.getDownTime() == mLastTouchDownTime) {
                    // An issue can occur when swiping down after unlock, where multiple down
                    // An issue can occur when swiping down after unlock, where multiple down
+1 −1
Original line number Original line Diff line number Diff line
@@ -342,7 +342,7 @@ public class NotificationShadeWindowViewController {
                MotionEvent cancellation = MotionEvent.obtain(ev);
                MotionEvent cancellation = MotionEvent.obtain(ev);
                cancellation.setAction(MotionEvent.ACTION_CANCEL);
                cancellation.setAction(MotionEvent.ACTION_CANCEL);
                mStackScrollLayout.onInterceptTouchEvent(cancellation);
                mStackScrollLayout.onInterceptTouchEvent(cancellation);
                mNotificationPanelViewController.sendInterceptTouchEventToView(cancellation);
                mNotificationPanelViewController.handleExternalInterceptTouch(cancellation);
                cancellation.recycle();
                cancellation.recycle();
            }
            }


+4 −27
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.widget.LinearLayout;


import com.android.internal.policy.SystemBarUtils;
import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
@@ -60,7 +61,7 @@ public class PhoneStatusBarView extends FrameLayout {
    private Rect mDisplaySize;
    private Rect mDisplaySize;
    private int mStatusBarHeight;
    private int mStatusBarHeight;
    @Nullable
    @Nullable
    private TouchEventHandler mTouchEventHandler;
    private Gefingerpoken mTouchEventHandler;


    /**
    /**
     * Draw this many pixels into the left/right side of the cutout to optimally use the space
     * Draw this many pixels into the left/right side of the cutout to optimally use the space
@@ -72,7 +73,7 @@ public class PhoneStatusBarView extends FrameLayout {
        mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class);
        mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class);
    }
    }


    void setTouchEventHandler(TouchEventHandler handler) {
    void setTouchEventHandler(Gefingerpoken handler) {
        mTouchEventHandler = handler;
        mTouchEventHandler = handler;
    }
    }


@@ -185,7 +186,7 @@ public class PhoneStatusBarView extends FrameLayout {
            );
            );
            return true;
            return true;
        }
        }
        return mTouchEventHandler.handleTouchEvent(event);
        return mTouchEventHandler.onTouchEvent(event);
    }
    }


    @Override
    @Override
@@ -267,28 +268,4 @@ public class PhoneStatusBarView extends FrameLayout {
                insets.second,
                insets.second,
                getPaddingBottom());
                getPaddingBottom());
    }
    }

    /**
     * A handler responsible for all touch event handling on the status bar.
     *
     * Touches that occur on the status bar view may have ramifications for the notification
     * panel (e.g. a touch that pulls down the shade could start on the status bar), so this
     * interface provides a way to notify the panel controller when these touches occur.
     *
     * The handler will be notified each time {@link PhoneStatusBarView#onTouchEvent} and
     * {@link PhoneStatusBarView#onInterceptTouchEvent} are called.
     **/
    public interface TouchEventHandler {
        /** Called each time {@link PhoneStatusBarView#onInterceptTouchEvent} is called. */
        void onInterceptTouchEvent(MotionEvent event);

        /**
         * Called each time {@link PhoneStatusBarView#onTouchEvent} is called.
         *
         * Should return true if the touch was handled by this handler and false otherwise. The
         * return value from the handler will be returned from
         * {@link PhoneStatusBarView#onTouchEvent}.
         */
        boolean handleTouchEvent(MotionEvent event);
    }
}
}
+9 −8
Original line number Original line Diff line number Diff line
@@ -24,11 +24,11 @@ import android.view.MotionEvent
import android.view.View
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver
import com.android.systemui.Gefingerpoken
import com.android.systemui.R
import com.android.systemui.R
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeLogger
import com.android.systemui.shade.ShadeLogger
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
import com.android.systemui.statusbar.phone.PhoneStatusBarView.TouchEventHandler
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.unfold.SysUIUnfoldComponent
import com.android.systemui.unfold.SysUIUnfoldComponent
import com.android.systemui.unfold.UNFOLD_STATUS_BAR
import com.android.systemui.unfold.UNFOLD_STATUS_BAR
@@ -131,7 +131,7 @@ class PhoneStatusBarViewController private constructor(
    }
    }


    /** Called when a touch event occurred on {@link PhoneStatusBarView}. */
    /** Called when a touch event occurred on {@link PhoneStatusBarView}. */
    fun onTouchEvent(event: MotionEvent) {
    fun onTouch(event: MotionEvent) {
        if (centralSurfaces.statusBarWindowState == WINDOW_STATE_SHOWING) {
        if (centralSurfaces.statusBarWindowState == WINDOW_STATE_SHOWING) {
            val upOrCancel =
            val upOrCancel =
                    event.action == MotionEvent.ACTION_UP ||
                    event.action == MotionEvent.ACTION_UP ||
@@ -141,13 +141,14 @@ class PhoneStatusBarViewController private constructor(
        }
        }
    }
    }


    inner class PhoneStatusBarViewTouchHandler : TouchEventHandler {
    inner class PhoneStatusBarViewTouchHandler : Gefingerpoken {
        override fun onInterceptTouchEvent(event: MotionEvent) {
        override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
            onTouchEvent(event)
            onTouch(event)
            return false
        }
        }


        override fun handleTouchEvent(event: MotionEvent): Boolean {
        override fun onTouchEvent(event: MotionEvent): Boolean {
            onTouchEvent(event)
            onTouch(event)


            // If panels aren't enabled, ignore the gesture and don't pass it down to the
            // If panels aren't enabled, ignore the gesture and don't pass it down to the
            // panel view.
            // panel view.
@@ -174,7 +175,7 @@ class PhoneStatusBarViewController private constructor(
                    return true
                    return true
                }
                }
            }
            }
            return centralSurfaces.notificationPanelViewController.sendTouchEventToView(event)
            return centralSurfaces.notificationPanelViewController.handleExternalTouch(event)
        }
        }
    }
    }


+0 −2
Original line number Original line Diff line number Diff line
@@ -536,12 +536,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
                mQsController,
                mQsController,
                mFragmentService,
                mFragmentService,
                mContentResolver,
                mContentResolver,
                mRecordingController,
                mShadeHeaderController,
                mShadeHeaderController,
                mScreenOffAnimationController,
                mScreenOffAnimationController,
                mLockscreenGestureLogger,
                mLockscreenGestureLogger,
                mShadeExpansionStateManager,
                mShadeExpansionStateManager,
                mNotificationRemoteInputManager,
                mSysUIUnfoldComponent,
                mSysUIUnfoldComponent,
                mSysUiState,
                mSysUiState,
                () -> mKeyguardBottomAreaViewController,
                () -> mKeyguardBottomAreaViewController,
Loading