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

Commit f8dd48e7 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Removed global windowFrames from PWM"

parents 9232b574 1454b39b
Loading
Loading
Loading
Loading
+60 −56
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;

import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED;
@@ -631,9 +632,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    InputConsumer mInputConsumer = null;

    private final WindowFrames mWindowFrames = new WindowFrames();
    private static final Rect mTmpDisplayCutoutSafeExceptMaybeBarsRect = new Rect();
    private static final Rect mTmpRect = new Rect();
    private static final Rect sTmpDisplayCutoutSafeExceptMaybeBarsRect = new Rect();
    private static final Rect sTmpRect = new Rect();
    private static final Rect sTmpDockedFrame = new Rect();
    private static final Rect sTmpNavFrame = new Rect();
    private static final Rect sTmpLastParentFrame = new Rect();

    WindowState mTopFullscreenOpaqueWindowState;
    WindowState mTopFullscreenOpaqueOrDimmingWindowState;
@@ -4308,9 +4311,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mDockLayer = 0x10000000;
        mStatusBarLayer = -1;

        mWindowFrames.setDisplayCutout(displayFrames.mDisplayCutout);
        mWindowFrames.setParentFrameWasClippedByDisplayCutout(false);

        if (displayFrames.mDisplayId == DEFAULT_DISPLAY) {
            // For purposes of putting out fake window up to steal focus, we will
            // drive nav being hidden only by whether it is requested.
@@ -4377,12 +4377,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return;
        }

        mTmpRect.setEmpty();
        mWindowFrames.setFrames(displayFrames.mDock /* parentFrame */,
                displayFrames.mDock /* displayFrame */, displayFrames.mDock /* overscanFrame */,
                displayFrames.mDock /* contentFrame */, displayFrames.mDock /* visibleFrame */,
                mTmpRect /* decorFrame */, displayFrames.mDock /* stableFrame */,
                displayFrames.mDock /* outsetFrame */);
        sTmpRect.setEmpty();
        sTmpDockedFrame.set(displayFrames.mDock);

        final int displayId = displayFrames.mDisplayId;
        final Rect dockFrame = displayFrames.mDock;
@@ -4396,7 +4392,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                continue;
            }

            w.computeFrameLw(mWindowFrames);
            w.getWindowFrames().setFrames(sTmpDockedFrame /* parentFrame */,
                    sTmpDockedFrame /* displayFrame */, sTmpDockedFrame /* overscanFrame */,
                    sTmpDockedFrame /* contentFrame */, sTmpDockedFrame /* visibleFrame */,
                    sTmpRect /* decorFrame */, sTmpDockedFrame /* stableFrame */,
                    sTmpDockedFrame /* outsetFrame */);
            w.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
            w.computeFrameLw();
            final Rect frame = w.getFrameLw();

            if (frame.left <= 0 && frame.top <= 0) {
@@ -4448,17 +4450,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return false;
        }
        // apply any navigation bar insets
        mTmpRect.setEmpty();
        mWindowFrames.setFrames(displayFrames.mUnrestricted /* parentFrame */,
        sTmpRect.setEmpty();
        mStatusBar.getWindowFrames().setFrames(displayFrames.mUnrestricted /* parentFrame */,
                displayFrames.mUnrestricted /* displayFrame */,
                displayFrames.mStable /* overscanFrame */, displayFrames.mStable /* contentFrame */,
                displayFrames.mStable /* visibleFrame */, mTmpRect /* decorFrame */,
                displayFrames.mStable /* visibleFrame */, sTmpRect /* decorFrame */,
                displayFrames.mStable /* stableFrame */, displayFrames.mStable /* outsetFrame */);

        mStatusBar.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
        mStatusBarLayer = mStatusBar.getSurfaceLayer();

        // Let the status bar determine its size.
        mStatusBar.computeFrameLw(mWindowFrames);
        mStatusBar.computeFrameLw();

        // For layout, the status bar is always at the top with our fixed height.
        displayFrames.mStable.top = displayFrames.mUnrestricted.top
@@ -4468,11 +4470,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                displayFrames.mDisplayCutoutSafe.top);

        // Tell the bar controller where the collapsed status bar content is
        mTmpRect.set(mStatusBar.getContentFrameLw());
        mTmpRect.intersect(displayFrames.mDisplayCutoutSafe);
        mTmpRect.top = mStatusBar.getContentFrameLw().top;  // Ignore top display cutout inset
        mTmpRect.bottom = displayFrames.mStable.top;  // Use collapsed status bar size
        mStatusBarController.setContentFrame(mTmpRect);
        sTmpRect.set(mStatusBar.getContentFrameLw());
        sTmpRect.intersect(displayFrames.mDisplayCutoutSafe);
        sTmpRect.top = mStatusBar.getContentFrameLw().top;  // Ignore top display cutout inset
        sTmpRect.bottom = displayFrames.mStable.top;  // Use collapsed status bar size
        mStatusBarController.setContentFrame(sTmpRect);

        boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0;
        boolean statusBarTranslucent = (sysui
@@ -4512,7 +4514,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return false;
        }

        final Rect navigationFrame = mWindowFrames.mParentFrame;
        final Rect navigationFrame = sTmpNavFrame;
        boolean transientNavBarShowing = mNavigationBarController.isTransientShowing();
        // Force the navigation bar to its appropriate place and size. We need to do this directly,
        // instead of relying on it to bubble up from the nav bar, because this needs to change
