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

Commit 20780af5 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Clean up remove_depart_target_from_motion flag(1/2)" into main

parents 49979214 9b553e48
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;

@@ -173,15 +172,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}. */
@@ -265,8 +263,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
@@ -301,8 +301,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);
            }
@@ -317,8 +316,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);
            }
+0 −11
Original line number Diff line number Diff line
@@ -294,17 +294,6 @@ flag {
    is_exported: true
}

flag {
    name: "remove_depart_target_from_motion"
    namespace: "windowing_frontend"
    description: "Remove DepartingAnimationTarget from BackMotionEvent"
    bug: "395035430"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
  name: "relative_insets"
  namespace: "windowing_frontend"
+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)
    }

Loading