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

Commit 0ffd49cb authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Always consume bottom insets when navigation bar is force shown

When an app requests SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION but we
force show the navigation bar, we need to treat for the app like
there is no virtual navigation bar on the device. Because if you
combine it with FLAG_HIDE_NAVIGATION, you'd expect the navigation
bar gets hidden but it doesn't, so there could be content that
overlaps with the navigation bar.

Bug: 27157904
Change-Id: I088e02eae2e723c35e9cb4873de6b1325458533b
parent 155a280e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -271,7 +271,8 @@ public abstract class WallpaperService extends Service {
            @Override
            public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
                    Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                    Configuration newConfig, Rect backDropRect, boolean forceLayout) {
                    Configuration newConfig, Rect backDropRect, boolean forceLayout,
                    boolean alwaysConsumeNavBar) {
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0, outsets);
                mCaller.sendMessage(msg);
@@ -790,7 +791,7 @@ public abstract class WallpaperService extends Service {
                            mFinalStableInsets.set(mDispatchedStableInsets);
                            WindowInsets insets = new WindowInsets(mFinalSystemInsets,
                                    null, mFinalStableInsets,
                                    getResources().getConfiguration().isScreenRound());
                                    getResources().getConfiguration().isScreenRound(), false);
                            if (DEBUG) {
                                Log.v(TAG, "dispatching insets=" + insets);
                            }
+2 −1
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ oneway interface IWindow {

    void resized(in Rect frame, in Rect overscanInsets, in Rect contentInsets,
            in Rect visibleInsets, in Rect stableInsets, in Rect outsets, boolean reportDraw,
            in Configuration newConfig, in Rect backDropFrame, boolean forceLayout);
            in Configuration newConfig, in Rect backDropFrame, boolean forceLayout,
            boolean alwaysConsumeNavBar);
    void moved(int newX, int newY);
    void dispatchAppVisibility(boolean visible);
    void dispatchGetNewSurface();
+2 −1
Original line number Diff line number Diff line
@@ -743,7 +743,8 @@ public class SurfaceView extends View {
        @Override
        public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
                Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                Configuration newConfig, Rect backDropRect, boolean forceLayout) {
                Configuration newConfig, Rect backDropRect, boolean forceLayout,
                boolean alwaysConsumeNavBar) {
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
                if (DEBUG) Log.v(
+7 −0
Original line number Diff line number Diff line
@@ -22516,6 +22516,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        final Rect mOutsets = new Rect();
        /**
         * In multi-window we force show the navigation bar. Because we don't want that the surface
         * size changes in this mode, we instead have a flag whether the navigation bar size should
         * always be consumed, so the app is treated like there is no virtual navigation bar at all.
         */
        boolean mAlwaysConsumeNavBar;
        /**
         * The internal insets given by this window.  This value is
         * supplied by the client (through
+26 −4
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ public final class ViewRootImpl implements ViewParent,
    final Rect mPendingContentInsets = new Rect();
    final Rect mPendingOutsets = new Rect();
    final Rect mPendingBackDropFrame = new Rect();
    boolean mPendingAlwaysConsumeNavBar;
    final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
            = new ViewTreeObserver.InternalInsetsInfo();

@@ -623,6 +624,9 @@ public final class ViewRootImpl implements ViewParent,
                mPendingContentInsets.set(mAttachInfo.mContentInsets);
                mPendingStableInsets.set(mAttachInfo.mStableInsets);
                mPendingVisibleInsets.set(0, 0, 0, 0);
                mAttachInfo.mAlwaysConsumeNavBar =
                        (res & WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_NAV_BAR) != 0;
                mPendingAlwaysConsumeNavBar = mAttachInfo.mAlwaysConsumeNavBar;
                if (DEBUG_LAYOUT) Log.v(mTag, "Added window " + mWindow);
                if (res < WindowManagerGlobal.ADD_OKAY) {
                    mAttachInfo.mRootView = null;
@@ -1345,7 +1349,8 @@ public final class ViewRootImpl implements ViewParent,
            }
            mLastWindowInsets = new WindowInsets(contentInsets,
                    null /* windowDecorInsets */, stableInsets,
                    mContext.getResources().getConfiguration().isScreenRound());
                    mContext.getResources().getConfiguration().isScreenRound(),
                    mAttachInfo.mAlwaysConsumeNavBar);
        }
        return mLastWindowInsets;
    }
