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

Commit b951f512 authored by wilsonshih's avatar wilsonshih
Browse files

Remove DepartingAnimationTarget from BackMotionEvent

This would create another SurfaceControl object through IPC, which is
unnecessary because the animation should run through
BackAnimationRunner.

Flag: EXEMPT bugfix
Bug: 395035430
Test: execute back-to-home transition several times, verify no
predict_back animation leash left in offscreen layer.

Change-Id: I6a54327e28576b5755b5b2536c6c4eb37712c56a
parent 5edc389e
Loading
Loading
Loading
Loading
+1 −21
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.window;

import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.RemoteAnimationTarget;
@@ -39,8 +38,6 @@ public final class BackMotionEvent implements Parcelable {

    @BackEvent.SwipeEdge
    private final int mSwipeEdge;
    @Nullable
    private final RemoteAnimationTarget mDepartingAnimationTarget;

    /**
     * Creates a new {@link BackMotionEvent} instance.
@@ -53,8 +50,6 @@ public final class BackMotionEvent implements Parcelable {
     * @param progress Value between 0 and 1 on how far along the back gesture is.
     * @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.
     */
    public BackMotionEvent(
            float touchX,
@@ -62,15 +57,13 @@ public final class BackMotionEvent implements Parcelable {
            long frameTimeMillis,
            float progress,
            boolean triggerBack,
            @BackEvent.SwipeEdge int swipeEdge,
            @Nullable RemoteAnimationTarget departingAnimationTarget) {
            @BackEvent.SwipeEdge int swipeEdge) {
        mTouchX = touchX;
        mTouchY = touchY;
        mFrameTimeMillis = frameTimeMillis;
        mProgress = progress;
        mTriggerBack = triggerBack;
        mSwipeEdge = swipeEdge;
        mDepartingAnimationTarget = departingAnimationTarget;
    }

    private BackMotionEvent(@NonNull Parcel in) {
@@ -79,7 +72,6 @@ public final class BackMotionEvent implements Parcelable {
        mProgress = in.readFloat();
        mTriggerBack = in.readBoolean();
        mSwipeEdge = in.readInt();
        mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
        mFrameTimeMillis = in.readLong();
    }

@@ -108,7 +100,6 @@ public final class BackMotionEvent implements Parcelable {
        dest.writeFloat(mProgress);
        dest.writeBoolean(mTriggerBack);
        dest.writeInt(mSwipeEdge);
        dest.writeTypedObject(mDepartingAnimationTarget, flags);
        dest.writeLong(mFrameTimeMillis);
    }

@@ -160,16 +151,6 @@ public final class BackMotionEvent implements Parcelable {
        return mFrameTimeMillis;
    }

    /**
     * Returns the {@link RemoteAnimationTarget} of the top departing application window,
     * or {@code null} if the top window should not be moved for the current type of back
     * destination.
     */
    @Nullable
    public RemoteAnimationTarget getDepartingAnimationTarget() {
        return mDepartingAnimationTarget;
    }

    @Override
    public String toString() {
        return "BackMotionEvent{"
@@ -179,7 +160,6 @@ public final class BackMotionEvent implements Parcelable {
                + ", mProgress=" + mProgress
                + ", mTriggerBack=" + mTriggerBack
                + ", mSwipeEdge=" + mSwipeEdge
                + ", mDepartingAnimationTarget=" + mDepartingAnimationTarget
                + "}";
    }
}
+3 −6
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.FloatRange;
import android.os.SystemProperties;
import android.util.MathUtils;
import android.view.MotionEvent;
import android.view.RemoteAnimationTarget;

import java.io.PrintWriter;

@@ -147,15 +146,14 @@ public class BackTouchTracker {
    }

    /** Creates a start {@link BackMotionEvent}. */
    public BackMotionEvent createStartEvent(RemoteAnimationTarget target) {
    public BackMotionEvent createStartEvent() {
        return new BackMotionEvent(
                /* touchX = */ mInitTouchX,
                /* touchY = */ mInitTouchY,
                /* frameTimeMillis = */ 0,
                /* progress = */ 0,
                /* triggerBack = */ mTriggerBack,
                /* swipeEdge = */ mSwipeEdge,
                /* departingAnimationTarget = */ target);
                /* swipeEdge = */ mSwipeEdge);
    }

    /** Creates a progress {@link BackMotionEvent}. */
@@ -239,8 +237,7 @@ public class BackTouchTracker {
                /* frameTimeMillis = */ 0,
                /* progress = */ progress,
                /* triggerBack = */ mTriggerBack,
                /* swipeEdge = */ mSwipeEdge,
                /* departingAnimationTarget = */ null);
                /* swipeEdge = */ mSwipeEdge);
    }

    /** Sets the thresholds for computing progress. */
+2 −4
Original line number Diff line number Diff line
@@ -270,8 +270,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                }
                mIOnBackInvokedCallback.onBackStarted(
                        new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(), frameTime,
                                backEvent.getProgress(), false, backEvent.getSwipeEdge(),
                                null));
                                backEvent.getProgress(), false, backEvent.getSwipeEdge()));
            } catch (RemoteException e) {
                Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
            }
@@ -286,8 +285,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                }
                mIOnBackInvokedCallback.onBackProgressed(
                        new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(), frameTime,
                                backEvent.getProgress(), false, backEvent.getSwipeEdge(),
                                null));
                                backEvent.getProgress(), false, backEvent.getSwipeEdge()));
            } catch (RemoteException e) {
                Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
            }
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class BackTouchTrackerTest {
    fun generatesProgress_onStart() {
        val linearTracker = linearTouchTracker()
        linearTracker.setGestureStartLocation(INITIAL_X_LEFT_EDGE, 0f, BackEvent.EDGE_LEFT)
        val event = linearTracker.createStartEvent(null)
        val event = linearTracker.createStartEvent()
        assertEquals(0f, event.progress, 0f)
    }

+1 −2
Original line number Diff line number Diff line
@@ -689,8 +689,7 @@ public class WindowOnBackInvokedDispatcherTest {
                /* frameTimeMillis = */ 0,
                /* progress = */ progress,
                /* triggerBack = */ false,
                /* swipeEdge = */ BackEvent.EDGE_LEFT,
                /* departingAnimationTarget = */ null);
                /* swipeEdge = */ BackEvent.EDGE_LEFT);
    }

    private void verifyImeCallackRegistrations() throws RemoteException {
Loading