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

Commit 95ca764c authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Clean up stale external transitions

If an external task view transition is started and returns a null
claim token, we now clean it up, otherwise it will remain in the
pending queue blocking subsequent transitions.

Bug: 392893178
Flag: com.android.wm.shell.enable_create_any_bubble
Test: TaskViewTransitionsTest
Change-Id: I50a8694a4694da237bd5bd1254725765b71f0ee5
parent 9c73c416
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -653,6 +653,15 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
        }
        if (pending.mExternalTransition != null) {
            pending.mClaimed = pending.mExternalTransition.start();
            if (pending.mClaimed == null) {
                ProtoLog.w(WM_SHELL_BUBBLES_NOISY, "TaskViewTransitions.startNextTransition(): "
                        + "taskView=%d starting the external transition returned a null claim "
                        + "token. it may have already finished. removing it so that it does not "
                        + "block other transitions.", pending.mTaskView.hashCode());
                mPending.remove(pending);
                startNextTransition();
                return;
            }
        } else {
            pending.mClaimed = mTransitions.startTransition(pending.mType, pending.mWct, this);
        }
+3 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class BubbleTransitionsTest extends ShellTestCase {
    @Test
    public void testConvertToBubble() {
        // Basic walk-through of convert-to-bubble transition stages
        when(mTransitions.startTransition(anyInt(), any(), any())).thenReturn(mock(IBinder.class));
        final ActivityManager.RunningTaskInfo taskInfo = setupBubble();
        final BubbleTransitions.BubbleTransition bt = mBubbleTransitions.startConvertToBubble(
                mBubble, taskInfo, mExpandedViewManager, mTaskViewFactory, mBubblePositioner,
@@ -319,6 +320,7 @@ public class BubbleTransitionsTest extends ShellTestCase {

    @Test
    public void testConvertFromBubble() {
        when(mTransitions.startTransition(anyInt(), any(), any())).thenReturn(mock(IBinder.class));
        final ActivityManager.RunningTaskInfo taskInfo = setupBubble();
        final BubbleTransitions.BubbleTransition bt = mBubbleTransitions.startConvertFromBubble(
                mBubble, taskInfo);
@@ -433,6 +435,7 @@ public class BubbleTransitionsTest extends ShellTestCase {
        when(bev.getViewRootImpl()).thenReturn(vri);
        when(mBubble.getBubbleBarExpandedView()).thenReturn(null);
        when(mBubble.getExpandedView()).thenReturn(bev);
        when(mTransitions.startTransition(anyInt(), any(), any())).thenReturn(mock(IBinder.class));

        final ActivityManager.RunningTaskInfo taskInfo = setupBubble();
        final BubbleTransitions.BubbleTransition bt = mBubbleTransitions.startConvertFromBubble(
+16 −0
Original line number Diff line number Diff line
@@ -477,6 +477,22 @@ public class TaskViewTransitionsTest extends ShellTestCase {
                .isEqualTo(bounds);
    }

    @Test
    public void externalTransitionPending_alreadyFinished_removed() {
        IBinder transition = mock(IBinder.class);
        mTaskViewTransitions.enqueueExternal(mTaskViewTaskController, () -> transition);
        assertThat(mTaskViewTransitions.hasPending()).isTrue();

        // enqueue an external transition, that when started returns a null token as if it has
        // already finished
        mTaskViewTransitions.enqueueExternal(mTaskViewTaskController, () -> null);
        assertThat(mTaskViewTransitions.hasPending()).isTrue();

        mTaskViewTransitions.onExternalDone(transition);

        assertThat(mTaskViewTransitions.hasPending()).isFalse();
    }

    private SurfaceControl.Transaction createMockTransaction() {
        SurfaceControl.Transaction transaction = mock(SurfaceControl.Transaction.class);
        when(transaction.reparent(any(), any())).thenReturn(transaction);