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

Commit 782c49d7 authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

Check that modespecs are not null

Change-Id: I259dad565ef86ca9e31918948f8a09caf1106969
Bug: 335720463
Test: atest LocalDisplayAdapterTest
parent 52ad3e2a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -168,6 +168,12 @@ final class LocalDisplayAdapter extends DisplayAdapter {
            }
            SurfaceControl.DesiredDisplayModeSpecs modeSpecs =
                    mSurfaceControlProxy.getDesiredDisplayModeSpecs(displayToken);
            if (modeSpecs == null) {
                // If mode specs is null, it most probably means that display got
                // unplugged very rapidly.
                Slog.w(TAG, "Desired display mode specs from SurfaceFlinger are null");
                return;
            }
            LocalDisplayDevice device = mDevices.get(physicalDisplayId);
            if (device == null) {
                // Display was added.
+14 −0
Original line number Diff line number Diff line
@@ -1141,6 +1141,20 @@ public class LocalDisplayAdapterTest {
        assertThat(info.roundedCorners).isNull();
    }

    @Test
    public void test_createLocalExternalDisplay_displayManagementEnabled_doesNotCrash()
            throws Exception {
        FakeDisplay display = new FakeDisplay(PORT_A);
        display.info.isInternal = false;
        setUpDisplay(display);
        updateAvailableDisplays();
        mAdapter.registerLocked();
        when(mSurfaceControlProxy.getDesiredDisplayModeSpecs(display.token)).thenReturn(null);
        mInjector.getTransmitter().sendHotplug(display, /* connected */ true);
        waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
        assertThat(mListener.addedDisplays.size()).isEqualTo(1);
    }

    @Test
    public void test_createLocalExternalDisplay_displayManagementEnabled_shouldHaveDefaultGroup()
            throws Exception {