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

Commit a8ed7371 authored by Rupesh Bansal's avatar Rupesh Bansal
Browse files

Add committedState change check when emitting events

Bug: 418482849
Test: NA
Flag: EXEMPT trivial change
Change-Id: Ifc05493579a7c168bafbd0b964e09a6aeea0cad8
parent bde539fd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -835,6 +835,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
                    .get(displayId, LOGICAL_DISPLAY_EVENT_BASE);
            boolean hasBasicInfoChanged =
                    !mTempDisplayInfo.equals(newDisplayInfo, /* compareOnlyBasicChanges */ true);

            // The display is no longer valid and needs to be removed.
            if (!display.isValidLocked()) {
                // Remove from group
@@ -888,13 +889,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
            } else if (hasBasicInfoChanged
                    || mTempDisplayInfo.getRefreshRate() != newDisplayInfo.getRefreshRate()
                    || mTempDisplayInfo.appVsyncOffsetNanos != newDisplayInfo.appVsyncOffsetNanos
                    || mTempDisplayInfo.committedState != newDisplayInfo.committedState
                    || mTempDisplayInfo.presentationDeadlineNanos
                    != newDisplayInfo.presentationDeadlineNanos) {
                // If only the hdr/sdr ratio changed, then send just the event for that case
                if ((diff == DisplayDeviceInfo.DIFF_HDR_SDR_RATIO)) {
                    logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_HDR_SDR_RATIO_CHANGED;
                } else {

                    if (hasBasicInfoChanged) {
                        logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_BASIC_CHANGED;
                    }
+19 −0
Original line number Diff line number Diff line
@@ -258,6 +258,25 @@ public class LogicalDisplayMapperTest {
        assertEquals(displayAdded, displayRemoved);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_COMMITTED_STATE_SEPARATE_EVENT)
    public void test_committedStateChanged_eventEmitted() {
        when(mFlagsMock.isCommittedStateSeparateEventEnabled()).thenReturn(true);
        initLogicalDisplayMapper();
        TestDisplayDevice device = createDisplayDevice(TYPE_INTERNAL, 600, 800,
                FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);

        // add
        LogicalDisplay displayAdded = add(device);
        assertEquals(info(displayAdded).address, info(device).address);
        assertEquals(DEFAULT_DISPLAY, id(displayAdded));

        device.getSourceInfo().committedState = STATE_ON;
        mDisplayDeviceRepo.onDisplayDeviceEvent(device, DISPLAY_DEVICE_EVENT_CHANGED);
        verify(mListenerMock).onLogicalDisplayEventLocked(
                mDisplayCaptor.capture(), eq(LOGICAL_DISPLAY_EVENT_COMMITTED_STATE_CHANGED));
    }

    @Test
    public void testDisplayDeviceAddAndRemove_NonInternalTypes() {
        initLogicalDisplayMapper();