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

Commit 93d900d7 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8464370 from 626138cb to tm-qpr1-release

Change-Id: I535173455ed14ec55ae95a508d1282190fb62a27
parents 246aec48 626138cb
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -46,8 +46,8 @@ public class BackEvent implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface SwipeEdge{}
    public @interface SwipeEdge{}


    private final int mTouchX;
    private final float mTouchX;
    private final int mTouchY;
    private final float mTouchY;
    private final float mProgress;
    private final float mProgress;


    @SwipeEdge
    @SwipeEdge
@@ -58,14 +58,14 @@ public class BackEvent implements Parcelable {
    /**
    /**
     * Creates a new {@link BackEvent} instance.
     * Creates a new {@link BackEvent} instance.
     *
     *
     * @param touchX Absolute X location of the touch point.
     * @param touchX Absolute X location of the touch point of this event.
     * @param touchY Absolute Y location of the touch point.
     * @param touchY Absolute Y location of the touch point of this event.
     * @param progress Value between 0 and 1 on how far along the back gesture is.
     * @param progress Value between 0 and 1 on how far along the back gesture is.
     * @param swipeEdge Indicates which edge the swipe starts from.
     * @param swipeEdge Indicates which edge the swipe starts from.
     * @param departingAnimationTarget The remote animation target of the departing application
     * @param departingAnimationTarget The remote animation target of the departing application
     *                                 window.
     *                                 window.
     */
     */
    public BackEvent(int touchX, int touchY, float progress, @SwipeEdge int swipeEdge,
    public BackEvent(float touchX, float touchY, float progress, @SwipeEdge int swipeEdge,
            @Nullable RemoteAnimationTarget departingAnimationTarget) {
            @Nullable RemoteAnimationTarget departingAnimationTarget) {
        mTouchX = touchX;
        mTouchX = touchX;
        mTouchY = touchY;
        mTouchY = touchY;
@@ -75,8 +75,8 @@ public class BackEvent implements Parcelable {
    }
    }


    private BackEvent(@NonNull Parcel in) {
    private BackEvent(@NonNull Parcel in) {
        mTouchX = in.readInt();
        mTouchX = in.readFloat();
        mTouchY = in.readInt();
        mTouchY = in.readFloat();
        mProgress = in.readFloat();
        mProgress = in.readFloat();
        mSwipeEdge = in.readInt();
        mSwipeEdge = in.readInt();
        mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
        mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
@@ -101,8 +101,8 @@ public class BackEvent implements Parcelable {


    @Override
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mTouchX);
        dest.writeFloat(mTouchX);
        dest.writeInt(mTouchY);
        dest.writeFloat(mTouchY);
        dest.writeFloat(mProgress);
        dest.writeFloat(mProgress);
        dest.writeInt(mSwipeEdge);
        dest.writeInt(mSwipeEdge);
        dest.writeTypedObject(mDepartingAnimationTarget, flags);
        dest.writeTypedObject(mDepartingAnimationTarget, flags);
@@ -118,14 +118,14 @@ public class BackEvent implements Parcelable {
    /**
    /**
     * Returns the absolute X location of the touch point.
     * Returns the absolute X location of the touch point.
     */
     */
    public int getTouchX() {
    public float getTouchX() {
        return mTouchX;
        return mTouchX;
    }
    }


    /**
    /**
     * Returns the absolute Y location of the touch point.
     * Returns the absolute Y location of the touch point.
     */
     */
    public int getTouchY() {
    public float getTouchY() {
        return mTouchY;
        return mTouchY;
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -301,7 +301,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        int backType = mBackNavigationInfo.getType();
        int backType = mBackNavigationInfo.getType();
        RemoteAnimationTarget animationTarget = mBackNavigationInfo.getDepartingAnimationTarget();
        RemoteAnimationTarget animationTarget = mBackNavigationInfo.getDepartingAnimationTarget();


        BackEvent backEvent = new BackEvent(0, 0, progress, swipeEdge, animationTarget);
        BackEvent backEvent = new BackEvent(
                event.getX(), event.getY(), progress, swipeEdge, animationTarget);
        IOnBackInvokedCallback targetCallback = null;
        IOnBackInvokedCallback targetCallback = null;
        if (shouldDispatchToLauncher(backType)) {
        if (shouldDispatchToLauncher(backType)) {
            targetCallback = mBackToLauncherCallback;
            targetCallback = mBackToLauncherCallback;
+18 −2
Original line number Original line Diff line number Diff line
@@ -928,6 +928,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            removeContentOverlay(mSwipePipToHomeOverlay, null /* callback */);
            removeContentOverlay(mSwipePipToHomeOverlay, null /* callback */);
            mSwipePipToHomeOverlay = null;
            mSwipePipToHomeOverlay = null;
        }
        }
        resetShadowRadius();
        mPipTransitionState.setInSwipePipToHomeTransition(false);
        mPipTransitionState.setInSwipePipToHomeTransition(false);
        mPictureInPictureParams = null;
        mPictureInPictureParams = null;
        mPipTransitionState.setTransitionState(PipTransitionState.UNDEFINED);
        mPipTransitionState.setTransitionState(PipTransitionState.UNDEFINED);
@@ -1573,13 +1574,28 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            // Avoid double removal, which is fatal.
            // Avoid double removal, which is fatal.
            return;
            return;
        }
        }
        final SurfaceControl.Transaction tx =
        final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
                mSurfaceControlTransactionFactory.getTransaction();
        tx.remove(surface);
        tx.remove(surface);
        tx.apply();
        tx.apply();
        if (callback != null) callback.run();
        if (callback != null) callback.run();
    }
    }


    private void resetShadowRadius() {
        if (mPipTransitionState.getTransitionState() == PipTransitionState.UNDEFINED) {
            // mLeash is undefined when in PipTransitionState.UNDEFINED
            return;
        }
        final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
        tx.setShadowRadius(mLeash, 0f);
        tx.apply();
    }

    @VisibleForTesting
    public void setSurfaceControlTransactionFactory(
            PipSurfaceTransactionHelper.SurfaceControlTransactionFactory factory) {
        mSurfaceControlTransactionFactory = factory;
    }

    /**
    /**
     * Dumps internal states.
     * Dumps internal states.
     */
     */
+3 −44
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;


import android.app.TaskInfo;
import android.app.TaskInfo;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.Rect;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
@@ -104,7 +103,7 @@ public class PipAnimationControllerTest extends ShellTestCase {
        final PipAnimationController.PipTransitionAnimator oldAnimator = mPipAnimationController
        final PipAnimationController.PipTransitionAnimator oldAnimator = mPipAnimationController
                .getAnimator(mTaskInfo, mLeash, baseValue, startValue, endValue1, null,
                .getAnimator(mTaskInfo, mLeash, baseValue, startValue, endValue1, null,
                        TRANSITION_DIRECTION_TO_PIP, 0, ROTATION_0);
                        TRANSITION_DIRECTION_TO_PIP, 0, ROTATION_0);
        oldAnimator.setSurfaceControlTransactionFactory(DummySurfaceControlTx::new);
        oldAnimator.setSurfaceControlTransactionFactory(PipDummySurfaceControlTx::new);
        oldAnimator.start();
        oldAnimator.start();


        final PipAnimationController.PipTransitionAnimator newAnimator = mPipAnimationController
        final PipAnimationController.PipTransitionAnimator newAnimator = mPipAnimationController
@@ -134,7 +133,7 @@ public class PipAnimationControllerTest extends ShellTestCase {


    @Test
    @Test
    public void pipTransitionAnimator_rotatedEndValue() {
    public void pipTransitionAnimator_rotatedEndValue() {
        final DummySurfaceControlTx tx = new DummySurfaceControlTx();
        final PipDummySurfaceControlTx tx = new PipDummySurfaceControlTx();
        final Rect startBounds = new Rect(200, 700, 400, 800);
        final Rect startBounds = new Rect(200, 700, 400, 800);
        final Rect endBounds = new Rect(0, 0, 500, 1000);
        final Rect endBounds = new Rect(0, 0, 500, 1000);
        // Fullscreen to PiP.
        // Fullscreen to PiP.
@@ -184,7 +183,7 @@ public class PipAnimationControllerTest extends ShellTestCase {
        final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController
        final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController
                .getAnimator(mTaskInfo, mLeash, baseValue, startValue, endValue, null,
                .getAnimator(mTaskInfo, mLeash, baseValue, startValue, endValue, null,
                        TRANSITION_DIRECTION_TO_PIP, 0, ROTATION_0);
                        TRANSITION_DIRECTION_TO_PIP, 0, ROTATION_0);
        animator.setSurfaceControlTransactionFactory(DummySurfaceControlTx::new);
        animator.setSurfaceControlTransactionFactory(PipDummySurfaceControlTx::new);


        animator.setPipAnimationCallback(mPipAnimationCallback);
        animator.setPipAnimationCallback(mPipAnimationCallback);


@@ -201,44 +200,4 @@ public class PipAnimationControllerTest extends ShellTestCase {
        verify(mPipAnimationCallback).onPipAnimationEnd(eq(mTaskInfo),
        verify(mPipAnimationCallback).onPipAnimationEnd(eq(mTaskInfo),
                any(SurfaceControl.Transaction.class), eq(animator));
                any(SurfaceControl.Transaction.class), eq(animator));
    }
    }

    /**
     * A dummy {@link SurfaceControl.Transaction} class.
     * This is created as {@link Mock} does not support method chaining.
     */
    public static class DummySurfaceControlTx extends SurfaceControl.Transaction {
        @Override
        public SurfaceControl.Transaction setAlpha(SurfaceControl leash, float alpha) {
            return this;
        }

        @Override
        public SurfaceControl.Transaction setPosition(SurfaceControl leash, float x, float y) {
            return this;
        }

        @Override
        public SurfaceControl.Transaction setWindowCrop(SurfaceControl leash, int w, int h) {
            return this;
        }

        @Override
        public SurfaceControl.Transaction setCornerRadius(SurfaceControl leash, float radius) {
            return this;
        }

        @Override
        public SurfaceControl.Transaction setMatrix(SurfaceControl leash, Matrix matrix,
                float[] float9) {
            return this;
        }

        @Override
        public SurfaceControl.Transaction setFrameTimelineVsync(long frameTimelineVsyncId) {
            return this;
        }

        @Override
        public void apply() {}
    }
}
}
+66 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.pip;

import android.graphics.Matrix;
import android.view.SurfaceControl;

/**
 * A dummy {@link SurfaceControl.Transaction} class for testing purpose and supports
 * method chaining.
 */
public class PipDummySurfaceControlTx extends SurfaceControl.Transaction {
    @Override
    public SurfaceControl.Transaction setAlpha(SurfaceControl leash, float alpha) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setPosition(SurfaceControl leash, float x, float y) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setWindowCrop(SurfaceControl leash, int w, int h) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setCornerRadius(SurfaceControl leash, float radius) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setShadowRadius(SurfaceControl leash, float radius) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setMatrix(SurfaceControl leash, Matrix matrix,
            float[] float9) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setFrameTimelineVsync(long frameTimelineVsyncId) {
        return this;
    }

    @Override
    public void apply() {}
}
Loading