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

Commit aa7f3630 authored by Ebru Kurnaz's avatar Ebru Kurnaz Committed by Android (Google) Code Review
Browse files

Merge "Reset display density ratio if forced density is called." into main

parents 2361434e 824551e8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -148,9 +148,8 @@ interface IWindowManager
    * Sets display forced density ratio and forced density in DisplayWindowSettings for
    * the given displayId. Ratio is used to update forced density to persist display size when
    * resolution change happens. Use {@link #setForcedDisplayDensityForUser} when there is no need
    * to handle resolution changes for the display. If setForcedDisplayDensityForUser is used after,
    * this the ratio will be updated to use the last set forced density. Use
    * {@link #clearForcedDisplayDensityForUser} to reset.
    * to handle resolution changes for the display. If setForcedDisplayDensityForUser is used after
    * this, the ratio will be reset. Use {@link #clearForcedDisplayDensityForUser} to reset.
    *
    * @param displayId Id of the display.
    * @param ratio The ratio of forced density to the default density.
+4 −0
Original line number Diff line number Diff line
@@ -3195,6 +3195,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
    }

    void clearForcedDensityRatio() {
        mForcedDisplayDensityRatio = 0.0f;
    }

    /** @param mode {@link #FORCE_SCALING_MODE_AUTO} or {@link #FORCE_SCALING_MODE_DISABLED}. */
    void setForcedScalingMode(@ForceScalingMode int mode) {
        if (mode != FORCE_SCALING_MODE_DISABLED) {
+2 −0
Original line number Diff line number Diff line
@@ -6235,6 +6235,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
        if (displayContent != null) {
            displayContent.setForcedDensity(density, targetUserId);
            displayContent.clearForcedDensityRatio();
            return;
        }

@@ -6246,6 +6247,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        mDisplayWindowSettings.setForcedDensity(info, density, targetUserId);
        mDisplayWindowSettings.setForcedDensityRatio(info, 0.0f);
    }

    @EnforcePermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
+20 −0
Original line number Diff line number Diff line
@@ -1631,6 +1631,26 @@ public class WindowManagerServiceTests extends WindowTestsBase {
                currentUserId);
    }


    @Test
    @EnableFlags(Flags.FLAG_ENABLE_PERSISTING_DISPLAY_SIZE_FOR_CONNECTED_DISPLAYS)
    public void setForcedDisplayDensity_forExternalDisplay_resetsRatio() {
        final DisplayInfo displayInfo = new DisplayInfo(mDisplayInfo);
        displayInfo.displayId = DEFAULT_DISPLAY + 1;
        displayInfo.type = Display.TYPE_EXTERNAL;
        displayInfo.logicalDensityDpi = 100;
        mDisplayContent = createNewDisplay(displayInfo);
        final int currentUserId = ActivityManager.getCurrentUser();
        final float forcedDensityRatio = 2f;

        mWm.setForcedDisplayDensityRatio(displayInfo.displayId, forcedDensityRatio,
                currentUserId);
        mWm.setForcedDisplayDensityForUser(displayInfo.displayId, 200,
                currentUserId);

        verify(mDisplayContent).clearForcedDensityRatio();
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_PERSISTING_DISPLAY_SIZE_FOR_CONNECTED_DISPLAYS)
    public void clearForcedDisplayDensityRatio_clearsRatioAndDensity() {