@@ -4523,7 +4525,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final Rect dockFrame = displayFrames.mDock;
        mNavigationBarPosition = navigationBarPosition(displayWidth, displayHeight, rotation);

        final Rect cutoutSafeUnrestricted = mTmpRect;
        final Rect cutoutSafeUnrestricted = sTmpRect;
        cutoutSafeUnrestricted.set(displayFrames.mUnrestricted);
        cutoutSafeUnrestricted.intersectUnchecked(displayFrames.mDisplayCutoutSafe);

@@ -4605,15 +4607,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        displayFrames.mContent.set(dockFrame);
        mStatusBarLayer = mNavigationBar.getSurfaceLayer();
        // And compute the final frame.
        mTmpRect.setEmpty();
        mWindowFrames.setFrames(navigationFrame /* parentFrame */,
        sTmpRect.setEmpty();
        mNavigationBar.getWindowFrames().setFrames(navigationFrame /* parentFrame */,
                navigationFrame /* displayFrame */, navigationFrame /* overscanFrame */,
                displayFrames.mDisplayCutoutSafe /* contentFrame */,
                navigationFrame /* visibleFrame */, mTmpRect /* decorFrame */,
                navigationFrame /* visibleFrame */, sTmpRect /* decorFrame */,
                navigationFrame /* stableFrame */,
                displayFrames.mDisplayCutoutSafe /* outsetFrame */);

        mNavigationBar.computeFrameLw(mWindowFrames);
        mNavigationBar.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
        mNavigationBar.computeFrameLw();
        mNavigationBarController.setContentFrame(mNavigationBar.getContentFrameLw());

        if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + navigationFrame);
@@ -4744,17 +4746,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final int requestedSysUiFl = PolicyControl.getSystemUiVisibility(null, attrs);
        final int sysUiFl = requestedSysUiFl | getImpliedSysUiFlagsForLayout(attrs);

        final Rect pf = mWindowFrames.mParentFrame;
        final Rect df = mWindowFrames.mDisplayFrame;
        final Rect of = mWindowFrames.mOverscanFrame;
        final Rect cf = mWindowFrames.mContentFrame;
        final Rect vf = mWindowFrames.mVisibleFrame;
        final Rect dcf = mWindowFrames.mDecorFrame;
        final Rect sf = mWindowFrames.mStableFrame;
        final WindowFrames windowFrames = win.getWindowFrames();

        windowFrames.setHasOutsets(false);
        sTmpLastParentFrame.set(windowFrames.mParentFrame);
        final Rect pf = windowFrames.mParentFrame;
        final Rect df = windowFrames.mDisplayFrame;
        final Rect of = windowFrames.mOverscanFrame;
        final Rect cf = windowFrames.mContentFrame;
        final Rect vf = windowFrames.mVisibleFrame;
        final Rect dcf = windowFrames.mDecorFrame;
        final Rect sf = windowFrames.mStableFrame;
        dcf.setEmpty();
        mWindowFrames.mOutsetFrame.setEmpty();
        mWindowFrames.setParentFrameWasClippedByDisplayCutout(false);
        mWindowFrames.setDisplayCutout(displayFrames.mDisplayCutout);
        windowFrames.setParentFrameWasClippedByDisplayCutout(false);
        windowFrames.setDisplayCutout(displayFrames.mDisplayCutout);

        final boolean hasNavBar = (isDefaultDisplay && mDefaultDisplayPolicy.hasNavigationBar()
                && mNavigationBar != null && mNavigationBar.isVisibleLw());
@@ -4774,7 +4779,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            cf.set(displayFrames.mDock);
            of.set(displayFrames.mDock);
            df.set(displayFrames.mDock);
            pf.set(displayFrames.mDock);
            windowFrames.mParentFrame.set(displayFrames.mDock);
            // IM dock windows layout below the nav bar...
            pf.bottom = df.bottom = of.bottom = displayFrames.mUnrestricted.bottom;
            // ...with content insets above the nav bar
