diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/PinnedStackController.java | 53 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskStack.java | 31 |
2 files changed, 44 insertions, 40 deletions
diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java index 5f41187c1cd9..2a20a70b6ee9 100644 --- a/services/core/java/com/android/server/wm/PinnedStackController.java +++ b/services/core/java/com/android/server/wm/PinnedStackController.java @@ -230,32 +230,37 @@ class PinnedStackController { } /** - * @param preChangeTargetBounds The final bounds of the stack if it is currently animating - * @return the repositioned PIP bounds given it's pre-change bounds, and the new display - * content. + * Updates the display info, calculating and returning the new stack and movement bounds in the + * new orientation of the device if necessary. */ - Rect onDisplayChanged(Rect preChangeStackBounds, Rect preChangeTargetBounds, - DisplayContent displayContent) { - final Rect postChangeStackBounds = new Rect(preChangeTargetBounds); - final DisplayInfo displayInfo = displayContent.getDisplayInfo(); - if (!mDisplayInfo.equals(displayInfo)) { - // Calculate the snap fraction of the current stack along the old movement bounds, and - // then update the stack bounds to the same fraction along the rotated movement bounds. - final Rect preChangeMovementBounds = getMovementBounds(preChangeStackBounds); - final float snapFraction = mSnapAlgorithm.getSnapFraction(preChangeStackBounds, - preChangeMovementBounds); - mDisplayInfo.copyFrom(displayInfo); - - final Rect postChangeMovementBounds = getMovementBounds(preChangeStackBounds, - false /* adjustForIme */); - mSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds, - snapFraction); - if (mIsMinimized) { - applyMinimizedOffset(postChangeStackBounds, postChangeMovementBounds); - } - notifyMovementBoundsChanged(false /* fromImeAdjustment */); + void onTaskStackBoundsChanged(Rect targetBounds, Rect outBounds) { + final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); + if (mDisplayInfo.equals(displayInfo)) { + return; } - return postChangeStackBounds; + + mTmpRect.set(targetBounds); + final Rect postChangeStackBounds = mTmpRect; + + // Calculate the snap fraction of the current stack along the old movement bounds + final Rect preChangeMovementBounds = getMovementBounds(postChangeStackBounds); + final float snapFraction = mSnapAlgorithm.getSnapFraction(postChangeStackBounds, + preChangeMovementBounds); + mDisplayInfo.copyFrom(displayInfo); + + // Calculate the stack bounds in the new orientation to the same same fraction along the + // rotated movement bounds. + final Rect postChangeMovementBounds = getMovementBounds(postChangeStackBounds, + false /* adjustForIme */); + mSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds, + snapFraction); + if (mIsMinimized) { + applyMinimizedOffset(postChangeStackBounds, postChangeMovementBounds); + } + + notifyMovementBoundsChanged(false /* fromImeAdjustment */); + + outBounds.set(postChangeStackBounds); } /** diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index c7532acb3c30..34e99a6e64c5 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -262,6 +262,12 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye if (mDisplayContent != null) { mDisplayContent.mDimLayerController.updateDimLayer(this); + if (mStackId == PINNED_STACK_ID) { + // Update the bounds based on any changes to the display info + getAnimatingBounds(mTmpRect2); + mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged(mTmpRect2, + bounds); + } mAnimationBackgroundSurface.setBounds(bounds); } @@ -391,15 +397,18 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye return false; } + if (StackId.tasksAreFloating(mStackId)) { + // Update stack bounds again since the display info has changed since updateDisplayInfo, + // however, for floating tasks, we don't need to apply the new rotation to the bounds, + // we can just update and return them here + setBounds(mBounds); + mBoundsAfterRotation.set(mBounds); + return true; + } + mTmpRect2.set(mBounds); mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2); switch (mStackId) { - case PINNED_STACK_ID: - Rect targetBounds = new Rect(); - getAnimatingBounds(targetBounds); - mTmpRect2 = mDisplayContent.getPinnedStackController().onDisplayChanged(mBounds, - targetBounds, mDisplayContent); - break; case DOCKED_STACK_ID: repositionDockedStackAfterRotation(mTmpRect2); snapDockedStackAfterRotation(mTmpRect2); @@ -651,7 +660,6 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye mAnimationBackgroundSurface = new DimLayer(mService, this, mDisplayContent.getDisplayId(), "animation background stackId=" + mStackId); - final Rect oldBounds = new Rect(mBounds); Rect bounds = null; final TaskStack dockedStack = dc.getDockedStackIgnoringVisibility(); if (mStackId == DOCKED_STACK_ID @@ -675,15 +683,6 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye } updateDisplayInfo(bounds); - - // Update the pinned stack controller after the display info is updated - if (mStackId == PINNED_STACK_ID) { - Rect targetBounds = new Rect(); - getAnimatingBounds(targetBounds); - mDisplayContent.getPinnedStackController().onDisplayChanged(oldBounds, targetBounds, - mDisplayContent); - } - super.onDisplayChanged(dc); } |