Ignore resize request when exiting PiP

When PipTaskOrganizer#removePip is called, the animator in
PipMotionHelper may still be running and issues a conflict window
container transaction at its end. This causes the activity resuming to a
weird bounds after drag to dismiss and re-open, in split-screen mode.

Fixes this by
- In PipMotionHelper, if it's a dismiss action, do not issue the window
container transaction
- In PipTaskOrganizer, if we know we're exiting, do not accept any
resize request

Video: http://rcll/aaaaaabFQoRHlzixHdtY/fCOxvnTXu9RtFYERIdskNf
Bug: 159943928
Test: see video
Change-Id: Ia9dd02f9707f9da74166bee24a015c2bb4e223c2
This commit is contained in:
Hongwei Wang
2020-06-25 22:27:07 -07:00
parent 7d42405bc5
commit 0eb6ecff76
2 changed files with 20 additions and 7 deletions

View File

@@ -612,7 +612,9 @@ public class PipTaskOrganizer extends TaskOrganizer implements
@PipAnimationController.TransitionDirection int direction, int durationMs,
Consumer<Rect> updateBoundsCallback) {
if (!mInPip) {
// can be initiated in other component, ignore if we are no longer in PIP
// TODO: tend to use shouldBlockResizeRequest here as well but need to consider
// the fact that when in exitPip, scheduleAnimateResizePip is executed in the window
// container transaction callback and we want to set the mExitingPip immediately.
return;
}
@@ -668,8 +670,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
private void scheduleFinishResizePip(Rect destinationBounds,
@PipAnimationController.TransitionDirection int direction,
Consumer<Rect> updateBoundsCallback) {
if (!mInPip) {
// can be initiated in other component, ignore if we are no longer in PIP
if (shouldBlockResizeRequest()) {
return;
}
@@ -697,8 +698,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
*/
public void scheduleOffsetPip(Rect originalBounds, int offset, int duration,
Consumer<Rect> updateBoundsCallback) {
if (!mInPip) {
// can be initiated in other component, ignore if we are no longer in PIP
if (shouldBlockResizeRequest()) {
return;
}
if (mShouldDeferEnteringPip) {
@@ -869,6 +869,16 @@ public class PipTaskOrganizer extends TaskOrganizer implements
: params.getAspectRatio();
}
/**
* Resize request can be initiated in other component, ignore if we are no longer in PIP
* or we're exiting from it.
*
* @return {@code true} if the resize request should be blocked/ignored.
*/
private boolean shouldBlockResizeRequest() {
return !mInPip || mExitingPip;
}
/**
* Sync with {@link #mSplitDivider} on destination bounds if PiP is going to split screen.
*

View File

@@ -533,8 +533,11 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
&& !mSpringingToTouch
&& !mMagnetizedPip.getObjectStuckToTarget()) {
mBounds.set(mTemporaryBounds);
mPipTaskOrganizer.scheduleFinishResizePip(mBounds);
if (!mDismissalPending) {
// do not schedule resize if PiP is dismissing, which may cause app re-open to
// mBounds instead of it's normal bounds.
mPipTaskOrganizer.scheduleFinishResizePip(mBounds);
}
mTemporaryBounds.setEmpty();
}