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

Commit 502f5729 authored by Jan Sebechlebsky's avatar Jan Sebechlebsky
Browse files

Make onVirtualDisplayRemoved callback idempotent.

... by not throwing an exception if it's invoked multiple times /
for already released display id.

Bug: 292284597
Test: atest VirtualDisplayTest
Change-Id: I151eafc1f4c2ea3fb5c8ed966965fe7efbd9cc56
parent 3dbac658
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -927,8 +927,9 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
        }

        if (virtualDisplayWrapper == null) {
            throw new IllegalStateException(
                    "Virtual device doesn't have a virtual display with ID " + displayId);
            Slog.w(TAG, "Virtual device " + mDeviceId + " doesn't have a virtual display with ID "
                    + displayId);
            return;
        }

        final long ident = Binder.clearCallingIdentity();
+0 −7
Original line number Diff line number Diff line
@@ -789,13 +789,6 @@ public class VirtualDeviceManagerServiceTest {
                nullable(String.class), eq(DISPLAY_ID_1), eq(null));
    }

    @Test
    public void onVirtualDisplayRemovedLocked_unknownDisplayId_throwsException() {
        final int unknownDisplayId = 999;
        assertThrows(IllegalStateException.class,
                () -> mDeviceImpl.onVirtualDisplayRemoved(unknownDisplayId));
    }

    @Test
    public void onVirtualDisplayRemovedLocked_wakeLockIsReleased() throws RemoteException {
        addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);