Merge "DisplayCutout: make dock divider cutout aware" into pi-dev
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java
index cb9453b..b7a5d31 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java
@@ -28,6 +28,7 @@
import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
+import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
@@ -55,6 +56,7 @@
mLp.token = new Binder();
mLp.setTitle(WINDOW_TITLE);
mLp.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION;
+ mLp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 52e4866..eebf2fd 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1032,15 +1032,21 @@
if (mAttrs.type == TYPE_DOCK_DIVIDER) {
// For the docked divider, we calculate the stable insets like a full-screen window
// so it can use it to calculate the snap positions.
- mStableInsets.set(Math.max(mStableFrame.left - mDisplayFrame.left, 0),
- Math.max(mStableFrame.top - mDisplayFrame.top, 0),
- Math.max(mDisplayFrame.right - mStableFrame.right, 0),
- Math.max(mDisplayFrame.bottom - mStableFrame.bottom, 0));
+ final WmDisplayCutout c = displayCutout.calculateRelativeTo(mDisplayFrame);
+ mTmpRect.set(mDisplayFrame);
+ mTmpRect.inset(c.getDisplayCutout().getSafeInsets());
+ mTmpRect.intersectUnchecked(mStableFrame);
+
+ mStableInsets.set(Math.max(mTmpRect.left - mDisplayFrame.left, 0),
+ Math.max(mTmpRect.top - mDisplayFrame.top, 0),
+ Math.max(mDisplayFrame.right - mTmpRect.right, 0),
+ Math.max(mDisplayFrame.bottom - mTmpRect.bottom, 0));
// The divider doesn't care about insets in any case, so set it to empty so we don't
// trigger a relayout when moving it.
mContentInsets.setEmpty();
mVisibleInsets.setEmpty();
+ displayCutout = WmDisplayCutout.NO_CUTOUT;
} else {
getDisplayContent().getBounds(mTmpRect);
// Override right and/or bottom insets in case if the frame doesn't fit the screen in