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

Commit 8ccc4fcf authored by Robert Carr's avatar Robert Carr
Browse files

BLASTSyncEngine: Disable overlapping calls to a single container

Currently we only keep one copy of mWaitingListener and
mBLASTSyncTransaction per level of the hierarchy and so we
are unable to support multiple sync operations at the same level.
For now skip overlapping syncs (making them unsynced). It's relatively
easy for the client to avoid overlapping calls, so this should be
good enough for now. In the future we'd like to keep a map
of mWaitingListener per SyncID, but there is a little
additional complexity about keeping multiple mBLASTSyncTransactions
which we will probably wait for S to tackle.

Bug: 151389300
Test: TaskOrganizerTests
Change-Id: I09efb6bc33468b1e060b8c21bab8cefba65a340e
parent 59624b21
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -2476,9 +2476,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<

    boolean prepareForSync(BLASTSyncEngine.TransactionReadyListener waitingListener,
            int waitingId) {
        boolean willSync = false;
        if (!isVisible()) {
            return willSync;
        boolean willSync = true;

        // If we are invisible, no need to sync, likewise if we are already engaged in a sync,
        // we can't support overlapping syncs on a single container yet.
        if (!isVisible() || mWaitingListener != null) {
            return false;
        }
        mUsingBLASTSyncTransaction = true;

+32 −0
Original line number Diff line number Diff line
@@ -532,6 +532,9 @@ public class TaskOrganizerTests extends WindowTestsBase {
        final Task task = createTaskInStack(stackController1, 0 /* userId */);
        final ITaskOrganizer organizer = registerMockOrganizer();

        spyOn(task);
        doReturn(true).when(task).isVisible();

        BLASTSyncEngine bse = new BLASTSyncEngine();

        BLASTSyncEngine.TransactionReadyListener transactionListener =
@@ -545,6 +548,35 @@ public class TaskOrganizerTests extends WindowTestsBase {
            .transactionReady(anyInt(), any());
    }

    @Test
    public void testOverlappingBLASTCallback() throws RemoteException {
        final ActivityStack stackController1 = createTaskStackOnDisplay(mDisplayContent);
        final Task task = createTaskInStack(stackController1, 0 /* userId */);
        final ITaskOrganizer organizer = registerMockOrganizer();

        spyOn(task);
        doReturn(true).when(task).isVisible();
        final WindowState w = createAppWindow(task, TYPE_APPLICATION, "Enlightened Window");
        makeWindowVisible(w);

        BLASTSyncEngine bse = new BLASTSyncEngine();

        BLASTSyncEngine.TransactionReadyListener transactionListener =
            mock(BLASTSyncEngine.TransactionReadyListener.class);

        int id = bse.startSyncSet(transactionListener);
        assertEquals(true, bse.addToSyncSet(id, task));
        bse.setReady(id);

        int id2 = bse.startSyncSet(transactionListener);
        // We should be rejected from the second sync since we are already
        // in one.
        assertEquals(false, bse.addToSyncSet(id2, task));
        w.finishDrawing(null);
        assertEquals(true, bse.addToSyncSet(id2, task));
        bse.setReady(id2);
    }

    @Test
    public void testBLASTCallbackWithWindow() {
        final ActivityStack stackController1 = createTaskStackOnDisplay(mDisplayContent);