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

Commit b89e6029 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make ShellTaskOrganiser respect display id for Home" into main

parents d60f6cfa fa20e66d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -506,10 +506,11 @@ public class ShellTaskOrganizer extends TaskOrganizer {
     * Returns the home task surface, not for wide use.
     */
    @Nullable
    public SurfaceControl getHomeTaskSurface() {
    public SurfaceControl getHomeTaskSurface(int displayId) {
        for (int i = 0; i < mTasks.size(); i++) {
            final TaskAppearedInfo info = mTasks.valueAt(i);
            if (info.getTaskInfo().getActivityType() == ACTIVITY_TYPE_HOME) {
            if (info.getTaskInfo().getActivityType() == ACTIVITY_TYPE_HOME
                    && info.getTaskInfo().displayId == displayId) {
                return info.getLeash();
            }
        }
+21 −17
Original line number Diff line number Diff line
@@ -194,10 +194,16 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
        final boolean isSyntheticRequest = options.getBoolean(
                "is_synthetic_recents_transition", /* defaultValue= */ false);
        final IBinder transition;
        ActivityOptions activityOptions = ActivityOptions.fromBundle(options);
        int displayId = activityOptions.getLaunchDisplayId();
        if (displayId == INVALID_DISPLAY) {
            displayId = DEFAULT_DISPLAY;
        }
        if (isSyntheticRequest) {
            transition = startSyntheticRecentsTransition(listener);
            transition = startSyntheticRecentsTransition(listener, displayId);
        } else {
            transition = startRealRecentsTransition(intent, fillIn, options, wct, listener);
            transition = startRealRecentsTransition(intent, fillIn, options, wct, listener,
                    displayId);
        }
        return transition;
    }
@@ -205,7 +211,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
    /**
     * Starts a synthetic recents transition that is not backed by a real WM transition.
     */
    private IBinder startSyntheticRecentsTransition(@NonNull IRecentsAnimationRunner listener) {
    private IBinder startSyntheticRecentsTransition(@NonNull IRecentsAnimationRunner listener,
            int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                "RecentsTransitionHandler.startRecentsTransition(synthetic)");
        final RecentsController lastController = getLastController();
@@ -218,7 +225,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,

        // Create a new synthetic transition and start it immediately
        final RecentsController controller = new RecentsController(listener);
        controller.startSyntheticTransition();
        controller.startSyntheticTransition(displayId);
        mControllers.add(controller);
        return SYNTHETIC_TRANSITION;
    }
@@ -227,9 +234,10 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
     * Starts a real WM-backed recents transition.
     */
    private IBinder startRealRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
            @Nullable WindowContainerTransaction requestWct, IRecentsAnimationRunner listener) {
            @Nullable WindowContainerTransaction requestWct, IRecentsAnimationRunner listener,
            int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                "RecentsTransitionHandler.startRecentsTransition");
                "RecentsTransitionHandler.startRecentsTransition, displayId=%d", displayId);

        final WindowContainerTransaction wct = requestWct != null
                ? requestWct : new WindowContainerTransaction();
@@ -240,11 +248,6 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
        // requires the handler, but the mixed handler also needs a reference to the transition.
        RecentsMixedHandler mixer = null;
        Consumer<IBinder> setTransitionForMixer = null;
        ActivityOptions activityOptions = ActivityOptions.fromBundle(options);
        int displayId = activityOptions.getLaunchDisplayId();
        if (displayId == INVALID_DISPLAY) {
            displayId = DEFAULT_DISPLAY;
        }
        for (int i = 0; i < mMixers.size(); ++i) {
            setTransitionForMixer = mMixers.get(i).handleRecentsRequest(displayId);
            if (setTransitionForMixer != null) {
@@ -593,30 +596,31 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
        /**
         * Starts a new transition that is not backed by a system transition.
         */
        void startSyntheticTransition() {
        void startSyntheticTransition(int displayId) {
            mTransition = SYNTHETIC_TRANSITION;

            // TODO(b/366021931): Update mechanism for pulling the home task, for now add home as
            //                    both opening and closing since there's some pre-existing
            //                    dependencies on having a closing task
            final ActivityManager.RunningTaskInfo homeTask =
                    mShellTaskOrganizer.getRunningTasks(DEFAULT_DISPLAY).stream()
                    mShellTaskOrganizer.getRunningTasks(displayId).stream()
                            .filter(task -> task.getActivityType() == ACTIVITY_TYPE_HOME)
                            .findFirst()
                            .get();
            final RemoteAnimationTarget openingTarget = TransitionUtil.newSyntheticTarget(
                    homeTask, mShellTaskOrganizer.getHomeTaskSurface(), TRANSIT_OPEN,
                    homeTask, mShellTaskOrganizer.getHomeTaskSurface(displayId), TRANSIT_OPEN,
                    0, true /* isTranslucent */);
            final RemoteAnimationTarget closingTarget = TransitionUtil.newSyntheticTarget(
                    homeTask, mShellTaskOrganizer.getHomeTaskSurface(), TRANSIT_CLOSE,
                    homeTask, mShellTaskOrganizer.getHomeTaskSurface(displayId), TRANSIT_CLOSE,
                    0, true /* isTranslucent */);
            final ArrayList<RemoteAnimationTarget> apps = new ArrayList<>();
            apps.add(openingTarget);
            apps.add(closingTarget);
            try {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                        "[%d] RecentsController.start: calling onAnimationStart with %d apps",
                        mInstanceId, apps.size());
                        "[%d] RecentsController.start: calling onAnimationStart with %d apps, "
                                + "displayId=%d",
                        mInstanceId, apps.size(), displayId);
                mListener.onAnimationStart(this,
                        apps.toArray(new RemoteAnimationTarget[apps.size()]),
                        new RemoteAnimationTarget[0],
+12 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIO

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
@@ -703,6 +704,17 @@ public class ShellTaskOrganizerTests extends ShellTestCase {
        assertFalse(isHomeTaskOnDefaultDisplay(taskInfo));
    }

    @Test
    public void testGetHomeTaskSurface() {
        RunningTaskInfo taskInfo = createTaskInfo(
                /* taskId= */ 1, ACTIVITY_TYPE_HOME, /* displayId= */ 2);
        SurfaceControl taskLeash = new SurfaceControl.Builder()
                .setName("home_task").build();
        mOrganizer.onTaskAppeared(taskInfo, taskLeash);
        assertNull(mOrganizer.getHomeTaskSurface(/* displayId= */ 0));
        assertEquals(mOrganizer.getHomeTaskSurface(/* displayId= */ 2), taskLeash);
    }

    private static RunningTaskInfo createTaskInfo(int taskId, int windowingMode) {
        RunningTaskInfo taskInfo = new RunningTaskInfo();
        taskInfo.taskId = taskId;