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

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

Fix BackAnimationController race condition

This CL fixes a race condition in BackAnimationController. Since
onThresholdCrossed is not executed on the shell main thread, the
ordering between other BackAnimation API function calls was not
guaranteed. Namely, onThresholdCrossed could have been executed before
the first MOVE event was processed, resulting in  startBackAnimation not
being called. In that case, BackAnimationController injected legacy back
events as a fallback instead of playing the predictive back animation.
Executing onThresholdCrossed on the shell main thread instead should
resolve this problem.

Additionally, the recently implemented small related change (commit 13423234) in EBGH is
put behind the predictiveBackDelayWmTransition flag as well.

Bug: 401832380
Flag: com.android.systemui.predictive_back_delay_wm_transition
Test: BackGestureInvokedTest
Change-Id: I77d0d1de66934754cc64330130d4bd34b4634796
parent 9a50081a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -332,8 +332,12 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

        @Override
        public void onThresholdCrossed() {
            if (predictiveBackDelayWmTransition()) {
                mShellExecutor.execute(BackAnimationController.this::onThresholdCrossed);
            } else {
                BackAnimationController.this.onThresholdCrossed();
            }
        }

        @Override
        public void setTriggerBack(boolean triggerBack) {
+6 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.MotionEvent.TOOL_TYPE_FINGER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;

import static com.android.systemui.Flags.edgebackGestureHandlerGetRunningTasksBackground;
import static com.android.systemui.Flags.predictiveBackDelayWmTransition;
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED;
@@ -1182,6 +1183,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                        return;
                    } else if (dx > dy && dx > mTouchSlop) {
                        if (mAllowGesture) {
                            if (!predictiveBackDelayWmTransition() && mBackAnimation != null) {
                                mBackAnimation.onThresholdCrossed();
                            }
                            if (mBackAnimation == null) {
                                pilferPointers();
                            }
@@ -1197,7 +1201,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                // forward touch
                mEdgeBackPlugin.onMotionEvent(ev);
                dispatchToBackAnimation(ev);
                if (mBackAnimation != null && mThresholdCrossed && !mLastFrameThresholdCrossed) {
                if (predictiveBackDelayWmTransition() && mBackAnimation != null
                        && mThresholdCrossed && !mLastFrameThresholdCrossed) {
                    mBackAnimation.onThresholdCrossed();
                }
            }