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

Commit 89d30ec2 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Change the default behavior with status bar decouple flag

The default behavior will be the devices default behavior, and the flag
will be a hint to enable the override to provide a new behavior override
beforehand.

Also, prepare the override types as a full decouple as it makes no more
sense if we don't apply it by default to decouple only parts of the
system bars.

Rename the legacy thing to override, as the override can happen in two
directions.

Test: DisplayPolicyInsetsTests
Test: DisplayPolicyTests
Bug: 327313645
Change-Id: I6f9de120bd29bfeb9f02ddf2c36fbe44f512a1b8
parent 2483fb08
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8620,7 +8620,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        // Override starts here.
        final Rect stableInsets = mDisplayContent.getDisplayPolicy().getDecorInsetsInfo(
                rotation, fullBounds.width(), fullBounds.height()).mLegacyConfigInsets;
                rotation, fullBounds.width(), fullBounds.height()).mOverrideConfigInsets;
        // This should be the only place override the configuration for ActivityRecord. Override
        // the value if not calculated yet.
        Rect outAppBounds = inOutConfig.windowConfiguration.getAppBounds();
@@ -8656,7 +8656,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            mDisplayContent.getDisplay().getDisplayInfo(info);
            mDisplayContent.computeSizeRanges(info, rotated, info.logicalWidth,
                    info.logicalHeight, mDisplayContent.getDisplayMetrics().density,
                    inOutConfig, true /* legacyConfig */);
                    inOutConfig, true /* overrideConfig */);
        }

        // It's possible that screen size will be considered in different orientation with or
+14 −13
Original line number Diff line number Diff line
@@ -2302,7 +2302,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        computeSizeRanges(mDisplayInfo, rotated, dw, dh, mDisplayMetrics.density, outConfig,
                false /* legacyConfig */);
                false /* overrideConfig */);

        setDisplayInfoOverride();

@@ -2439,7 +2439,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(rotation);
        displayInfo.displayCutout = displayCutout.isEmpty() ? null : displayCutout;
        computeSizeRanges(displayInfo, rotated, dw, dh, mDisplayMetrics.density, outConfig,
                false /* legacyConfig */);
                false /* overrideConfig */);
        return displayInfo;
    }

