diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 2053826d91a92..1819da4a86a02 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -2781,6 +2781,15 @@ public interface WindowManager extends ViewManager { */ public boolean hasManualSurfaceInsets; + /** + * Whether we should use global insets state when report insets to the window. When set to + * {@code true}, all the insets will be reported to the window regardless of the z-order. + * Otherwise, only the insets above the given window will be reported. + * + * @hide + */ + public boolean receiveInsetsIgnoringZOrder; + /** * Whether the previous surface insets should be used vs. what is currently set. When set * to {@code true}, the view root will ignore surfaces insets in this object and use what @@ -3714,15 +3723,16 @@ public interface WindowManager extends ViewManager { out.writeInt(preferredDisplayModeId); out.writeInt(systemUiVisibility); out.writeInt(subtreeSystemUiVisibility); - out.writeInt(hasSystemUiListeners ? 1 : 0); + out.writeBoolean(hasSystemUiListeners); out.writeInt(inputFeatures); out.writeLong(userActivityTimeout); out.writeInt(surfaceInsets.left); out.writeInt(surfaceInsets.top); out.writeInt(surfaceInsets.right); out.writeInt(surfaceInsets.bottom); - out.writeInt(hasManualSurfaceInsets ? 1 : 0); - out.writeInt(preservePreviousSurfaceInsets ? 1 : 0); + out.writeBoolean(hasManualSurfaceInsets); + out.writeBoolean(receiveInsetsIgnoringZOrder); + out.writeBoolean(preservePreviousSurfaceInsets); out.writeLong(accessibilityIdOfAnchor); TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); out.writeInt(mColorMode); @@ -3783,15 +3793,16 @@ public interface WindowManager extends ViewManager { preferredDisplayModeId = in.readInt(); systemUiVisibility = in.readInt(); subtreeSystemUiVisibility = in.readInt(); - hasSystemUiListeners = in.readInt() != 0; + hasSystemUiListeners = in.readBoolean(); inputFeatures = in.readInt(); userActivityTimeout = in.readLong(); surfaceInsets.left = in.readInt(); surfaceInsets.top = in.readInt(); surfaceInsets.right = in.readInt(); surfaceInsets.bottom = in.readInt(); - hasManualSurfaceInsets = in.readInt() != 0; - preservePreviousSurfaceInsets = in.readInt() != 0; + hasManualSurfaceInsets = in.readBoolean(); + receiveInsetsIgnoringZOrder = in.readBoolean(); + preservePreviousSurfaceInsets = in.readBoolean(); accessibilityIdOfAnchor = in.readLong(); accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mColorMode = in.readInt(); @@ -4020,6 +4031,11 @@ public interface WindowManager extends ViewManager { changes |= SURFACE_INSETS_CHANGED; } + if (receiveInsetsIgnoringZOrder != o.receiveInsetsIgnoringZOrder) { + receiveInsetsIgnoringZOrder = o.receiveInsetsIgnoringZOrder; + changes |= SURFACE_INSETS_CHANGED; + } + if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) { preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets; changes |= SURFACE_INSETS_CHANGED; @@ -4208,6 +4224,9 @@ public interface WindowManager extends ViewManager { sb.append(" (!preservePreviousSurfaceInsets)"); } } + if (receiveInsetsIgnoringZOrder) { + sb.append(" receive insets ignoring z-order"); + } if (mColorMode != COLOR_MODE_DEFAULT) { sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode)); } diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index 75176df6aaf77..a971794dc97de 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -124,7 +124,8 @@ class InsetsStateController { ? provider.getSource().getType() : ITYPE_INVALID; return getInsetsForTarget(type, target.getWindowingMode(), target.isAlwaysOnTop(), target.getFrozenInsetsState() != null ? target.getFrozenInsetsState() : - target.mAboveInsetsState); + (target.mAttrs.receiveInsetsIgnoringZOrder ? mState : + target.mAboveInsetsState)); } InsetsState getInsetsForWindowMetrics(@NonNull WindowManager.LayoutParams attrs) { diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java index be036034542eb..80961d7afb70b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java @@ -416,6 +416,16 @@ public class InsetsStateControllerTest extends WindowTestsBase { verify(navBar, atLeastOnce()).notifyInsetsChanged(); } + @Test + public void testDispatchGlobalInsets() { + final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); + getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); + final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); + assertNull(getController().getInsetsForWindow(app).peekSource(ITYPE_NAVIGATION_BAR)); + app.mAttrs.receiveInsetsIgnoringZOrder = true; + assertNotNull(getController().getInsetsForWindow(app).peekSource(ITYPE_NAVIGATION_BAR)); + } + private WindowState createTestWindow(String name) { final WindowState win = createWindow(null, TYPE_APPLICATION, name); win.setHasSurface(true);