From d7282448a65bc416a58640cf756402189a25c593 Mon Sep 17 00:00:00 2001 From: Salini Venate Date: Wed, 31 Mar 2021 14:29:54 +0530 Subject: [PATCH] [DO NOT MERGE] Handle landscape and portrait display for PIP rotation Both landscape or portrait display screen scenarios should be handled when logicalWidth and LogicalHeight are updated during the rotation of a pip activity Bug: 185196174 Signed-off-by: Salini Venate Signed-off-by: Swee Yee Fonn Change-Id: Ic0dffb059f1a430ae5b08d91f1fa0d7b585c25ef Test: android.server.cts.ActivityManagerPinnedStackTests Test: #testPinnedStackInBoundsAfterRotation --- .../com/android/systemui/pip/PipBoundsHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java b/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java index 583953ce34af5..50437240a29f7 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java @@ -80,6 +80,7 @@ public class PipBoundsHandler { private int mImeHeight; private boolean mIsShelfShowing; private int mShelfHeight; + private boolean mDefaultLandscape; private final DisplayController.OnDisplaysChangedListener mDisplaysChangedListener = new DisplayController.OnDisplaysChangedListener() { @@ -87,6 +88,7 @@ public class PipBoundsHandler { public void onDisplayAdded(int displayId) { if (displayId == mContext.getDisplayId()) { mDisplayLayout.set(mDisplayController.getDisplayLayout(displayId)); + mDefaultLandscape = (mDisplayInfo.logicalWidth > mDisplayInfo.logicalHeight); } } }; @@ -362,9 +364,17 @@ public class PipBoundsHandler { private void updateDisplayInfoIfNeeded() { final boolean updateNeeded; if ((mDisplayInfo.rotation == ROTATION_0) || (mDisplayInfo.rotation == ROTATION_180)) { - updateNeeded = (mDisplayInfo.logicalWidth > mDisplayInfo.logicalHeight); + if (!mDefaultLandscape) { + updateNeeded = (mDisplayInfo.logicalWidth > mDisplayInfo.logicalHeight); + } else { + updateNeeded = (mDisplayInfo.logicalWidth < mDisplayInfo.logicalHeight); + } } else { - updateNeeded = (mDisplayInfo.logicalWidth < mDisplayInfo.logicalHeight); + if (!mDefaultLandscape) { + updateNeeded = (mDisplayInfo.logicalWidth < mDisplayInfo.logicalHeight); + } else { + updateNeeded = (mDisplayInfo.logicalWidth > mDisplayInfo.logicalHeight); + } } if (updateNeeded) { final int newLogicalHeight = mDisplayInfo.logicalWidth;