summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java6
-rw-r--r--services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java22
2 files changed, 24 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 61ce062d6047..6af730f9abdc 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1088,6 +1088,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
: Math.max(mFrame.bottom - mStableFrame.bottom, 0));
}
+ mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);
+
// Offset the actual frame by the amount layout frame is off.
mFrame.offset(-layoutXDiff, -layoutYDiff);
mCompatFrame.offset(-layoutXDiff, -layoutYDiff);
@@ -1095,10 +1097,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mVisibleFrame.offset(-layoutXDiff, -layoutYDiff);
mStableFrame.offset(-layoutXDiff, -layoutYDiff);
- // TODO(roosa): Figure out what frame exactly this needs to be calculated with.
- mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);
-
-
mCompatFrame.set(mFrame);
if (mEnforceSizeCompat) {
// If there is a size compatibility scale being applied to the
diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
index 4638635a9402..5a563320f9cb 100644
--- a/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
@@ -441,6 +441,28 @@ public class WindowFrameTests extends WindowTestsBase {
assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
}
+ @Test
+ public void testDisplayCutout_tempInsetBounds() {
+ // Regular fullscreen task and window
+ TaskWithBounds task = new TaskWithBounds(new Rect(0, -500, 1000, 1500));
+ task.mFullscreenForTest = false;
+ task.mInsetBounds.set(0, 0, 1000, 2000);
+ WindowState w = createWindow(task, FILL_PARENT, FILL_PARENT);
+ w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
+
+ final Rect pf = new Rect(0, -500, 1000, 1500);
+ // Create a display cutout of size 50x50, aligned top-center
+ final WmDisplayCutout cutout = WmDisplayCutout.computeSafeInsets(
+ fromBoundingRect(500, 0, 550, 50), pf.width(), pf.height());
+
+ w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, pf, cutout, false);
+
+ assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetTop(), 50);
+ assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetBottom(), 0);
+ assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetLeft(), 0);
+ assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
+ }
+
private WindowStateWithTask createWindow(Task task, int width, int height) {
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
attrs.width = width;