From c95ff8433a40eafa422fdf56b782350153f605dd Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 21 Mar 2017 10:20:20 -0700 Subject: [PATCH] Prevent updating aspect ratio unless it is different. - The old check of the bounds assumed there was no expanded state, so when a PiP activity tries to set the aspect ratio from a a menu action, it will cause an animation to the normal bounds again. Bug: 36462497 Test: Set aspect ratio in pip action handler Change-Id: Iba5e9571a3024c8369c2a24d32c2d8f34831ede4 --- .../server/wm/PinnedStackController.java | 7 +++++++ .../wm/PinnedStackWindowController.java | 20 +++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java index 0e6b1b6a6ce91..012480e0410d7 100644 --- a/services/core/java/com/android/server/wm/PinnedStackController.java +++ b/services/core/java/com/android/server/wm/PinnedStackController.java @@ -298,6 +298,13 @@ class PinnedStackController { } } + /** + * @return the current aspect ratio. + */ + float getAspectRatio() { + return mAspectRatio; + } + /** * Sets the current set of actions. */ diff --git a/services/core/java/com/android/server/wm/PinnedStackWindowController.java b/services/core/java/com/android/server/wm/PinnedStackWindowController.java index 6a0e353ea385a..0b2cba3773390 100644 --- a/services/core/java/com/android/server/wm/PinnedStackWindowController.java +++ b/services/core/java/com/android/server/wm/PinnedStackWindowController.java @@ -79,19 +79,17 @@ public class PinnedStackWindowController extends StackWindowController { return; } - final int displayId = mContainer.getDisplayContent().getDisplayId(); - final Rect toBounds = mService.getPictureInPictureBounds(displayId, aspectRatio); - final Rect targetBounds = new Rect(); - mContainer.getAnimatingBounds(targetBounds); - if (!toBounds.equals(targetBounds)) { - animateResizePinnedStack(toBounds, -1 /* duration */); - } - final PinnedStackController pinnedStackController = mContainer.getDisplayContent().getPinnedStackController(); - pinnedStackController.setAspectRatio( - pinnedStackController.isValidPictureInPictureAspectRatio(aspectRatio) - ? aspectRatio : -1f); + + if (Float.compare(aspectRatio, pinnedStackController.getAspectRatio()) != 0) { + final int displayId = mContainer.getDisplayContent().getDisplayId(); + final Rect toBounds = mService.getPictureInPictureBounds(displayId, aspectRatio); + animateResizePinnedStack(toBounds, -1 /* duration */); + pinnedStackController.setAspectRatio( + pinnedStackController.isValidPictureInPictureAspectRatio(aspectRatio) + ? aspectRatio : -1f); + } } }