@@ -4876,9 +4881,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                ? displayFrames.mRestricted.bottom
                                : displayFrames.mUnrestricted.bottom;

                        if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
                                        "Laying out status bar window: (%d,%d - %d,%d)",
                                        pf.left, pf.top, pf.right, pf.bottom));
                        if (DEBUG_LAYOUT) Slog.v(TAG, "Laying out status bar window: " + pf);
                    } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0
                            && type >= FIRST_APPLICATION_WINDOW && type <= LAST_SUB_WINDOW) {
                        // Asking to layout into the overscan region, so give it that pure
@@ -4950,17 +4953,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        pf.bottom = df.bottom = of.bottom = cf.bottom =
                                displayFrames.mRestricted.bottom;
                    }
                    if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
                            "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)",
                            pf.left, pf.top, pf.right, pf.bottom));
                    if (DEBUG_LAYOUT) Slog.v(TAG, "Laying out IN_SCREEN status bar window: " + pf);
                } else if (type == TYPE_NAVIGATION_BAR || type == TYPE_NAVIGATION_BAR_PANEL) {
                    // The navigation bar has Real Ultimate Power.
                    of.set(displayFrames.mUnrestricted);
                    df.set(displayFrames.mUnrestricted);
                    pf.set(displayFrames.mUnrestricted);
                    if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
                                    "Laying out navigation bar window: (%d,%d - %d,%d)",
                                    pf.left, pf.top, pf.right, pf.bottom));
                    if (DEBUG_LAYOUT) Slog.v(TAG, "Laying out navigation bar window: " + pf);
                } else if ((type == TYPE_SECURE_SYSTEM_OVERLAY || type == TYPE_SCREENSHOT)
                        && ((fl & FLAG_FULLSCREEN) != 0)) {
                    // Fullscreen secure system overlays get what they ask for. Screenshot region
@@ -5087,7 +5086,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // Ensure that windows with a DEFAULT or NEVER display cutout mode are laid out in
        // the cutout safe zone.
        if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) {
            final Rect displayCutoutSafeExceptMaybeBars = mTmpDisplayCutoutSafeExceptMaybeBarsRect;
            final Rect displayCutoutSafeExceptMaybeBars = sTmpDisplayCutoutSafeExceptMaybeBarsRect;
            displayCutoutSafeExceptMaybeBars.set(displayFrames.mDisplayCutoutSafe);
            if (layoutInScreen && layoutInsetDecor && !requestedFullscreen
                    && cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT) {
@@ -5122,9 +5121,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // They will later be cropped or shifted using the displayFrame in WindowState,
            // which prevents overlap with the DisplayCutout.
            if (!attachedInParent && !floatingInScreenWindow) {
                mTmpRect.set(pf);
                sTmpRect.set(pf);
                pf.intersectUnchecked(displayCutoutSafeExceptMaybeBars);
                mWindowFrames.setParentFrameWasClippedByDisplayCutout(!mTmpRect.equals(pf));
                windowFrames.setParentFrameWasClippedByDisplayCutout(!sTmpRect.equals(pf));
            }
            // Make sure that NO_LIMITS windows clipped to the display don't extend under the
            // cutout.
@@ -5152,8 +5151,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // apply the outsets to floating dialogs, because they wouldn't make sense there.
        final boolean useOutsets = shouldUseOutsets(attrs, fl);
        if (isDefaultDisplay && useOutsets) {
            final Rect osf = mWindowFrames.mOutsetFrame;
            final Rect osf = windowFrames.mOutsetFrame;
            osf.set(cf.left, cf.top, cf.right, cf.bottom);
            windowFrames.setHasOutsets(true);
            int outset = ScreenShapeHelper.getWindowOutsetBottomPx(mContext.getResources());
            if (outset > 0) {
                int rotation = displayFrames.mRotation;
@@ -5180,9 +5180,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()
                + " dcf=" + dcf.toShortString()
                + " sf=" + sf.toShortString()
                + " osf=" + mWindowFrames.mOutsetFrame.toShortString());
                + " osf=" + windowFrames.mOutsetFrame.toShortString() + " " + win);

        if (!sTmpLastParentFrame.equals(pf)) {
            windowFrames.setContentChanged(true);
        }

        win.computeFrameLw(mWindowFrames);
        win.computeFrameLw();
        // Dock windows carve out the bottom of the screen, so normal windows
        // can't appear underneath them.
        if (type == TYPE_INPUT_METHOD && win.isVisibleLw()
+6 −7
Original line number Diff line number Diff line
@@ -63,12 +63,10 @@ import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -95,7 +93,6 @@ import com.android.internal.policy.IShortcutService;
import com.android.server.wm.DisplayFrames;
import com.android.server.wm.DisplayRotation;
import com.android.server.wm.WindowFrames;
import com.android.server.wm.utils.WmDisplayCutout;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -201,10 +198,8 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         * getFrame() if so desired.  Must be called with the window manager
         * lock held.
         *
         * @param windowFrames Container for all the window frames that affect how the window is
         *                     laid out.
         */
        public void computeFrameLw(WindowFrames windowFrames);
        public void computeFrameLw();

        /**
         * Retrieve the current frame of the window that has been assigned by
@@ -477,6 +472,11 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         * Writes {@link com.android.server.wm.IdentifierProto} to stream.
         */
        void writeIdentifierToProto(ProtoOutputStream proto, long fieldId);

        /**
         * @return The {@link WindowFrames} associated with this {@link WindowState}
         */
        WindowFrames getWindowFrames();
    }

    /**
@@ -1167,7 +1167,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
    default void layoutWindowLw(
            WindowState win, WindowState attached, DisplayFrames displayFrames) {}


    /**
     * Return the layout hints for a newly added window. These values are computed on the
     * most recent layout, so they are not guaranteed to be correct.
+3 −3
Original line number Diff line number Diff line
@@ -571,7 +571,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            if (!w.mLayoutAttached) {
                if (mTmpInitial) {
                    //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                    w.mContentChanged = false;
                    w.resetContentChanged();
                }
                if (w.mAttrs.type == TYPE_DREAM) {
                    // Don't layout windows behind a dream, so that if it does stuff like hide
@@ -616,7 +616,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                    || w.mLayoutNeeded) {
                if (mTmpInitial) {
                    //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                    w.mContentChanged = false;
                    w.resetContentChanged();
                }
                w.mLayoutNeeded = false;
                w.prelayout();
@@ -699,7 +699,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        final WindowStateAnimator winAnimator = w.mWinAnimator;

        //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
        w.mContentChanged = false;
        w.resetContentChanged();

        // Moved from updateWindowsAndWallpaperLocked().
        if (w.mHasSurface) {
+30 −6
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.annotation.NonNull;
import android.graphics.Rect;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayCutout;
import android.view.WindowManager;

import com.android.server.wm.utils.InsetUtils;
import com.android.server.wm.utils.WmDisplayCutout;
@@ -191,6 +190,10 @@ public class WindowFrames {

    private final Rect mTmpRect = new Rect();

    private boolean mHasOutsets;

    private boolean mContentChanged;

    public WindowFrames() {
    }

@@ -237,11 +240,9 @@ public class WindowFrames {
     * Calculates the outsets for this windowFrame. The outsets are calculated by the area between
     * the {@link #mOutsetFrame} and the {@link #mContentFrame}. If there are no outsets, then
     * {@link #mOutsets} is set to empty.
     *
     * @param hasOutsets Whether this frame has outsets.
     */
    void calculateOutsets(boolean hasOutsets) {
        if (hasOutsets) {
    void calculateOutsets() {
        if (mHasOutsets) {
            InsetUtils.insetsBetweenFrames(mOutsetFrame, mContentFrame, mOutsets);
        } else {
            mOutsets.setEmpty();
@@ -249,7 +250,8 @@ public class WindowFrames {
    }

    /**
     * Calculate the insets for the type {@link WindowManager.LayoutParams#TYPE_DOCK_DIVIDER}
     * Calculate the insets for the type
     * {@link android.view.WindowManager.LayoutParams#TYPE_DOCK_DIVIDER}
     *
     * @param cutoutInsets The insets for the cutout.
     */
@@ -367,6 +369,28 @@ public class WindowFrames {
        mLastContentInsets.set(-1, -1, -1, -1);
    }

    /**
     * Sets whether the frame has outsets.
     */
    public void setHasOutsets(boolean hasOutsets) {
        mHasOutsets = hasOutsets;
    }

    /**
     * Sets whether the content has changed. This means that either the size or parent frame has
     * changed.
     */
    public void setContentChanged(boolean contentChanged) {
        mContentChanged = contentChanged;
    }

    /**
     * @see #setContentChanged(boolean)
     */
    boolean hasContentChanged() {
        return mContentChanged;
    }

    public void writeToProto(@NonNull ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);
        mParentFrame.writeToProto(proto, PARENT_FRAME);
+30 −42

File changed.

Preview size limit exceeded, changes collapsed.

Loading