Merge "Sync PiP WM bounds to rotation immediately for fade-in" into tm-dev
This commit is contained in:
@@ -89,6 +89,8 @@ public class PipTransition extends PipTransitionController {
|
|||||||
private final Rect mExitDestinationBounds = new Rect();
|
private final Rect mExitDestinationBounds = new Rect();
|
||||||
@Nullable
|
@Nullable
|
||||||
private IBinder mExitTransition;
|
private IBinder mExitTransition;
|
||||||
|
private IBinder mRequestedEnterTransition;
|
||||||
|
private WindowContainerToken mRequestedEnterTask;
|
||||||
/** The Task window that is currently in PIP windowing mode. */
|
/** The Task window that is currently in PIP windowing mode. */
|
||||||
@Nullable
|
@Nullable
|
||||||
private WindowContainerToken mCurrentPipTaskToken;
|
private WindowContainerToken mCurrentPipTaskToken;
|
||||||
@@ -201,6 +203,9 @@ public class PipTransition extends PipTransitionController {
|
|||||||
}
|
}
|
||||||
mCurrentPipTaskToken = null;
|
mCurrentPipTaskToken = null;
|
||||||
return true;
|
return true;
|
||||||
|
} else if (transition == mRequestedEnterTransition) {
|
||||||
|
mRequestedEnterTransition = null;
|
||||||
|
mRequestedEnterTask = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The previous PIP Task is no longer in PIP, but this is not an exit transition (This can
|
// The previous PIP Task is no longer in PIP, but this is not an exit transition (This can
|
||||||
@@ -243,6 +248,8 @@ public class PipTransition extends PipTransitionController {
|
|||||||
if (request.getType() == TRANSIT_PIP) {
|
if (request.getType() == TRANSIT_PIP) {
|
||||||
WindowContainerTransaction wct = new WindowContainerTransaction();
|
WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
||||||
|
mRequestedEnterTransition = transition;
|
||||||
|
mRequestedEnterTask = request.getTriggerTask().token;
|
||||||
wct.setActivityWindowingMode(request.getTriggerTask().token,
|
wct.setActivityWindowingMode(request.getTriggerTask().token,
|
||||||
WINDOWING_MODE_UNDEFINED);
|
WINDOWING_MODE_UNDEFINED);
|
||||||
final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds();
|
final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds();
|
||||||
@@ -254,6 +261,23 @@ public class PipTransition extends PipTransitionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleRotateDisplay(int startRotation, int endRotation,
|
||||||
|
WindowContainerTransaction wct) {
|
||||||
|
if (mRequestedEnterTransition != null && mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
||||||
|
// A fade-in was requested but not-yet started. In this case, just recalculate the
|
||||||
|
// initial state under the new rotation.
|
||||||
|
int rotationDelta = deltaRotation(startRotation, endRotation);
|
||||||
|
if (rotationDelta != Surface.ROTATION_0) {
|
||||||
|
mPipBoundsState.getDisplayLayout().rotateTo(mContext.getResources(), endRotation);
|
||||||
|
final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds();
|
||||||
|
wct.setBounds(mRequestedEnterTask, destinationBounds);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionMerged(@NonNull IBinder transition) {
|
public void onTransitionMerged(@NonNull IBinder transition) {
|
||||||
if (transition != mExitTransition) {
|
if (transition != mExitTransition) {
|
||||||
|
|||||||
@@ -195,6 +195,17 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
|||||||
mPipBoundsAlgorithm);
|
mPipBoundsAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the display is going to rotate.
|
||||||
|
*
|
||||||
|
* @return {@code true} if it was handled, otherwise the existing pip logic
|
||||||
|
* will deal with rotation.
|
||||||
|
*/
|
||||||
|
public boolean handleRotateDisplay(int startRotation, int endRotation,
|
||||||
|
WindowContainerTransaction wct) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface for PiP transitions (both from and to PiP mode)
|
* Callback interface for PiP transitions (both from and to PiP mode)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
*/
|
*/
|
||||||
private final DisplayChangeController.OnDisplayChangingListener mRotationController = (
|
private final DisplayChangeController.OnDisplayChangingListener mRotationController = (
|
||||||
int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) -> {
|
int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) -> {
|
||||||
|
if (mPipTransitionController.handleRotateDisplay(fromRotation, toRotation, t)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mPipBoundsState.getDisplayLayout().rotation() == toRotation) {
|
if (mPipBoundsState.getDisplayLayout().rotation() == toRotation) {
|
||||||
// The same rotation may have been set by auto PiP-able or fixed rotation. So notify
|
// The same rotation may have been set by auto PiP-able or fixed rotation. So notify
|
||||||
// the change with fromRotation=false to apply the rotated destination bounds from
|
// the change with fromRotation=false to apply the rotated destination bounds from
|
||||||
|
|||||||
@@ -520,7 +520,6 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
|||||||
// Legacy dispatch relies on this (for now).
|
// Legacy dispatch relies on this (for now).
|
||||||
ar.mEnteringAnimation = visibleAtTransitionEnd;
|
ar.mEnteringAnimation = visibleAtTransitionEnd;
|
||||||
}
|
}
|
||||||
mController.dispatchLegacyAppTransitionFinished(ar);
|
|
||||||
}
|
}
|
||||||
final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
|
final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
|
||||||
if (wt != null) {
|
if (wt != null) {
|
||||||
@@ -532,6 +531,15 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// dispatch legacy callback in a different loop. This is because multiple legacy handlers
|
||||||
|
// (fixed-rotation/displaycontent) make global changes, so we want to ensure that we've
|
||||||
|
// processed all the participants first (in particular, we want to trigger pip-enter first)
|
||||||
|
for (int i = 0; i < mParticipants.size(); ++i) {
|
||||||
|
final ActivityRecord ar = mParticipants.valueAt(i).asActivityRecord();
|
||||||
|
if (ar != null) {
|
||||||
|
mController.dispatchLegacyAppTransitionFinished(ar);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (activitiesWentInvisible) {
|
if (activitiesWentInvisible) {
|
||||||
// Always schedule stop processing when transition finishes because activities don't
|
// Always schedule stop processing when transition finishes because activities don't
|
||||||
// stop while they are in a transition thus their stop could still be pending.
|
// stop while they are in a transition thus their stop could still be pending.
|
||||||
|
|||||||
Reference in New Issue
Block a user