Loading core/java/android/window/BackMotionEvent.java +16 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public final class BackMotionEvent implements Parcelable { private final float mProgress; private final float mVelocityX; private final float mVelocityY; private final boolean mTriggerBack; @BackEvent.SwipeEdge private final int mSwipeEdge; Loading @@ -54,6 +55,7 @@ public final class BackMotionEvent implements Parcelable { * Value in pixels/second. {@link Float#NaN} if was not computed. * @param velocityY Y velocity computed from the touch point of this event. * Value in pixels/second. {@link Float#NaN} if was not computed. * @param triggerBack Indicates whether the back arrow is in the triggered state or not * @param swipeEdge Indicates which edge the swipe starts from. * @param departingAnimationTarget The remote animation target of the departing * application window. Loading @@ -64,6 +66,7 @@ public final class BackMotionEvent implements Parcelable { float progress, float velocityX, float velocityY, boolean triggerBack, @BackEvent.SwipeEdge int swipeEdge, @Nullable RemoteAnimationTarget departingAnimationTarget) { mTouchX = touchX; Loading @@ -71,6 +74,7 @@ public final class BackMotionEvent implements Parcelable { mProgress = progress; mVelocityX = velocityX; mVelocityY = velocityY; mTriggerBack = triggerBack; mSwipeEdge = swipeEdge; mDepartingAnimationTarget = departingAnimationTarget; } Loading @@ -81,6 +85,7 @@ public final class BackMotionEvent implements Parcelable { mProgress = in.readFloat(); mVelocityX = in.readFloat(); mVelocityY = in.readFloat(); mTriggerBack = in.readBoolean(); mSwipeEdge = in.readInt(); mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR); } Loading Loading @@ -110,6 +115,7 @@ public final class BackMotionEvent implements Parcelable { dest.writeFloat(mProgress); dest.writeFloat(mVelocityX); dest.writeFloat(mVelocityY); dest.writeBoolean(mTriggerBack); dest.writeInt(mSwipeEdge); dest.writeTypedObject(mDepartingAnimationTarget, flags); } Loading Loading @@ -156,6 +162,15 @@ public final class BackMotionEvent implements Parcelable { return mVelocityY; } /** * Returns whether the back arrow is in the triggered state or not * * @return boolean indicating whether the back arrow is in the triggered state or not */ public boolean getTriggerBack() { return mTriggerBack; } /** * Returns the screen edge that the swipe starts from. */ Loading @@ -182,6 +197,7 @@ public final class BackMotionEvent implements Parcelable { + ", mProgress=" + mProgress + ", mVelocityX=" + mVelocityX + ", mVelocityY=" + mVelocityY + ", mTriggerBack=" + mTriggerBack + ", mSwipeEdge" + mSwipeEdge + ", mDepartingAnimationTarget" + mDepartingAnimationTarget + "}"; Loading core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class WindowOnBackInvokedDispatcherTest { /* progress = */ 0, /* velocityX = */ 0, /* velocityY = */ 0, /* triggerBack = */ false, /* swipeEdge = */ BackEvent.EDGE_LEFT, /* departingAnimationTarget = */ null); Loading libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationConstants.java +0 −1 Original line number Diff line number Diff line Loading @@ -21,5 +21,4 @@ package com.android.wm.shell.back; */ class BackAnimationConstants { static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.20f; static final float PROGRESS_COMMIT_THRESHOLD = 0.1f; } libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.java +11 −7 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ package com.android.wm.shell.back; import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.RemoteAnimationTarget.MODE_OPENING; import static android.window.BackEvent.EDGE_RIGHT; import static com.android.internal.jank.InteractionJankMonitor.CUJ_PREDICTIVE_BACK_CROSS_ACTIVITY; import static com.android.wm.shell.back.BackAnimationConstants.PROGRESS_COMMIT_THRESHOLD; import static com.android.wm.shell.back.BackAnimationConstants.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW; Loading Loading @@ -91,7 +91,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { } }; private static final float MIN_WINDOW_ALPHA = 0.01f; private static final float WINDOW_X_SHIFT_DP = 96; private static final float WINDOW_X_SHIFT_DP = 48; private static final int SCALE_FACTOR = 100; // TODO(b/264710590): Use the progress commit threshold from ViewConfiguration once it exists. private static final float TARGET_COMMIT_PROGRESS = 0.5f; Loading Loading @@ -126,6 +126,8 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction(); private boolean mBackInProgress = false; private boolean mIsRightEdge; private boolean mTriggerBack = false; private PointF mTouchPos = new PointF(); private IRemoteAnimationFinishedCallback mFinishCallback; Loading Loading @@ -241,14 +243,15 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private void onGestureProgress(@NonNull BackEvent backEvent) { if (!mBackInProgress) { mIsRightEdge = backEvent.getSwipeEdge() == EDGE_RIGHT; mInitialTouchPos.set(backEvent.getTouchX(), backEvent.getTouchY()); mBackInProgress = true; } mTouchPos.set(backEvent.getTouchX(), backEvent.getTouchY()); float progress = backEvent.getProgress(); float springProgress = (progress > PROGRESS_COMMIT_THRESHOLD ? mapLinear(progress, 0.1f, 1, TARGET_COMMIT_PROGRESS, 1) float springProgress = (mTriggerBack ? mapLinear(progress, 0f, 1, TARGET_COMMIT_PROGRESS, 1) : mapLinear(progress, 0, 1f, 0, TARGET_COMMIT_PROGRESS)) * SCALE_FACTOR; mLeavingProgressSpring.animateToFinalPosition(springProgress); mEnteringProgressSpring.animateToFinalPosition(springProgress); Loading Loading @@ -312,7 +315,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { transformWithProgress( mEnteringProgress, Math.max( smoothstep(ENTER_ALPHA_THRESHOLD, 1, mEnteringProgress), smoothstep(ENTER_ALPHA_THRESHOLD, 0.7f, mEnteringProgress), MIN_WINDOW_ALPHA), /* alpha */ mEnteringTarget.leash, mEnteringRect, Loading @@ -337,14 +340,13 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { mClosingTarget.leash, mClosingRect, 0, mWindowXShift mIsRightEdge ? 0 : mWindowXShift ); } } private void transformWithProgress(float progress, float alpha, SurfaceControl surface, RectF targetRect, float deltaXMin, float deltaXMax) { final float touchY = mTouchPos.y; final int width = mStartTaskRect.width(); final int height = mStartTaskRect.height(); Loading Loading @@ -376,12 +378,14 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private final class Callback extends IOnBackInvokedCallback.Default { @Override public void onBackStarted(BackMotionEvent backEvent) { mTriggerBack = backEvent.getTriggerBack(); mProgressAnimator.onBackStarted(backEvent, CrossActivityBackAnimation.this::onGestureProgress); } @Override public void onBackProgressed(@NonNull BackMotionEvent backEvent) { mTriggerBack = backEvent.getTriggerBack(); mProgressAnimator.onBackProgressed(backEvent); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/back/TouchTracker.java +2 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ class TouchTracker { /* progress = */ 0, /* velocityX = */ 0, /* velocityY = */ 0, /* triggerBack = */ mTriggerBack, /* swipeEdge = */ mSwipeEdge, /* departingAnimationTarget = */ target); } Loading Loading @@ -204,6 +205,7 @@ class TouchTracker { /* progress = */ progress, /* velocityX = */ mLatestVelocityX, /* velocityY = */ mLatestVelocityY, /* triggerBack = */ mTriggerBack, /* swipeEdge = */ mSwipeEdge, /* departingAnimationTarget = */ null); } Loading Loading
core/java/android/window/BackMotionEvent.java +16 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public final class BackMotionEvent implements Parcelable { private final float mProgress; private final float mVelocityX; private final float mVelocityY; private final boolean mTriggerBack; @BackEvent.SwipeEdge private final int mSwipeEdge; Loading @@ -54,6 +55,7 @@ public final class BackMotionEvent implements Parcelable { * Value in pixels/second. {@link Float#NaN} if was not computed. * @param velocityY Y velocity computed from the touch point of this event. * Value in pixels/second. {@link Float#NaN} if was not computed. * @param triggerBack Indicates whether the back arrow is in the triggered state or not * @param swipeEdge Indicates which edge the swipe starts from. * @param departingAnimationTarget The remote animation target of the departing * application window. Loading @@ -64,6 +66,7 @@ public final class BackMotionEvent implements Parcelable { float progress, float velocityX, float velocityY, boolean triggerBack, @BackEvent.SwipeEdge int swipeEdge, @Nullable RemoteAnimationTarget departingAnimationTarget) { mTouchX = touchX; Loading @@ -71,6 +74,7 @@ public final class BackMotionEvent implements Parcelable { mProgress = progress; mVelocityX = velocityX; mVelocityY = velocityY; mTriggerBack = triggerBack; mSwipeEdge = swipeEdge; mDepartingAnimationTarget = departingAnimationTarget; } Loading @@ -81,6 +85,7 @@ public final class BackMotionEvent implements Parcelable { mProgress = in.readFloat(); mVelocityX = in.readFloat(); mVelocityY = in.readFloat(); mTriggerBack = in.readBoolean(); mSwipeEdge = in.readInt(); mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR); } Loading Loading @@ -110,6 +115,7 @@ public final class BackMotionEvent implements Parcelable { dest.writeFloat(mProgress); dest.writeFloat(mVelocityX); dest.writeFloat(mVelocityY); dest.writeBoolean(mTriggerBack); dest.writeInt(mSwipeEdge); dest.writeTypedObject(mDepartingAnimationTarget, flags); } Loading Loading @@ -156,6 +162,15 @@ public final class BackMotionEvent implements Parcelable { return mVelocityY; } /** * Returns whether the back arrow is in the triggered state or not * * @return boolean indicating whether the back arrow is in the triggered state or not */ public boolean getTriggerBack() { return mTriggerBack; } /** * Returns the screen edge that the swipe starts from. */ Loading @@ -182,6 +197,7 @@ public final class BackMotionEvent implements Parcelable { + ", mProgress=" + mProgress + ", mVelocityX=" + mVelocityX + ", mVelocityY=" + mVelocityY + ", mTriggerBack=" + mTriggerBack + ", mSwipeEdge" + mSwipeEdge + ", mDepartingAnimationTarget" + mDepartingAnimationTarget + "}"; Loading
core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class WindowOnBackInvokedDispatcherTest { /* progress = */ 0, /* velocityX = */ 0, /* velocityY = */ 0, /* triggerBack = */ false, /* swipeEdge = */ BackEvent.EDGE_LEFT, /* departingAnimationTarget = */ null); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationConstants.java +0 −1 Original line number Diff line number Diff line Loading @@ -21,5 +21,4 @@ package com.android.wm.shell.back; */ class BackAnimationConstants { static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.20f; static final float PROGRESS_COMMIT_THRESHOLD = 0.1f; }
libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.java +11 −7 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ package com.android.wm.shell.back; import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.RemoteAnimationTarget.MODE_OPENING; import static android.window.BackEvent.EDGE_RIGHT; import static com.android.internal.jank.InteractionJankMonitor.CUJ_PREDICTIVE_BACK_CROSS_ACTIVITY; import static com.android.wm.shell.back.BackAnimationConstants.PROGRESS_COMMIT_THRESHOLD; import static com.android.wm.shell.back.BackAnimationConstants.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW; Loading Loading @@ -91,7 +91,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { } }; private static final float MIN_WINDOW_ALPHA = 0.01f; private static final float WINDOW_X_SHIFT_DP = 96; private static final float WINDOW_X_SHIFT_DP = 48; private static final int SCALE_FACTOR = 100; // TODO(b/264710590): Use the progress commit threshold from ViewConfiguration once it exists. private static final float TARGET_COMMIT_PROGRESS = 0.5f; Loading Loading @@ -126,6 +126,8 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction(); private boolean mBackInProgress = false; private boolean mIsRightEdge; private boolean mTriggerBack = false; private PointF mTouchPos = new PointF(); private IRemoteAnimationFinishedCallback mFinishCallback; Loading Loading @@ -241,14 +243,15 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private void onGestureProgress(@NonNull BackEvent backEvent) { if (!mBackInProgress) { mIsRightEdge = backEvent.getSwipeEdge() == EDGE_RIGHT; mInitialTouchPos.set(backEvent.getTouchX(), backEvent.getTouchY()); mBackInProgress = true; } mTouchPos.set(backEvent.getTouchX(), backEvent.getTouchY()); float progress = backEvent.getProgress(); float springProgress = (progress > PROGRESS_COMMIT_THRESHOLD ? mapLinear(progress, 0.1f, 1, TARGET_COMMIT_PROGRESS, 1) float springProgress = (mTriggerBack ? mapLinear(progress, 0f, 1, TARGET_COMMIT_PROGRESS, 1) : mapLinear(progress, 0, 1f, 0, TARGET_COMMIT_PROGRESS)) * SCALE_FACTOR; mLeavingProgressSpring.animateToFinalPosition(springProgress); mEnteringProgressSpring.animateToFinalPosition(springProgress); Loading Loading @@ -312,7 +315,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { transformWithProgress( mEnteringProgress, Math.max( smoothstep(ENTER_ALPHA_THRESHOLD, 1, mEnteringProgress), smoothstep(ENTER_ALPHA_THRESHOLD, 0.7f, mEnteringProgress), MIN_WINDOW_ALPHA), /* alpha */ mEnteringTarget.leash, mEnteringRect, Loading @@ -337,14 +340,13 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { mClosingTarget.leash, mClosingRect, 0, mWindowXShift mIsRightEdge ? 0 : mWindowXShift ); } } private void transformWithProgress(float progress, float alpha, SurfaceControl surface, RectF targetRect, float deltaXMin, float deltaXMax) { final float touchY = mTouchPos.y; final int width = mStartTaskRect.width(); final int height = mStartTaskRect.height(); Loading Loading @@ -376,12 +378,14 @@ public class CrossActivityBackAnimation extends ShellBackAnimation { private final class Callback extends IOnBackInvokedCallback.Default { @Override public void onBackStarted(BackMotionEvent backEvent) { mTriggerBack = backEvent.getTriggerBack(); mProgressAnimator.onBackStarted(backEvent, CrossActivityBackAnimation.this::onGestureProgress); } @Override public void onBackProgressed(@NonNull BackMotionEvent backEvent) { mTriggerBack = backEvent.getTriggerBack(); mProgressAnimator.onBackProgressed(backEvent); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/back/TouchTracker.java +2 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ class TouchTracker { /* progress = */ 0, /* velocityX = */ 0, /* velocityY = */ 0, /* triggerBack = */ mTriggerBack, /* swipeEdge = */ mSwipeEdge, /* departingAnimationTarget = */ target); } Loading Loading @@ -204,6 +205,7 @@ class TouchTracker { /* progress = */ progress, /* velocityX = */ mLatestVelocityX, /* velocityY = */ mLatestVelocityY, /* triggerBack = */ mTriggerBack, /* swipeEdge = */ mSwipeEdge, /* departingAnimationTarget = */ null); } Loading