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

Commit a5fe6975 authored by Ady Abraham's avatar Ady Abraham
Browse files

DisplayInfo: don't check renderFrameRate for equal()

equal() already checks getRefreshRate in order to determine
if the DisplayInfo differs in the refresh rate the app would
experience. Checking for renderFrameRate is redundant.

This change avoids a duplicate onDisplayChanged event when
both the render frame rate and the the frame rate override change.
For example, the following are considered the same from the app perspective:
 - renderFrameRate=30; frameRateOverride=30
 - renderFrameRate=60; frameRateOverride=30

Bug: 377240935
Test: Running TouchLatency and expanding notification shade
Flag: EXEMPT bugfix
Change-Id: Ic57a785401c515f65a6e89009de43e33c949f7dc
parent e01bd635
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -441,7 +441,6 @@ public final class DisplayInfo implements Parcelable {
                && Objects.equals(displayCutout, other.displayCutout)
                && rotation == other.rotation
                && modeId == other.modeId
                && renderFrameRate == other.renderFrameRate
                && hasArrSupport == other.hasArrSupport
                && defaultModeId == other.defaultModeId
                && userPreferredModeId == other.userPreferredModeId
@@ -694,6 +693,9 @@ public final class DisplayInfo implements Parcelable {
        if (refreshRateOverride > 0) {
            return refreshRateOverride;
        }
        if (renderFrameRate > 0) {
            return renderFrameRate;
        }
        if (supportedModes.length == 0) {
            return 0;
        }
+17 −0
Original line number Diff line number Diff line
@@ -77,6 +77,23 @@ public class DisplayInfoTest {
        assertTrue(displayInfo1.equals(displayInfo2));
    }

    @Test
    public void testRefreshRateOverride_keepsDisplyInfosEqualWhenOverrideIsSame() {
        Display.Mode mode = new Display.Mode(
                /*modeId=*/1, /*width=*/1000, /*height=*/1000, /*refreshRate=*/120);
        DisplayInfo displayInfo1 = new DisplayInfo();
        setSupportedMode(displayInfo1, mode);
        displayInfo1.renderFrameRate = 60;
        displayInfo1.refreshRateOverride = 30;

        DisplayInfo displayInfo2 = new DisplayInfo();
        setSupportedMode(displayInfo2, mode);
        displayInfo2.renderFrameRate = 30;
        displayInfo2.refreshRateOverride = 30;

        assertTrue(displayInfo1.equals(displayInfo2));
    }

    @Test
    public void testRefreshRateOverride_makeDisplayInfosDifferent() {
        Display.Mode mode = new Display.Mode(
+4 −0
Original line number Diff line number Diff line
@@ -3848,6 +3848,10 @@ public class DisplayManagerServiceTest {
        DisplayDeviceInfo displayDeviceInfo = new DisplayDeviceInfo();
        displayDeviceInfo.copyFrom(displayDevice.getDisplayDeviceInfoLocked());
        displayDeviceInfo.modeId = modeId;
        if (modeId > 0 && modeId <= displayDeviceInfo.supportedModes.length) {
            displayDeviceInfo.renderFrameRate =
                displayDeviceInfo.supportedModes[modeId - 1].getRefreshRate();
        }
        updateDisplayDeviceInfo(displayManager, displayDevice, displayDeviceInfo);
    }