Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f51c6d57 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce a flag to let app get global insets state" into sc-dev

parents 422a19bb 3dc12eba
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -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));
            }
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+10 −0
Original line number Diff line number Diff line
@@ -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);