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

Commit a75eeb5c authored by Kriti Dang's avatar Kriti Dang Committed by Android (Google) Code Review
Browse files

Merge "Clearing the DPI information, when forced Size is cleared"

parents 022d5e39 952c926a
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 {