@@ -1512,6 +1517,9 @@ public final class ViewRootImpl implements ViewParent,
                if (!mPendingOutsets.equals(mAttachInfo.mOutsets)) {
                    insetsChanged = true;
                }
                if (mPendingAlwaysConsumeNavBar != mAttachInfo.mAlwaysConsumeNavBar) {
                    insetsChanged = true;
                }
                if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
                        || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
                    windowSizeMayChange = true;
@@ -1696,6 +1704,8 @@ public final class ViewRootImpl implements ViewParent,
                final boolean outsetsChanged = !mPendingOutsets.equals(mAttachInfo.mOutsets);
                final boolean surfaceSizeChanged = (relayoutResult
                        & WindowManagerGlobal.RELAYOUT_RES_SURFACE_RESIZED) != 0;
                final boolean alwaysConsumeNavBarChanged =
                        mPendingAlwaysConsumeNavBar != mAttachInfo.mAlwaysConsumeNavBar;
                if (contentInsetsChanged) {
                    mAttachInfo.mContentInsets.set(mPendingContentInsets);
                    if (DEBUG_LAYOUT) Log.v(mTag, "Content insets changing to: "
@@ -1715,6 +1725,10 @@ public final class ViewRootImpl implements ViewParent,
                    // Need to relayout with content insets.
                    contentInsetsChanged = true;
                }
                if (alwaysConsumeNavBarChanged) {
                    mAttachInfo.mAlwaysConsumeNavBar = mPendingAlwaysConsumeNavBar;
                    contentInsetsChanged = true;
                }
                if (contentInsetsChanged || mLastSystemUiVisibility !=
                        mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested
                        || mLastOverscanRequested != mAttachInfo.mOverscanRequested
@@ -3391,6 +3405,7 @@ public final class ViewRootImpl implements ViewParent,
                    mPendingOutsets.set((Rect) args.arg7);
                    mPendingBackDropFrame.set((Rect) args.arg8);
                    mForceNextWindowRelayout = args.argi1 != 0;
                    mPendingAlwaysConsumeNavBar = args.argi2 != 0;

                    args.recycle();

@@ -5570,6 +5585,10 @@ public final class ViewRootImpl implements ViewParent,
                mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
                mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingConfiguration,
                mSurface);

        mPendingAlwaysConsumeNavBar =
                (relayoutResult & WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR) != 0;

        //Log.d(mTag, "<<<<<< BACK FROM relayout");
        if (restore) {
            params.restore();
@@ -5841,7 +5860,8 @@ public final class ViewRootImpl implements ViewParent,

    public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
            Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
            Configuration newConfig, Rect backDropFrame, boolean forceLayout) {
            Configuration newConfig, Rect backDropFrame, boolean forceLayout,
            boolean alwaysConsumeNavBar) {
        if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString()
                + " contentInsets=" + contentInsets.toShortString()
                + " visibleInsets=" + visibleInsets.toShortString()
@@ -5878,6 +5898,7 @@ public final class ViewRootImpl implements ViewParent,
        args.arg7 = sameProcessCall ? new Rect(outsets) : outsets;
        args.arg8 = sameProcessCall ? new Rect(backDropFrame) : backDropFrame;
        args.argi1 = forceLayout ? 1 : 0;
        args.argi2 = alwaysConsumeNavBar ? 1 : 0;
        msg.obj = args;
        mHandler.sendMessage(msg);
    }
@@ -6879,12 +6900,13 @@ public final class ViewRootImpl implements ViewParent,
        @Override
        public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
                Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                Configuration newConfig, Rect backDropFrame, boolean forceLayout) {
                Configuration newConfig, Rect backDropFrame, boolean forceLayout,
                boolean alwaysConsumeNavBar) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
                viewAncestor.dispatchResized(frame, overscanInsets, contentInsets,
                        visibleInsets, stableInsets, outsets, reportDraw, newConfig, backDropFrame,
                        forceLayout);
                        forceLayout, alwaysConsumeNavBar);
            }
        }

Loading