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

Commit 0935d999 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Pipe finish callback through synthetic recents path" into main

parents 43ffc5cd 94a6b224
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -585,7 +585,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
            }

            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                    "[%d] RecentsController.cancelSyntheticTransition reason=%s",
                    "[%d] RecentsController.cancelSyntheticTransition: reason=%s",
                    mInstanceId, reason);
            try {
                // TODO(b/366021931): Notify the correct tasks once we build actual targets, and
@@ -602,13 +602,24 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
         * Called when a synthetic transition is finished.
         * @return
         */
        boolean finishSyntheticTransition() {
        boolean finishSyntheticTransition(IResultReceiver runnerFinishCb, String reason) {
            if (!isSyntheticTransition()) {
                return false;
            }

            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                    "[%d] RecentsController.finishSyntheticTransition", mInstanceId);
                    "[%d] RecentsController.finishSyntheticTransition: reason=%s", mInstanceId,
                    reason);
            if (runnerFinishCb != null) {
                try {
                    ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                            "[%d] RecentsController.finishInner: calling finish callback",
                            mInstanceId);
                    runnerFinishCb.send(0, null);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to report transition finished", e);
                }
            }
            // TODO(b/366021931): Clean up leashes accordingly
            cleanUp();
            return true;
@@ -1230,7 +1241,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,

        private void finishInner(boolean toHome, boolean sendUserLeaveHint,
                IResultReceiver runnerFinishCb, String reason) {
            if (finishSyntheticTransition()) {
            if (finishSyntheticTransition(runnerFinishCb, reason)) {
                return;
            }

+7 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSess

import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -43,6 +44,7 @@ import androidx.test.runner.AndroidJUnit4;

import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.dx.mockito.inline.extended.StaticMockitoSession;
import com.android.internal.os.IResultReceiver;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
@@ -141,8 +143,9 @@ public class RecentsTransitionHandlerTest extends ShellTestCase {
    }

    @Test
    public void testStartSyntheticRecentsTransition_callsOnAnimationStart() throws Exception {
    public void testStartSyntheticRecentsTransition_callsOnAnimationStartAndFinishCallback() throws Exception {
        final IRecentsAnimationRunner runner = mock(IRecentsAnimationRunner.class);
        final IResultReceiver finishCallback = mock(IResultReceiver.class);
        doReturn(new Binder()).when(runner).asBinder();
        Bundle options = new Bundle();
        options.putBoolean("is_synthetic_recents_transition", true);
@@ -151,10 +154,11 @@ public class RecentsTransitionHandlerTest extends ShellTestCase {
                runner);
        verify(runner).onAnimationStart(any(), any(), any(), any(), any(), any());

        // Finish and verify no transition remains
        // Finish and verify no transition remains and that the provided finish callback is called
        mRecentsTransitionHandler.findController(transition).finish(true /* toHome */,
                false /* sendUserLeaveHint */, null /* finishCb */);
                false /* sendUserLeaveHint */, finishCallback);
        mMainExecutor.flushAll();
        verify(finishCallback).send(anyInt(), any());
        assertNull(mRecentsTransitionHandler.findController(transition));
    }