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

Commit df8dcf01 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Delay start of predictive back transition" into main

parents bfd807b2 13423234
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP;
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_PREDICTIVE_BACK_HOME;
import static com.android.systemui.Flags.predictiveBackDelayTransition;
import static com.android.window.flags.Flags.unifyBackNavigationTransition;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW;

@@ -431,6 +432,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    @VisibleForTesting
    public void onThresholdCrossed() {
        mThresholdCrossed = true;
        BackTouchTracker activeTracker = getActiveTracker();
        if (predictiveBackDelayTransition() && activeTracker != null && mActiveCallback == null
                && mBackGestureStarted) {
            startBackNavigation(activeTracker);
        }
        // There was no focus window when calling startBackNavigation, still pilfer pointers so
        // the next focus window won't receive motion events.
        if (mBackNavigationInfo == null && mReceivedNullNavigationInfo) {
@@ -488,9 +494,14 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                if (swipeEdge == EDGE_NONE) {
                    // start animation immediately for non-gestural sources (without ACTION_MOVE
                    // events)
                    if (!predictiveBackDelayTransition()) {
                        mThresholdCrossed = true;
                    }
                    mPointersPilfered = true;
                    onGestureStarted(touchX, touchY, swipeEdge);
                    if (predictiveBackDelayTransition()) {
                        onThresholdCrossed();
                    }
                    mShouldStartOnNextMoveEvent = false;
                } else {
                    mShouldStartOnNextMoveEvent = true;
@@ -544,14 +555,17 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            mPostCommitAnimationInProgress = false;
            mShellExecutor.removeCallbacks(mAnimationTimeoutRunnable);
            startSystemAnimation();
        } else if (touchTracker == mCurrentTracker) {
            // Only start the back navigation if no other gesture is being processed. Otherwise,
            // the back navigation will fall back to legacy back event injection.
            startBackNavigation(mCurrentTracker);
        } else if (!predictiveBackDelayTransition()) {
            startBackNavigation(touchTracker);
        }
    }

    private void startBackNavigation(@NonNull BackTouchTracker touchTracker) {
        if (touchTracker != mCurrentTracker) {
            // Only start the back navigation if no other gesture is being processed. Otherwise,
            // the back navigation will fall back to legacy back event injection.
            return;
        }
        try {
            startLatencyTracking();
            if (mBackAnimationAdapter != null
+7 −0
Original line number Diff line number Diff line
@@ -7,3 +7,10 @@ flag {
    description: "Enable Shade Animations"
    bug: "327732946"
}

flag {
    name: "predictive_back_delay_transition"
    namespace: "systemui"
    description: "Slightly delays the back transition start"
    bug: "301195601"
}
+5 −3
Original line number Diff line number Diff line
@@ -1129,6 +1129,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                    mGestureBlockingActivityRunning.get(), mIsInPip, mDisplaySize,
                    mEdgeWidthLeft, mLeftInset, mEdgeWidthRight, mRightInset, mExcludeRegion));
        } else if (mAllowGesture || mLogGesture) {
            boolean mLastFrameThresholdCrossed = mThresholdCrossed;
            if (!mThresholdCrossed) {
                mEndPoint.x = (int) ev.getX();
                mEndPoint.y = (int) ev.getY();
@@ -1181,9 +1182,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                        return;
                    } else if (dx > dy && dx > mTouchSlop) {
                        if (mAllowGesture) {
                            if (mBackAnimation != null) {
                                mBackAnimation.onThresholdCrossed();
                            } else {
                            if (mBackAnimation == null) {
                                pilferPointers();
                            }
                            mThresholdCrossed = true;
@@ -1198,6 +1197,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                // forward touch
                mEdgeBackPlugin.onMotionEvent(ev);
                dispatchToBackAnimation(ev);
                if (mBackAnimation != null && mThresholdCrossed && !mLastFrameThresholdCrossed) {
                    mBackAnimation.onThresholdCrossed();
                }
            }
        }
    }