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

Commit ce4a0cf9 authored by Adrian Roos's avatar Adrian Roos
Browse files

Properly redispatch systemUiVisibility flags

Fixes two bugs introduced by change
I7bd32531130d199c0734ffcb800194e77b7e16c3:

When the system window insets consumed by DecorView
change as a result of changing flags, the insets must
be redispatched to the hierarchy.

Also fixes a bug where, as a result of removing the wrong
implication of the SYSTEM_UI_FLAG_LAYOUT_STABLE flag by
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, the status bar was
being forced to black when returning from recents.

Bug: 17489047
Bug: 15046646
Change-Id: I127b0ff3b17c4873a7c28d67020f84298ed09db2
parent 41f76639
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -2164,6 +2164,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        private int mLastBottomInset = 0;
        private int mLastRightInset = 0;
        private int mLastSystemUiVisibility = 0;
        private int mLastWindowSystemUiVisibility = 0;


        public DecorView(Context context, int featureId) {
@@ -2749,6 +2750,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            updateColorViews(null /* insets */);
        }

        @Override
        public void onWindowSystemUiVisibilityChanged(int visible) {
            mLastWindowSystemUiVisibility = visible;
            updateColorViews(null /* insets */);
        }

        @Override
        public WindowInsets onApplyWindowInsets(WindowInsets insets) {
            mFrameOffsets.set(insets.getSystemWindowInsets());
@@ -2791,7 +2798,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            }

            WindowManager.LayoutParams attrs = getAttributes();
            int sysUiVisibility = attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility;
            int sysUiVisibility = attrs.systemUiVisibility | mLastWindowSystemUiVisibility;

            // When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, we still need
            // to ensure that the rest of the view hierarchy doesn't notice it, unless they've
@@ -2812,16 +2819,24 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                    lp.rightMargin = consumedRight;
                    lp.bottomMargin = consumedBottom;
                    mContentRoot.setLayoutParams(lp);

                    if (insets == null) {
                        // The insets have changed, but we're not currently in the process
                        // of dispatching them.
                        requestApplyInsets();
                    }
                }

                if (insets != null) {
                insets = insets.consumeStableInsets().replaceSystemWindowInsets(
                    insets = insets.replaceSystemWindowInsets(
                            insets.getSystemWindowInsetLeft(),
                            insets.getSystemWindowInsetTop(),
                            insets.getSystemWindowInsetRight() - consumedRight,
                        insets.getSystemWindowInsetBottom() - consumedBottom
                );
                            insets.getSystemWindowInsetBottom() - consumedBottom);
                }
            }

            if (insets != null) {
                insets = insets.consumeStableInsets();
            }
            return insets;
        }
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static com.android.server.wm.WindowManagerService.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerService.DEBUG_LAYERS;
@@ -1271,9 +1272,10 @@ class WindowStateAnimator {
            // not always reporting the correct system decor rect. In such
            // cases, we take into account the specified content insets as well.
            if ((w.mSystemUiVisibility & SYSTEM_UI_FLAGS_LAYOUT_STABLE_FULLSCREEN)
                    == SYSTEM_UI_FLAGS_LAYOUT_STABLE_FULLSCREEN) {
                    == SYSTEM_UI_FLAGS_LAYOUT_STABLE_FULLSCREEN
                    || (w.mAttrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
                // Don't apply the workaround to apps explicitly requesting
                // fullscreen layout.
                // fullscreen layout or when the bars are transparent.
                clipRect.intersect(mClipRect);
            } else {
                final int offsetTop = Math.max(clipRect.top, w.mContentInsets.top);