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

Commit b6c5c0d9 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Revert "Update display contents when metrics change"

This reverts commit eddb7c09.

Reason for revert: b/36518752

Bug: 36518752
Change-Id: I39773db7b8d02aec360ca80d02b3c161ccf02786
parent eddb7c09
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ import java.util.Arrays;
 * <li>The real display area specifies the part of the display that contains content
 * including the system decorations.  Even so, the real display area may be smaller than the
 * physical size of the display if the window manager is emulating a smaller display
 * using (adb shell wm size).  Use the following methods to query the
 * using (adb shell am display-size).  Use the following methods to query the
 * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li>
 * </ul>
 * </p><p>
@@ -947,7 +947,7 @@ public final class Display {
     * The size is adjusted based on the current rotation of the display.
     * </p><p>
     * The real size may be smaller than the physical size of the screen when the
     * window manager is emulating a smaller display (using adb shell wm size).
     * window manager is emulating a smaller display (using adb shell am display-size).
     * </p>
     *
     * @param outSize Set to the real size of the display.
+1 −15
Original line number Diff line number Diff line
@@ -62,18 +62,7 @@ final class LogicalDisplay {

    private final int mDisplayId;
    private final int mLayerStack;
    /**
     * Override information set by the window manager. Will be reported instead of {@link #mInfo}
     * if not null.
     * @see #setDisplayInfoOverrideFromWindowManagerLocked(DisplayInfo)
     * @see #getDisplayInfoLocked()
     */
    private DisplayInfo mOverrideDisplayInfo;
    /**
     * Current display info. Initialized with {@link #mBaseDisplayInfo}. Set to {@code null} if
     * needs to be updated.
     * @see #getDisplayInfoLocked()
     */
    private DisplayInfo mOverrideDisplayInfo; // set by the window manager
    private DisplayInfo mInfo;

    // The display device that this logical display is based on and which
@@ -272,9 +261,6 @@ final class LogicalDisplay {

            mPrimaryDisplayDeviceInfo = deviceInfo;
            mInfo = null;
            // Make sure that WM will be notified of new changes. It will then decide whether to
            // apply them or not and will set the value again.
            mOverrideDisplayInfo = null;
        }
    }

+4 −65
Original line number Diff line number Diff line
@@ -179,23 +179,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    // Mapping from a token IBinder to a WindowToken object on this display.
    private final HashMap<IBinder, WindowToken> mTokenMap = new HashMap();

    // Initial display metrics.
    int mInitialDisplayWidth = 0;
    int mInitialDisplayHeight = 0;
    int mInitialDisplayDensity = 0;

    /**
     * Overridden display size. Initialized with {@link #mInitialDisplayWidth}
     * and {@link #mInitialDisplayHeight}, but can be set via shell command "adb shell wm size".
     * @see WindowManagerService#setForcedDisplaySize(int, int, int)
     */
    int mBaseDisplayWidth = 0;
    int mBaseDisplayHeight = 0;
    /**
     * Overridden display density for current user. Initialized with {@link #mInitialDisplayDensity}
     * but can be set from Settings or via shell command "adb shell wm density".
     * @see WindowManagerService#setForcedDisplayDensityForUser(int, int, int)
     */
    int mBaseDisplayDensity = 0;
    boolean mDisplayScalingDisabled;
    private final DisplayInfo mDisplayInfo = new DisplayInfo();
@@ -1523,10 +1511,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    void updateDisplayInfo() {
        mDisplay.getDisplayInfo(mDisplayInfo);
        mDisplay.getMetrics(mDisplayMetrics);

        // Check if display metrics changed and update base values if needed.
        updateBaseDisplayMetricsIfNeeded();

        for (int i = mTaskStackContainers.size() - 1; i >= 0; --i) {
            mTaskStackContainers.get(i).updateDisplayInfo(null);
        }
@@ -1542,11 +1526,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            }
        }

        updateBaseDisplayMetrics(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight,
                mDisplayInfo.logicalDensityDpi);
        mInitialDisplayWidth = mDisplayInfo.logicalWidth;
        mInitialDisplayHeight = mDisplayInfo.logicalHeight;
        mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
        mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth;
        mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight;
        mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
        mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
    }

    void getLogicalDisplayRect(Rect out) {
@@ -1576,50 +1559,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    /**
     * If display metrics changed, overrides are not set and it's not just a rotation - update base
     * values.
     */
    private void updateBaseDisplayMetricsIfNeeded() {
        final int orientation = mDisplayInfo.rotation;
        final boolean rotated = (orientation == ROTATION_90 || orientation == ROTATION_270);
        final int newWidth = rotated ? mDisplayInfo.logicalHeight : mDisplayInfo.logicalWidth;
        final int newHeight = rotated ? mDisplayInfo.logicalWidth : mDisplayInfo.logicalHeight;
        int density = mDisplayInfo.logicalDensityDpi;

        boolean displayMetricsChanged = false;

        // Check if display size is not forced and changed in new display info.
        boolean isDisplaySizeForced = mBaseDisplayWidth != mInitialDisplayWidth
                || mBaseDisplayHeight != mInitialDisplayHeight;
        if (!isDisplaySizeForced) {
            displayMetricsChanged = mBaseDisplayWidth != newWidth
                    || mBaseDisplayHeight != newHeight;
        }

        // Check if display density is not forced and changed in new display info.
        final int forcedDensity = mBaseDisplayDensity != mInitialDisplayDensity
                ? mBaseDisplayDensity : 0;
        if (forcedDensity != 0) {
            density = forcedDensity;
        } else {
            displayMetricsChanged |= mBaseDisplayDensity != mDisplayInfo.logicalDensityDpi;
        }

        if (displayMetricsChanged) {
            updateBaseDisplayMetrics(newWidth, newHeight, density);
            mService.reconfigureDisplayLocked(this);
        }
    }

    /** Update base (override) display metrics. */
    void updateBaseDisplayMetrics(int baseWidth, int baseHeight, int baseDensity) {
        mBaseDisplayWidth = baseWidth;
        mBaseDisplayHeight = baseHeight;
        mBaseDisplayDensity = baseDensity;
        mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
    }

    void getContentRect(Rect out) {
        out.set(mContentRect);
    }
+4 −3
Original line number Diff line number Diff line
@@ -5324,8 +5324,8 @@ public class WindowManagerService extends IWindowManager.Stub
                    if (displayContent.mBaseDisplayWidth != width
                            || displayContent.mBaseDisplayHeight != height) {
                        Slog.i(TAG_WM, "FORCED DISPLAY SIZE: " + width + "x" + height);
                        displayContent.updateBaseDisplayMetrics(width, height,
                                displayContent.mBaseDisplayDensity);
                        displayContent.mBaseDisplayWidth = width;
                        displayContent.mBaseDisplayHeight = height;
                    }
                } catch (NumberFormatException ex) {
                }
@@ -5350,7 +5350,8 @@ public class WindowManagerService extends IWindowManager.Stub
    // displayContent must not be null
    private void setForcedDisplaySizeLocked(DisplayContent displayContent, int width, int height) {
        Slog.i(TAG_WM, "Using new display size: " + width + "x" + height);
        displayContent.updateBaseDisplayMetrics(width, height, displayContent.mBaseDisplayDensity);
        displayContent.mBaseDisplayWidth = width;
        displayContent.mBaseDisplayHeight = height;
        reconfigureDisplayLocked(displayContent);
    }