Merge "Reset PiP shadow radius in onTaskVanished" into tm-dev am: 4384a4b74c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17766824 Change-Id: I0c91d16921c01a394bf3c318f3b33cdf698050c8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -924,6 +924,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);
|
||||||
@@ -1569,13 +1570,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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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() {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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() {}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -242,6 +242,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
|
|||||||
mPipBoundsState.setDisplayLayout(new DisplayLayout(info,
|
mPipBoundsState.setDisplayLayout(new DisplayLayout(info,
|
||||||
mContext.getResources(), true, true));
|
mContext.getResources(), true, true));
|
||||||
mSpiedPipTaskOrganizer.setOneShotAnimationType(PipAnimationController.ANIM_TYPE_ALPHA);
|
mSpiedPipTaskOrganizer.setOneShotAnimationType(PipAnimationController.ANIM_TYPE_ALPHA);
|
||||||
|
mSpiedPipTaskOrganizer.setSurfaceControlTransactionFactory(PipDummySurfaceControlTx::new);
|
||||||
doNothing().when(mSpiedPipTaskOrganizer).enterPipWithAlphaAnimation(any(), anyLong());
|
doNothing().when(mSpiedPipTaskOrganizer).enterPipWithAlphaAnimation(any(), anyLong());
|
||||||
doNothing().when(mSpiedPipTaskOrganizer).scheduleAnimateResizePip(any(), anyInt(), any());
|
doNothing().when(mSpiedPipTaskOrganizer).scheduleAnimateResizePip(any(), anyInt(), any());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user