summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hongwei Wang <hwwang@google.com> 2020-02-27 13:47:52 -0800
committer Hongwei Wang <hwwang@google.com> 2020-02-27 22:41:59 -0800
commitea2ae858d02749083b67ccf0c428cf1d50f5eebe (patch)
treef73f66b528dca53377377df0fb432f2c8fe77b58
parent92a82e2d81eeab8ca766acab814c5a9d6692e845 (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java6
3 files changed, 23 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java b/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
index b5fd406de368..1fc1fe45bbb3 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
@@ -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);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
index 1555153e8d4f..665146e6ba0d 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
@@ -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);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 7b9626871b24..8ada3c393222 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -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) {