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

Commit 952c926a authored by Kriti Dang's avatar Kriti Dang
Browse files

Clearing the DPI information, when forced Size is cleared

Bug: When forced size is cleared, but not DPI, it can result in wrong
DPI information.

Bug: 238951067
Test: adb shell dumpsys display (shows correct dpi values)
Change-Id: Ie8b0b2009ba141072a91262cacf7293d786238b1
parent ae27c955
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -269,6 +269,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    /** For {@link #setForcedScalingMode} to apply flag {@link Display#FLAG_SCALING_DISABLED}. */
    static final int FORCE_SCALING_MODE_DISABLED = 1;

    static final float INVALID_DPI = 0.0f;

    @IntDef(prefix = { "FORCE_SCALING_MODE_" }, value = {
            FORCE_SCALING_MODE_AUTO,
            FORCE_SCALING_MODE_DISABLED
@@ -2935,6 +2937,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    /** If the given width and height equal to initial size, the setting will be cleared. */
    void setForcedSize(int width, int height) {
        setForcedSize(width, height, INVALID_DPI, INVALID_DPI);
    }

    /**
     * If the given width and height equal to initial size, the setting will be cleared.
     * If xPpi or yDpi is equal to {@link #INVALID_DPI}, the values are ignored.
     */
    void setForcedSize(int width, int height, float xDPI, float yDPI) {
  	// Can't force size higher than the maximal allowed
        if (mMaxUiWidth > 0 && width > mMaxUiWidth) {
            final float ratio = mMaxUiWidth / (float) width;
@@ -2954,8 +2964,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        Slog.i(TAG_WM, "Using new display size: " + width + "x" + height);
        updateBaseDisplayMetrics(width, height, mBaseDisplayDensity, mBaseDisplayPhysicalXDpi,
                mBaseDisplayPhysicalYDpi);
        updateBaseDisplayMetrics(width, height, mBaseDisplayDensity,
                xDPI != INVALID_DPI ? xDPI : mBaseDisplayPhysicalXDpi,
                yDPI != INVALID_DPI ? yDPI : mBaseDisplayPhysicalYDpi);
        reconfigureDisplayLocked();

        if (!mIsSizeForced) {
+3 −1
Original line number Diff line number Diff line
@@ -5780,7 +5780,9 @@ public class WindowManagerService extends IWindowManager.Stub
                final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
                if (displayContent != null) {
                    displayContent.setForcedSize(displayContent.mInitialDisplayWidth,
                            displayContent.mInitialDisplayHeight);
                            displayContent.mInitialDisplayHeight,
                            displayContent.mInitialPhysicalXDpi,
                            displayContent.mInitialPhysicalXDpi);
                }
            }
        } finally {