diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimation.java index 7cf359729ee88..e71a59d267405 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimation.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimation.java @@ -16,6 +16,7 @@ package com.android.wm.shell.back; +import android.view.KeyEvent; import android.view.MotionEvent; import android.window.BackEvent; @@ -29,8 +30,14 @@ public interface BackAnimation { /** * Called when a {@link MotionEvent} is generated by a back gesture. + * + * @param event the original {@link MotionEvent} + * @param action the original {@link KeyEvent#getAction()} when the event was dispatched to + * the process. This is forwarded separately because the input pipeline may mutate + * the {#event} action state later. + * @param swipeEdge the edge from which the swipe begins. */ - void onBackMotion(MotionEvent event, @BackEvent.SwipeEdge int swipeEdge); + void onBackMotion(MotionEvent event, int action, @BackEvent.SwipeEdge int swipeEdge); /** * Sets whether the back gesture is past the trigger threshold or not. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java index 08cb252cdf432..93ee3f5378e8f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java @@ -138,8 +138,9 @@ public class BackAnimationController implements RemoteCallable onMotionEvent(event, swipeEdge)); + public void onBackMotion( + MotionEvent event, int action, @BackEvent.SwipeEdge int swipeEdge) { + mShellExecutor.execute(() -> onMotionEvent(event, action, swipeEdge)); } @Override @@ -209,13 +210,13 @@ public class BackAnimationController implements RemoteCallable backEventCaptor = ArgumentCaptor.forClass(BackEvent.class); verify(mIOnBackInvokedCallback).onBackProgressed(backEventCaptor.capture()); @@ -166,6 +171,7 @@ public class BackAnimationControllerTest { mController.setTriggerBack(true); // Fake trigger back mController.onMotionEvent( MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0), + MotionEvent.ACTION_UP, BackEvent.EDGE_LEFT); verify(mIOnBackInvokedCallback).onBackInvoked(); } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java index a1258df7a12c1..03652412c129c 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java @@ -480,7 +480,9 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl public void onMotionEvent(MotionEvent event) { if (mBackAnimation != null) { mBackAnimation.onBackMotion( - event, mIsLeftPanel ? BackEvent.EDGE_LEFT : BackEvent.EDGE_RIGHT); + event, + event.getActionMasked(), + mIsLeftPanel ? BackEvent.EDGE_LEFT : BackEvent.EDGE_RIGHT); } if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain();