Restrict dock sides after rotation
Bug: 27167078
Change-Id: If51626b75321eebc277eb2399ee753ffe489642b
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 44afbcc..c207aea 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -25,6 +25,9 @@
import static android.content.pm.PackageManager.FEATURE_WATCH;
import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
+import static android.view.WindowManager.DOCKED_TOP;
+import static android.view.WindowManager.DOCKED_LEFT;
+import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT;
@@ -6098,6 +6101,17 @@
}
}
+ @Override
+ public boolean isDockSideAllowed(int dockSide) {
+
+ // We do not allow all dock sides at which the navigation bar touches the docked stack.
+ if (!mNavigationBarCanMove) {
+ return dockSide == DOCKED_TOP || dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT;
+ } else {
+ return dockSide == DOCKED_TOP || dockSide == DOCKED_LEFT;
+ }
+ }
+
void sendCloseSystemWindows() {
PhoneWindow.sendCloseSystemWindows(mContext, null);
}
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index c9873a5..2f86ebc 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -336,6 +336,7 @@
final int newRotation = getDisplayInfo().rotation;
mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
if (mStackId == DOCKED_STACK_ID) {
+ repositionDockedStackAfterRotation(mTmpRect2);
snapDockedStackAfterRotation(mTmpRect2);
}
@@ -347,6 +348,43 @@
}
/**
+ * Some dock sides are not allowed by the policy. This method queries the policy and moves
+ * the docked stack around if needed.
+ *
+ * @param inOutBounds the bounds of the docked stack to adjust
+ */
+ private void repositionDockedStackAfterRotation(Rect inOutBounds) {
+ int dockSide = getDockSide(inOutBounds);
+ if (mService.mPolicy.isDockSideAllowed(dockSide)) {
+ return;
+ }
+ mDisplayContent.getLogicalDisplayRect(mTmpRect);
+ dockSide = DockedDividerUtils.invertDockSide(dockSide);
+ switch (dockSide) {
+ case DOCKED_LEFT:
+ int movement = inOutBounds.left;
+ inOutBounds.left -= movement;
+ inOutBounds.right -= movement;
+ break;
+ case DOCKED_RIGHT:
+ movement = mTmpRect.right - inOutBounds.right;
+ inOutBounds.left += movement;
+ inOutBounds.right += movement;
+ break;
+ case DOCKED_TOP:
+ movement = inOutBounds.top;
+ inOutBounds.top -= movement;
+ inOutBounds.bottom -= movement;
+ break;
+ case DOCKED_BOTTOM:
+ movement = mTmpRect.bottom - inOutBounds.bottom;
+ inOutBounds.top += movement;
+ inOutBounds.bottom += movement;
+ break;
+ }
+ }
+
+ /**
* Snaps the bounds after rotation to the closest snap target for the docked stack.
*/
private void snapDockedStackAfterRotation(Rect outBounds) {