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

Commit b794d707 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[CS] Remove CentralSurfaces from OverviewProxyService; just ask shade.

Since OverviewProxyService already has access to ShadeViewController and
the CentralSurfaces methods just proxy to the shade anyway, have
OverviewProxyService ask the shade directly.

This also refactors the #onInputFocusTransfer method into three separate
methods instead of having boolean parameters.

Bug: 277764509
Test: small swipe down from launcher -> verify input focus transfer
started then cancelled
Test: fling down from launcher -> verify input focus transfer started
and completed successfully
Test: 2 finger trackpad swipe down from home on tablet -> opens shade
Test: 3 finger trackpad swipe down while in app on tablet -> opens shade
Test: atest NotificationPanelViewcontrollerTest OverviewProxyServiceTest

Change-Id: I7e2429999e4805d1ad9c239359a0bf7249050a2a
parent cd81b370
Loading
Loading
Loading
Loading
+31 −40
Original line number Diff line number Diff line
@@ -104,7 +104,6 @@ import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.StatusBarWindowCallback;
import com.android.systemui.statusbar.policy.CallbackController;
import com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder;
@@ -146,7 +145,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private final SceneContainerFlags mSceneContainerFlags;
    private final Executor mMainExecutor;
    private final ShellInterface mShellInterface;
    private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;
    private final Lazy<ShadeViewController> mShadeViewControllerLazy;
    private SysUiState mSysUiState;
    private final Handler mHandler;
@@ -205,7 +203,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        public void onStatusBarTouchEvent(MotionEvent event) {
            verifyCallerAndClearCallingIdentity("onStatusBarTouchEvent", () -> {
                // TODO move this logic to message queue
                mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> {
                if (event.getActionMasked() == ACTION_DOWN) {
                    mShadeViewControllerLazy.get().startExpandLatencyTracking();
                }
@@ -221,9 +218,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                        if (mSceneContainerFlags.isEnabled()) {
                            mSceneInteractor.get().setVisible(true, "swipe down on launcher");
                        } else {
                                centralSurfaces.onInputFocusTransfer(
                                        mInputFocusTransferStarted, false /* cancel */,
                                        0 /* velocity */);
                            mShadeViewControllerLazy.get().startInputFocusTransfer();
                        }
                    }
                    if (action == ACTION_UP || action == ACTION_CANCEL) {
@@ -232,22 +227,22 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                        if (!mSceneContainerFlags.isEnabled()) {
                            float velocity = (event.getY() - mInputFocusTransferStartY)
                                    / (event.getEventTime() - mInputFocusTransferStartMillis);
                                centralSurfaces.onInputFocusTransfer(mInputFocusTransferStarted,
                                        action == ACTION_CANCEL,
                                        velocity);
                            if (action == ACTION_CANCEL) {
                                mShadeViewControllerLazy.get().cancelInputFocusTransfer();
                            } else {
                                mShadeViewControllerLazy.get().finishInputFocusTransfer(velocity);
                            }
                        }
                    }
                    event.recycle();
                });
            });
            });
        }

        @Override
        public void onStatusBarTrackpadEvent(MotionEvent event) {
            verifyCallerAndClearCallingIdentityPostMain("onStatusBarTrackpadEvent", () ->
                    mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces ->
                            centralSurfaces.onStatusBarTrackpadEvent(event)));
                    mShadeViewControllerLazy.get().handleExternalTouch(event));
        }

        @Override
@@ -569,7 +564,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            CommandQueue commandQueue,
            ShellInterface shellInterface,
            Lazy<NavigationBarController> navBarControllerLazy,
            Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            Lazy<ShadeViewController> shadeViewControllerLazy,
            ScreenPinningRequest screenPinningRequest,
            NavigationModeController navModeController,
@@ -597,7 +591,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        mSceneContainerFlags = sceneContainerFlags;
        mMainExecutor = mainExecutor;
        mShellInterface = shellInterface;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mShadeViewControllerLazy = shadeViewControllerLazy;
        mHandler = new Handler();
        mNavBarControllerLazy = navBarControllerLazy;
@@ -772,10 +765,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    public void cleanupAfterDeath() {
        if (mInputFocusTransferStarted) {
            mHandler.post(() -> {
                mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> {
                mInputFocusTransferStarted = false;
                    centralSurfaces.onInputFocusTransfer(false, true /* cancel */, 0 /* velocity */);
                });
                mShadeViewControllerLazy.get().cancelInputFocusTransfer();
            });
        }
        startConnectionToCurrentUser();
