summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yunfan Chen <yunfanc@google.com> 2022-01-12 17:55:09 +0900
committer Yunfan Chen <yunfanc@google.com> 2022-01-12 17:55:09 +0900
commit98cc29d15d7af520d79a1e4d2a6b4405bd802c1c (patch)
treea03176b048e4098132f5366ac92f5db6249d3fb9
parent189f69261ffcfd6e25bb892d007dcc29e47b7b10 (diff)
Support given content insets for non-IME windows
This will let the task bar and all other windows provide an insets frame smaller than the window's frame. This is a regression caused by the flexible insets change. If the window provides both internal insets and the content insets, both of them will be deducted. A comment is added to the provideInternalInsets to avoid the mis-use. There's a long term plan to change the functionality of the provideInternalInsets. Will have it in the follow-up patches. Bug: 212221722 Test: atest DisplayPolicyTests Change-Id: Ib9e414627992b46b1a1d0afa314ea180dfdbc4d6
-rw-r--r--core/java/android/view/WindowManager.java3
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java22
3 files changed, 31 insertions, 4 deletions
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index cd9f3eb65bc8..5be3a57e8527 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -3581,7 +3581,8 @@ public interface WindowManager extends ViewManager {
/**
* If specified, the insets provided by this window will be our window frame minus the
- * insets specified by providedInternalInsets.
+ * insets specified by providedInternalInsets. This should not be used together with
+ * {@link WindowState#mGivenContentInsets}. If both of them are set, both will be applied.
*
* @hide
*/
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index f0e8b8f54e50..6e94dfedee35 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -1122,6 +1122,7 @@ public class DisplayPolicy {
if (!mNavButtonForcedVisible) {
inOutFrame.inset(windowState.getLayoutingAttrs(
displayFrames.mRotation).providedInternalInsets);
+ inOutFrame.inset(win.mGivenContentInsets);
}
},
@@ -1190,9 +1191,12 @@ public class DisplayPolicy {
break;
}
mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
- windowState, inOutFrame) -> inOutFrame.inset(
- windowState.getLayoutingAttrs(displayFrames.mRotation)
- .providedInternalInsets), imeFrameProvider);
+ windowState, inOutFrame) -> {
+ inOutFrame.inset(
+ windowState.getLayoutingAttrs(displayFrames.mRotation)
+ .providedInternalInsets);
+ inOutFrame.inset(win.mGivenContentInsets);
+ }, imeFrameProvider);
mInsetsSourceWindowsExceptIme.add(win);
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java
index 69700052ce74..2b131e1fb7c5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java
@@ -322,4 +322,26 @@ public class DisplayPolicyTests extends WindowTestsBase {
assertFalse(navBarSource.getFrame().isEmpty());
assertTrue(imeSource.getFrame().contains(navBarSource.getFrame()));
}
+
+ @UseTestDisplay(addWindows = { W_NAVIGATION_BAR })
+ @Test
+ public void testInsetsGivenContentFrame() {
+ final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
+ final DisplayInfo displayInfo = new DisplayInfo();
+ displayInfo.logicalWidth = 1000;
+ displayInfo.logicalHeight = 2000;
+ displayInfo.rotation = ROTATION_0;
+
+ WindowManager.LayoutParams attrs = mNavBarWindow.mAttrs;
+ displayPolicy.addWindowLw(mNavBarWindow, attrs);
+ mNavBarWindow.setRequestedSize(attrs.width, attrs.height);
+ mNavBarWindow.getControllableInsetProvider().setServerVisible(true);
+
+ mNavBarWindow.mGivenContentInsets.set(0, 10, 0, 0);
+
+ displayPolicy.layoutWindowLw(mNavBarWindow, null, mDisplayContent.mDisplayFrames);
+ final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState();
+ final InsetsSource navBarSource = state.peekSource(ITYPE_NAVIGATION_BAR);
+ assertEquals(attrs.height - 10, navBarSource.getFrame().height());
+ }
}