@@ -2613,11 +2613,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * @param dh Display Height in current rotation.
     * @param density Display density.
     * @param outConfig The output configuration to
     * @param legacyConfig Whether we need to report the legacy result, which is excluding system
     *                     decorations.
     * @param overrideConfig Whether we need to report the override config result
     */
    void computeSizeRanges(DisplayInfo displayInfo, boolean rotated,
            int dw, int dh, float density, Configuration outConfig, boolean legacyConfig) {
            int dw, int dh, float density, Configuration outConfig, boolean overrideConfig) {

        // We need to determine the smallest width that will occur under normal
        // operation.  To this, start with the base screen size and compute the
@@ -2635,10 +2634,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        displayInfo.smallestNominalAppHeight = 1<<30;
        displayInfo.largestNominalAppWidth = 0;
        displayInfo.largestNominalAppHeight = 0;
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, unrotDw, unrotDh, legacyConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, unrotDh, unrotDw, legacyConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, unrotDw, unrotDh, legacyConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, unrotDh, unrotDw, legacyConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, unrotDw, unrotDh, overrideConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, unrotDh, unrotDw, overrideConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, unrotDw, unrotDh,
                overrideConfig);
        adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, unrotDh, unrotDw,
                overrideConfig);

        if (outConfig == null) {
            return;
@@ -2648,17 +2649,17 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int dw, int dh,
            boolean legacyConfig) {
            boolean overrideConfig) {
        final DisplayPolicy.DecorInsets.Info info = mDisplayPolicy.getDecorInsetsInfo(
                rotation, dw, dh);
        final int w;
        final int h;
        if (!legacyConfig) {
        if (!overrideConfig) {
            w = info.mConfigFrame.width();
            h = info.mConfigFrame.height();
        } else {
            w = info.mLegacyConfigFrame.width();
            h = info.mLegacyConfigFrame.height();
            w = info.mOverrideConfigFrame.width();
            h = info.mOverrideConfigFrame.height();
        }
        if (w < displayInfo.smallestNominalAppWidth) {
            displayInfo.smallestNominalAppWidth = w;
+14 −14
Original line number Diff line number Diff line
@@ -1914,9 +1914,9 @@ public class DisplayPolicy {
            final Rect mConfigInsets = new Rect();

            /**
             * Legacy value of mConfigInsets for app compatibility purpose.
             * Override value of mConfigInsets for app compatibility purpose.
             */
            final Rect mLegacyConfigInsets = new Rect();
            final Rect mOverrideConfigInsets = new Rect();

            /** The display frame available after excluding {@link #mNonDecorInsets}. */
            final Rect mNonDecorFrame = new Rect();
@@ -1929,9 +1929,9 @@ public class DisplayPolicy {
            final Rect mConfigFrame = new Rect();

            /**
             * Legacy value of mConfigFrame for app compatibility purpose.
             * Override value of mConfigFrame for app compatibility purpose.
             */
            final Rect mLegacyConfigFrame = new Rect();
            final Rect mOverrideConfigFrame = new Rect();

            private boolean mNeedUpdate = true;

@@ -1947,22 +1947,22 @@ public class DisplayPolicy {
                        ? decor
                        : insetsState.calculateInsets(displayFrame, dc.mWmService.mConfigTypes,
                                true /* ignoreVisibility */);
                final Insets legacyConfigInsets = dc.mWmService.mConfigTypes
                        == dc.mWmService.mLegacyConfigTypes
                final Insets overrideConfigInsets = dc.mWmService.mConfigTypes
                        == dc.mWmService.mOverrideConfigTypes
                        ? configInsets
                        : insetsState.calculateInsets(displayFrame,
                                dc.mWmService.mLegacyConfigTypes, true /* ignoreVisibility */);
                                dc.mWmService.mOverrideConfigTypes, true /* ignoreVisibility */);
                mNonDecorInsets.set(decor.left, decor.top, decor.right, decor.bottom);
                mConfigInsets.set(configInsets.left, configInsets.top, configInsets.right,
                        configInsets.bottom);
                mLegacyConfigInsets.set(legacyConfigInsets.left, legacyConfigInsets.top,
                        legacyConfigInsets.right, legacyConfigInsets.bottom);
                mOverrideConfigInsets.set(overrideConfigInsets.left, overrideConfigInsets.top,
                        overrideConfigInsets.right, overrideConfigInsets.bottom);
                mNonDecorFrame.set(displayFrame);
                mNonDecorFrame.inset(mNonDecorInsets);
                mConfigFrame.set(displayFrame);
                mConfigFrame.inset(mConfigInsets);
                mLegacyConfigFrame.set(displayFrame);
                mLegacyConfigFrame.inset(mLegacyConfigInsets);
                mOverrideConfigFrame.set(displayFrame);
                mOverrideConfigFrame.inset(mOverrideConfigInsets);
                mNeedUpdate = false;
                return insetsState;
            }
@@ -1970,10 +1970,10 @@ public class DisplayPolicy {
            void set(Info other) {
                mNonDecorInsets.set(other.mNonDecorInsets);
                mConfigInsets.set(other.mConfigInsets);
                mLegacyConfigInsets.set(other.mLegacyConfigInsets);
                mOverrideConfigInsets.set(other.mOverrideConfigInsets);
                mNonDecorFrame.set(other.mNonDecorFrame);
                mConfigFrame.set(other.mConfigFrame);
                mLegacyConfigFrame.set(other.mLegacyConfigFrame);
                mOverrideConfigFrame.set(other.mOverrideConfigFrame);
                mNeedUpdate = false;
            }

@@ -2086,7 +2086,7 @@ public class DisplayPolicy {
        final InsetsState newInsetsState = newInfo.update(mDisplayContent, rotation, dw, dh);
        final DecorInsets.Info currentInfo = getDecorInsetsInfo(rotation, dw, dh);
        if (newInfo.mConfigFrame.equals(currentInfo.mConfigFrame)
                && newInfo.mLegacyConfigFrame.equals(currentInfo.mLegacyConfigFrame)) {
                && newInfo.mOverrideConfigFrame.equals(currentInfo.mOverrideConfigFrame)) {
            // Even if the config frame is not changed in current rotation, it may change the
            // insets in other rotations if the frame of insets source is changed.
            final InsetsState currentInsetsState = mDisplayContent.mDisplayFrames.mInsetsState;
+1 −1
Original line number Diff line number Diff line
@@ -2449,7 +2449,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        if (!useLegacyInsetsForStableBounds) {
            intersectWithInsetsIfFits(outStableBounds, mTmpBounds, info.mConfigInsets);
        } else {
            intersectWithInsetsIfFits(outStableBounds, mTmpBounds, info.mLegacyConfigInsets);
            intersectWithInsetsIfFits(outStableBounds, mTmpBounds, info.mOverrideConfigInsets);
        }
    }

+7 −9
Original line number Diff line number Diff line
@@ -561,7 +561,7 @@ public class WindowManagerService extends IWindowManager.Stub
    /** Device default insets types shall be excluded from config app sizes. */
    final int mConfigTypes;

    final int mLegacyConfigTypes;
    final int mOverrideConfigTypes;

    final boolean mLimitedAlphaCompositing;
    final int mMaxUiWidth;
@@ -1195,19 +1195,17 @@ public class WindowManagerService extends IWindowManager.Stub
        if (mFlags.mInsetsDecoupledConfiguration) {
            mDecorTypes = 0;
            mConfigTypes = 0;
        } else if (isScreenSizeDecoupledFromStatusBarAndCutout) {
            mDecorTypes = WindowInsets.Type.navigationBars();
            mConfigTypes = WindowInsets.Type.navigationBars();
        } else {
            mDecorTypes = WindowInsets.Type.displayCutout() | WindowInsets.Type.navigationBars();
            mConfigTypes = WindowInsets.Type.displayCutout() | WindowInsets.Type.statusBars()
                    | WindowInsets.Type.navigationBars();
        }
        if (isScreenSizeDecoupledFromStatusBarAndCutout) {
            // Do not fallback to legacy value for enabled devices.
            mLegacyConfigTypes = WindowInsets.Type.navigationBars();
        if (isScreenSizeDecoupledFromStatusBarAndCutout && !mFlags.mInsetsDecoupledConfiguration) {
            // If the global new behavior is not there, but the partial decouple flag is on.
            mOverrideConfigTypes = 0;
        } else {
            mLegacyConfigTypes = WindowInsets.Type.displayCutout() | WindowInsets.Type.statusBars()
            mOverrideConfigTypes =
                    WindowInsets.Type.displayCutout() | WindowInsets.Type.statusBars()
                            | WindowInsets.Type.navigationBars();
        }