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

Commit 3c0ab176 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes from topic "caitlinshk-remove-cs-from-screenpin" into main

* changes:
  [CS] Remove CentralSurfaces from OverviewProxyService; just ask shade.
  [CS] Remove CentralSurfaces from ScreenPinningRequest.
parents 6774ac7e b794d707
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;
@@ -145,7 +144,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;
@@ -204,7 +202,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();
                }
@@ -220,9 +217,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) {
@@ -231,22 +226,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
@@ -568,7 +563,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,
@@ -596,7 +590,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        mSceneContainerFlags = sceneContainerFlags;
        mMainExecutor = mainExecutor;
        mShellInterface = shellInterface;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mShadeViewControllerLazy = shadeViewControllerLazy;
        mHandler = new Handler();
        mNavBarControllerLazy = navBarControllerLazy;
@@ -771,10 +764,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();
+9 −12
Original line number Diff line number Diff line
@@ -57,15 +57,14 @@ import com.android.systemui.CoreStartable;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.navigationbar.NavigationBarController;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.util.leak.RotationUtils;

import java.util.ArrayList;
import java.util.Optional;

import javax.inject.Inject;

@@ -77,8 +76,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
    private static final String TAG = "ScreenPinningRequest";

    private final Context mContext;
    private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;

    private final Lazy<NavigationBarController> mNavigationBarControllerLazy;
    private final AccessibilityManager mAccessibilityService;
    private final WindowManager mWindowManager;
    private final BroadcastDispatcher mBroadcastDispatcher;
@@ -101,12 +99,12 @@ public class ScreenPinningRequest implements View.OnClickListener,
    @Inject
    public ScreenPinningRequest(
            Context context,
            Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            NavigationModeController navigationModeController,
            Lazy<NavigationBarController> navigationBarControllerLazy,
            BroadcastDispatcher broadcastDispatcher,
            UserTracker userTracker) {
        mContext = context;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mNavigationBarControllerLazy = navigationBarControllerLazy;
        mAccessibilityService = (AccessibilityManager)
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
        mWindowManager = (WindowManager)
@@ -289,15 +287,14 @@ public class ScreenPinningRequest implements View.OnClickListener,
                        .setVisibility(View.INVISIBLE);
            }

            final Optional<CentralSurfaces> centralSurfacesOptional =
                    mCentralSurfacesOptionalLazy.get();
            boolean recentsVisible =
                    centralSurfacesOptional.map(CentralSurfaces::isOverviewEnabled).orElse(false);
            int displayId = mContext.getDisplayId();
            boolean overviewEnabled =
                    mNavigationBarControllerLazy.get().isOverviewEnabled(displayId);
            boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled();
            int descriptionStringResId;
            if (QuickStepContract.isGesturalMode(mNavBarMode)) {
                descriptionStringResId = R.string.screen_pinning_description_gestural;
            } else if (recentsVisible) {
            } else if (overviewEnabled) {
                mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(VISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(INVISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(INVISIBLE);
@@ -314,7 +311,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
            }

            NavigationBarView navigationBarView =
                    centralSurfacesOptional.map(CentralSurfaces::getNavigationBarView).orElse(null);
                    mNavigationBarControllerLazy.get().getNavigationBarView(displayId);
            if (navigationBarView != null) {
                ((ImageView) mLayout.findViewById(R.id.screen_pinning_back_icon))
                        .setImageDrawable(navigationBarView.getBackDrawable());
+32 −9
Original line number Diff line number Diff line
@@ -2252,7 +2252,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    @Override
    public void startWaitingForExpandGesture() {
    public void startInputFocusTransfer() {
        if (!mCommandQueue.panelsEnabled()) {
            return;
        }
        if (!isFullyCollapsed()) {
            return;
        }
@@ -2262,16 +2265,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.
     *
Loading