+32 −9
Original line number Diff line number Diff line
@@ -2247,7 +2247,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    @Override
    public void startWaitingForExpandGesture() {
    public void startInputFocusTransfer() {
        if (!mCommandQueue.panelsEnabled()) {
            return;
        }
        if (!isFullyCollapsed()) {
            return;
        }
@@ -2257,16 +2260,36 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    @Override
    public void stopWaitingForExpandGesture(boolean cancel, final float velocity) {
    public void cancelInputFocusTransfer() {
        if (!mCommandQueue.panelsEnabled()) {
            return;
        }
        if (mExpectingSynthesizedDown) {
            mExpectingSynthesizedDown = false;
            if (cancel) {
            collapse(false /* delayed */, 1.0f /* speedUpFactor */);
            } else {
            onTrackingStopped(false);
        }
    }

    /**
     * There are two scenarios behind this function call. First, input focus transfer has
     * successfully happened and this view already received synthetic DOWN event.
     * (mExpectingSynthesizedDown == false). Do nothing.
     *
     * Second, before input focus transfer finished, user may have lifted finger in previous window
     * and this window never received synthetic DOWN event. (mExpectingSynthesizedDown == true). In
     * this case, we use the velocity to trigger fling event.
     */
    @Override
    public void finishInputFocusTransfer(final float velocity) {
        if (!mCommandQueue.panelsEnabled()) {
            return;
        }
        if (mExpectingSynthesizedDown) {
            mExpectingSynthesizedDown = false;
            // Window never will receive touch events that typically trigger haptic on open.
            maybeVibrateOnOpening(false /* openingWithTouch */);
            fling(velocity > 1f ? 1000f * velocity : 0  /* expand */);
            }
            onTrackingStopped(false);
        }
    }
+0 −18
Original line number Diff line number Diff line
@@ -43,24 +43,6 @@ interface ShadeSurface : ShadeViewController {
    /** Cancels the views current animation. */
    fun cancelAnimation()

    /** Input focus transfer is about to happen. */
    fun startWaitingForExpandGesture()

    /**
     * Called when this view is no longer waiting for input focus transfer.
     *
     * There are two scenarios behind this function call. First, input focus transfer has
     * successfully happened and this view already received synthetic DOWN event.
     * (mExpectingSynthesizedDown == false). Do nothing.
     *
     * Second, before input focus transfer finished, user may have lifted finger in previous window
     * and this window never received synthetic DOWN event. (mExpectingSynthesizedDown == true). In
     * this case, we use the velocity to trigger fling event.
     *
     * @param velocity unit is in px / millis
     */
    fun stopWaitingForExpandGesture(cancel: Boolean, velocity: Float)

    /** Animates the view from its current alpha to zero then runs the runnable. */
    fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator

+26 −1
Original line number Diff line number Diff line
@@ -239,9 +239,34 @@ interface ShadeViewController {
    )
    fun isFullyExpanded(): Boolean

    /** Sends an external (e.g. Status Bar) touch event to the Shade touch handler. */
    /**
     * Sends an external (e.g. Status Bar) touch event to the Shade touch handler.
     *
     * This is different from [startInputFocusTransfer] as it doesn't rely on setting the launcher
     * window slippery to allow the frameworks to route those events after passing the initial
     * threshold.
     */
    fun handleExternalTouch(event: MotionEvent): Boolean

    /**
     * Triggered when an input focus transfer gesture has started.
     *
     * Used to dispatch initial touch events before crossing the threshold to pull down the
     * notification shade. After that, since the launcher window is set to slippery, input
     * frameworks take care of routing the events to the notification shade.
     */
    fun startInputFocusTransfer()

    /** Triggered when the input focus transfer was cancelled. */
    fun cancelInputFocusTransfer()

    /**
     * Triggered when the input focus transfer has finished successfully.
     *
     * @param velocity unit is in px / millis
     */
    fun finishInputFocusTransfer(velocity: Float)

    /**
     * Performs haptic feedback from a view with a haptic feedback constant.
     *
+3 −0
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ class ShadeViewControllerEmptyImpl @Inject constructor() : ShadeViewController {
    override fun handleExternalTouch(event: MotionEvent): Boolean {
        return false
    }
    override fun startInputFocusTransfer() {}
    override fun cancelInputFocusTransfer() {}
    override fun finishInputFocusTransfer(velocity: Float) {}
    override fun performHapticFeedback(constant: Int) {}

    override val shadeHeadsUpTracker = ShadeHeadsUpTrackerEmptyImpl()
Loading