Updates destination bounds upon rotation change

This would be a bug for any PiP-enabled application if the preferred
fullscreen is in a different screen rotation than in PiP mode.

Bug: 150360003
Test: atest PinnedStackTests
Test: manually enter/exit PiP w/ Play movies app
Change-Id: Ibb56d907b9968eaf90171315faa6181a7e72b146
This commit is contained in:
Hongwei Wang
2020-02-27 13:47:52 -08:00
parent 92a82e2d81
commit ea2ae858d0
3 changed files with 23 additions and 4 deletions

View File

@@ -99,6 +99,10 @@ public class PipAnimationController {
return mCurrentAnimator;
}
PipTransitionAnimator getCurrentAnimator() {
return mCurrentAnimator;
}
private PipTransitionAnimator setupPipTransitionAnimator(PipTransitionAnimator animator) {
animator.setInterpolator(mFastOutSlowInInterpolator);
animator.setFloatValues(FRACTION_START, FRACTION_END);

View File

@@ -166,7 +166,22 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
* Updates the display dimension with given {@link DisplayInfo}
*/
public void onDisplayInfoChanged(DisplayInfo displayInfo) {
mDisplayBounds.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
final Rect newDisplayBounds = new Rect(0, 0,
displayInfo.logicalWidth, displayInfo.logicalHeight);
if (!mDisplayBounds.equals(newDisplayBounds)) {
// Updates the exiting PiP animation in case the screen rotation changes in the middle.
// It's a legit case that PiP window is in portrait mode on home screen and
// the application requests landscape onces back to fullscreen mode.
final PipAnimationController.PipTransitionAnimator animator =
mPipAnimationController.getCurrentAnimator();
if (animator != null
&& animator.getAnimationType() == ANIM_TYPE_BOUNDS
&& animator.getDestinationBounds().equals(mDisplayBounds)) {
animator.updateEndValue(newDisplayBounds);
animator.setDestinationBounds(newDisplayBounds);
}
}
mDisplayBounds.set(newDisplayBounds);
}
/**

View File

@@ -69,7 +69,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
private IActivityManager mActivityManager;
private Handler mHandler = new Handler();
private final PinnedStackListener mPinnedStackListener = new PipManagerPinnedStackListener();
private final DisplayInfo mTmpDisplayInfo = new DisplayInfo();
private final Rect mTmpInsetBounds = new Rect();
private final Rect mTmpNormalBounds = new Rect();
@@ -211,7 +210,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
mActivityManager = ActivityManager.getService();
try {
WindowManagerWrapper.getInstance().addPinnedStackListener(mPinnedStackListener);
WindowManagerWrapper.getInstance().addPinnedStackListener(
new PipManagerPinnedStackListener());
} catch (RemoteException e) {
Log.e(TAG, "Failed to register pinned stack listener", e);
}
@@ -341,7 +341,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
private void updateMovementBounds(Rect animatingBounds, boolean fromImeAdjustment,
boolean fromShelfAdjustment) {
mPipTaskOrganizer.onDisplayInfoChanged(mTmpDisplayInfo);
// Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before
// passing to mTouchHandler, mTouchHandler would rely on the bounds calculated by
// mPipBoundsHandler with up-to-dated information
@@ -350,6 +349,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
animatingBounds, fromImeAdjustment, fromShelfAdjustment,
mTmpDisplayInfo.rotation);
mPipTaskOrganizer.onDisplayInfoChanged(mTmpDisplayInfo);
}
public void dump(PrintWriter pw) {