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

Commit 13423234 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Delay start of predictive back transition

This CL delays the start of the predictive back transition. With this CL, the back transition will only be started once the back gesture threshold was crossed. This prevents onStart of the previous activity being called whenever a tap happens within the back gesture area.

This may introduce a small delay of the animation start but testing suggests that the delay is acceptable. This will need to be further monitored and examined in the different flag rollout stages.

Bug: 301195601
Flag: com.android.systemui.predictive_back_delay_transition
Test: Manual, i.e. verified no regressions for back navigations with CL. Also verified manually that the introduced delay does not affect back animation responsiveness too much.
Test: BackAnimationControllerTest
Change-Id: I0255f4b34c7c9e9312bc503226fdb30dd3d1b9e6
parent 03d6b1fc
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
@@ -1128,6 +1128,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();
@@ -1180,9 +1181,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;
@@ -1197,6 +1196,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                // forward touch
                mEdgeBackPlugin.onMotionEvent(ev);
                dispatchToBackAnimation(ev);
                if (mBackAnimation != null && mThresholdCrossed && !mLastFrameThresholdCrossed) {
                    mBackAnimation.onThresholdCrossed();
                }
            }
        }
    }