Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipExpandAnimator.java +5 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class PipExpandAnimator extends ValueAnimator { private final SurfaceControl.Transaction mStartTransaction; private final SurfaceControl.Transaction mFinishTransaction; private final @Surface.Rotation int mRotation; private final Boolean mIsPipInDesktopMode; // optional callbacks for tracking animation start and end @Nullable Loading Loading @@ -112,7 +113,8 @@ public class PipExpandAnimator extends ValueAnimator { @NonNull Rect startBounds, @NonNull Rect endBounds, @Nullable Rect sourceRectHint, @Surface.Rotation int rotation) { @Surface.Rotation int rotation, boolean isPipInDesktopMode) { mLeash = leash; mStartTransaction = startTransaction; mFinishTransaction = finishTransaction; Loading @@ -124,6 +126,7 @@ public class PipExpandAnimator extends ValueAnimator { mInsetEvaluator = new RectEvaluator(new Rect()); mPipSurfaceTransactionHelper = new PipSurfaceTransactionHelper(context); mRotation = rotation; mIsPipInDesktopMode = isPipInDesktopMode; mSourceRectHint = sourceRectHint != null ? new Rect(sourceRectHint) : null; if (mSourceRectHint != null) { Loading Loading @@ -179,7 +182,7 @@ public class PipExpandAnimator extends ValueAnimator { mAnimatedRect, insets, degrees, x, y, true /* isExpanding */, mRotation == ROTATION_90); } mPipSurfaceTransactionHelper.round(tx, mLeash, false /* applyCornerRadius */) mPipSurfaceTransactionHelper.round(tx, mLeash, mIsPipInDesktopMode /* applyCornerRadius */) .shadow(tx, mLeash, false /* applyShadowRadius */); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +1 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public class PipTransition extends PipTransitionController implements mPipInteractionHandler = pipInteractionHandler; mExpandHandler = new PipExpandHandler(mContext, pipBoundsState, pipBoundsAlgorithm, pipTransitionState, pipDisplayLayoutState, pipInteractionHandler, pipTransitionState, pipDisplayLayoutState, pipDesktopState, pipInteractionHandler, splitScreenControllerOptional); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/transition/PipExpandHandler.java +9 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.ProtoLog; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDesktopState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.pip2.phone.PipInteractionHandler; Loading @@ -59,6 +60,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final PipTransitionState mPipTransitionState; private final PipDisplayLayoutState mPipDisplayLayoutState; private final PipDesktopState mPipDesktopState; private final PipInteractionHandler mPipInteractionHandler; private final Optional<SplitScreenController> mSplitScreenControllerOptional; Loading @@ -74,6 +76,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { PipBoundsAlgorithm pipBoundsAlgorithm, PipTransitionState pipTransitionState, PipDisplayLayoutState pipDisplayLayoutState, PipDesktopState pipDesktopState, PipInteractionHandler pipInteractionHandler, Optional<SplitScreenController> splitScreenControllerOptional) { mContext = context; Loading @@ -81,6 +84,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipTransitionState = pipTransitionState; mPipDisplayLayoutState = pipDisplayLayoutState; mPipDesktopState = pipDesktopState; mPipInteractionHandler = pipInteractionHandler; mSplitScreenControllerOptional = splitScreenControllerOptional; Loading Loading @@ -186,7 +190,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { PipExpandAnimator animator = mPipExpandAnimatorSupplier.get(mContext, pipLeash, startTransaction, finishTransaction, endBounds, startBounds, endBounds, sourceRectHint, delta); sourceRectHint, delta, mPipDesktopState.isPipInDesktopMode()); animator.setAnimationStartCallback(() -> mPipInteractionHandler.begin(pipLeash, PipInteractionHandler.INTERACTION_EXIT_PIP)); animator.setAnimationEndCallback(() -> { Loading Loading @@ -248,7 +252,8 @@ public class PipExpandHandler implements Transitions.TransitionHandler { final SurfaceControl pipLeash = pipChange.getLeash(); PipExpandAnimator animator = mPipExpandAnimatorSupplier.get(mContext, pipLeash, startTransaction, finishTransaction, endBounds, startBounds, endBounds, null /* srcRectHint */, ROTATION_0 /* delta */); null /* srcRectHint */, ROTATION_0 /* delta */, mPipDesktopState.isPipInDesktopMode()); mSplitScreenControllerOptional.ifPresent(splitController -> { Loading Loading @@ -331,7 +336,8 @@ public class PipExpandHandler implements Transitions.TransitionHandler { @NonNull Rect startBounds, @NonNull Rect endBounds, @Nullable Rect sourceRectHint, @Surface.Rotation int rotation); @Surface.Rotation int rotation, Boolean isPipInDesktopMode); } @VisibleForTesting Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/animation/PipExpandAnimatorTest.java +30 −3 Original line number Diff line number Diff line Loading @@ -75,12 +75,14 @@ public class PipExpandAnimatorTest { private Rect mSourceRectHint; @Surface.Rotation private int mRotation; private SurfaceControl mTestLeash; private static final int CORNER_RADIUS = 32; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mMockContext.getResources()).thenReturn(mMockResources); when(mMockResources.getInteger(anyInt())).thenReturn(0); when(mMockResources.getDimensionPixelSize(anyInt())).thenReturn(CORNER_RADIUS); when(mMockFactory.getTransaction()).thenReturn(mMockTransaction); // No-op on the mMockTransaction when(mMockTransaction.setAlpha(any(SurfaceControl.class), anyFloat())) Loading Loading @@ -132,7 +134,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -155,7 +157,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -178,7 +180,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -193,4 +195,29 @@ public class PipExpandAnimatorTest { verify(mMockTransaction).setCornerRadius(mTestLeash, 0f); verify(mMockTransaction).setShadowRadius(mTestLeash, 0f); } @Test public void onAnimationEnd_expand_isInDesktopMode_setRoundedCorners() { mRotation = Surface.ROTATION_0; mBaseBounds = new Rect(0, 0, 1_000, 2_000); mStartBounds = new Rect(500, 1_000, 1_000, 2_000); mEndBounds = new Rect(mBaseBounds); mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation, true /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); mPipExpandAnimator.setAnimationEndCallback(mMockEndCallback); InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mPipExpandAnimator.start(); clearInvocations(mMockTransaction); mPipExpandAnimator.end(); }); verify(mMockTransaction).setCrop(mTestLeash, mEndBounds); verify(mMockTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS); verify(mMockTransaction).setShadowRadius(mTestLeash, 0f); } } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/phone/transition/PipExpandHandlerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDesktopState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.pip2.phone.PipInteractionHandler; Loading Loading @@ -84,6 +85,7 @@ public class PipExpandHandlerTest { @Mock private PipBoundsAlgorithm mMockPipBoundsAlgorithm; @Mock private PipTransitionState mMockPipTransitionState; @Mock private PipDisplayLayoutState mMockPipDisplayLayoutState; @Mock private PipDesktopState mMockPipDesktopState; @Mock private PipInteractionHandler mMockPipInteractionHandler; @Mock private SplitScreenController mMockSplitScreenController; Loading Loading @@ -116,10 +118,11 @@ public class PipExpandHandlerTest { mPipExpandHandler = new PipExpandHandler(mMockContext, mMockPipBoundsState, mMockPipBoundsAlgorithm, mMockPipTransitionState, mMockPipDisplayLayoutState, mMockPipInteractionHandler, Optional.of(mMockSplitScreenController)); mMockPipDesktopState, mMockPipInteractionHandler, Optional.of(mMockSplitScreenController)); mPipExpandHandler.setPipExpandAnimatorSupplier((context, leash, startTransaction, finishTransaction, baseBounds, startBounds, endBounds, sourceRectHint, rotation) -> mMockPipExpandAnimator); sourceRectHint, rotation, isPipInDesktopMode) -> mMockPipExpandAnimator); } @Test Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipExpandAnimator.java +5 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class PipExpandAnimator extends ValueAnimator { private final SurfaceControl.Transaction mStartTransaction; private final SurfaceControl.Transaction mFinishTransaction; private final @Surface.Rotation int mRotation; private final Boolean mIsPipInDesktopMode; // optional callbacks for tracking animation start and end @Nullable Loading Loading @@ -112,7 +113,8 @@ public class PipExpandAnimator extends ValueAnimator { @NonNull Rect startBounds, @NonNull Rect endBounds, @Nullable Rect sourceRectHint, @Surface.Rotation int rotation) { @Surface.Rotation int rotation, boolean isPipInDesktopMode) { mLeash = leash; mStartTransaction = startTransaction; mFinishTransaction = finishTransaction; Loading @@ -124,6 +126,7 @@ public class PipExpandAnimator extends ValueAnimator { mInsetEvaluator = new RectEvaluator(new Rect()); mPipSurfaceTransactionHelper = new PipSurfaceTransactionHelper(context); mRotation = rotation; mIsPipInDesktopMode = isPipInDesktopMode; mSourceRectHint = sourceRectHint != null ? new Rect(sourceRectHint) : null; if (mSourceRectHint != null) { Loading Loading @@ -179,7 +182,7 @@ public class PipExpandAnimator extends ValueAnimator { mAnimatedRect, insets, degrees, x, y, true /* isExpanding */, mRotation == ROTATION_90); } mPipSurfaceTransactionHelper.round(tx, mLeash, false /* applyCornerRadius */) mPipSurfaceTransactionHelper.round(tx, mLeash, mIsPipInDesktopMode /* applyCornerRadius */) .shadow(tx, mLeash, false /* applyShadowRadius */); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +1 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public class PipTransition extends PipTransitionController implements mPipInteractionHandler = pipInteractionHandler; mExpandHandler = new PipExpandHandler(mContext, pipBoundsState, pipBoundsAlgorithm, pipTransitionState, pipDisplayLayoutState, pipInteractionHandler, pipTransitionState, pipDisplayLayoutState, pipDesktopState, pipInteractionHandler, splitScreenControllerOptional); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/transition/PipExpandHandler.java +9 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.ProtoLog; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDesktopState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.pip2.phone.PipInteractionHandler; Loading @@ -59,6 +60,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final PipTransitionState mPipTransitionState; private final PipDisplayLayoutState mPipDisplayLayoutState; private final PipDesktopState mPipDesktopState; private final PipInteractionHandler mPipInteractionHandler; private final Optional<SplitScreenController> mSplitScreenControllerOptional; Loading @@ -74,6 +76,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { PipBoundsAlgorithm pipBoundsAlgorithm, PipTransitionState pipTransitionState, PipDisplayLayoutState pipDisplayLayoutState, PipDesktopState pipDesktopState, PipInteractionHandler pipInteractionHandler, Optional<SplitScreenController> splitScreenControllerOptional) { mContext = context; Loading @@ -81,6 +84,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipTransitionState = pipTransitionState; mPipDisplayLayoutState = pipDisplayLayoutState; mPipDesktopState = pipDesktopState; mPipInteractionHandler = pipInteractionHandler; mSplitScreenControllerOptional = splitScreenControllerOptional; Loading Loading @@ -186,7 +190,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler { PipExpandAnimator animator = mPipExpandAnimatorSupplier.get(mContext, pipLeash, startTransaction, finishTransaction, endBounds, startBounds, endBounds, sourceRectHint, delta); sourceRectHint, delta, mPipDesktopState.isPipInDesktopMode()); animator.setAnimationStartCallback(() -> mPipInteractionHandler.begin(pipLeash, PipInteractionHandler.INTERACTION_EXIT_PIP)); animator.setAnimationEndCallback(() -> { Loading Loading @@ -248,7 +252,8 @@ public class PipExpandHandler implements Transitions.TransitionHandler { final SurfaceControl pipLeash = pipChange.getLeash(); PipExpandAnimator animator = mPipExpandAnimatorSupplier.get(mContext, pipLeash, startTransaction, finishTransaction, endBounds, startBounds, endBounds, null /* srcRectHint */, ROTATION_0 /* delta */); null /* srcRectHint */, ROTATION_0 /* delta */, mPipDesktopState.isPipInDesktopMode()); mSplitScreenControllerOptional.ifPresent(splitController -> { Loading Loading @@ -331,7 +336,8 @@ public class PipExpandHandler implements Transitions.TransitionHandler { @NonNull Rect startBounds, @NonNull Rect endBounds, @Nullable Rect sourceRectHint, @Surface.Rotation int rotation); @Surface.Rotation int rotation, Boolean isPipInDesktopMode); } @VisibleForTesting Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/animation/PipExpandAnimatorTest.java +30 −3 Original line number Diff line number Diff line Loading @@ -75,12 +75,14 @@ public class PipExpandAnimatorTest { private Rect mSourceRectHint; @Surface.Rotation private int mRotation; private SurfaceControl mTestLeash; private static final int CORNER_RADIUS = 32; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mMockContext.getResources()).thenReturn(mMockResources); when(mMockResources.getInteger(anyInt())).thenReturn(0); when(mMockResources.getDimensionPixelSize(anyInt())).thenReturn(CORNER_RADIUS); when(mMockFactory.getTransaction()).thenReturn(mMockTransaction); // No-op on the mMockTransaction when(mMockTransaction.setAlpha(any(SurfaceControl.class), anyFloat())) Loading Loading @@ -132,7 +134,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -155,7 +157,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -178,7 +180,7 @@ public class PipExpandAnimatorTest { mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation); mRotation, false /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); Loading @@ -193,4 +195,29 @@ public class PipExpandAnimatorTest { verify(mMockTransaction).setCornerRadius(mTestLeash, 0f); verify(mMockTransaction).setShadowRadius(mTestLeash, 0f); } @Test public void onAnimationEnd_expand_isInDesktopMode_setRoundedCorners() { mRotation = Surface.ROTATION_0; mBaseBounds = new Rect(0, 0, 1_000, 2_000); mStartBounds = new Rect(500, 1_000, 1_000, 2_000); mEndBounds = new Rect(mBaseBounds); mPipExpandAnimator = new PipExpandAnimator(mMockContext, mTestLeash, mMockStartTransaction, mMockFinishTransaction, mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint, mRotation, true /* isPipInDesktopMode */); mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory); mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback); mPipExpandAnimator.setAnimationEndCallback(mMockEndCallback); InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mPipExpandAnimator.start(); clearInvocations(mMockTransaction); mPipExpandAnimator.end(); }); verify(mMockTransaction).setCrop(mTestLeash, mEndBounds); verify(mMockTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS); verify(mMockTransaction).setShadowRadius(mTestLeash, 0f); } }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/phone/transition/PipExpandHandlerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDesktopState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.pip2.phone.PipInteractionHandler; Loading Loading @@ -84,6 +85,7 @@ public class PipExpandHandlerTest { @Mock private PipBoundsAlgorithm mMockPipBoundsAlgorithm; @Mock private PipTransitionState mMockPipTransitionState; @Mock private PipDisplayLayoutState mMockPipDisplayLayoutState; @Mock private PipDesktopState mMockPipDesktopState; @Mock private PipInteractionHandler mMockPipInteractionHandler; @Mock private SplitScreenController mMockSplitScreenController; Loading Loading @@ -116,10 +118,11 @@ public class PipExpandHandlerTest { mPipExpandHandler = new PipExpandHandler(mMockContext, mMockPipBoundsState, mMockPipBoundsAlgorithm, mMockPipTransitionState, mMockPipDisplayLayoutState, mMockPipInteractionHandler, Optional.of(mMockSplitScreenController)); mMockPipDesktopState, mMockPipInteractionHandler, Optional.of(mMockSplitScreenController)); mPipExpandHandler.setPipExpandAnimatorSupplier((context, leash, startTransaction, finishTransaction, baseBounds, startBounds, endBounds, sourceRectHint, rotation) -> mMockPipExpandAnimator); sourceRectHint, rotation, isPipInDesktopMode) -> mMockPipExpandAnimator); } @Test Loading