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

Commit 097aaddc authored by Jorge Gil's avatar Jorge Gil
Browse files

Desks: Use correct displayId for active desk look up

When entering overview in CD from desktop, the active desk id should be
set using the CD displayId, otherwise when recents finishes, the desk
may not get deactivated as intended.

Flag: com.android.window.flags.enable_multiple_desktops_backend
Bug: 415030147
Test: manual
Change-Id: Ic3d07b7ab380eabfdaf41cfce78ee66026414762
parent b5aff7b0
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -427,7 +427,8 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
                        new WindowContainerTransaction());
            }
            final MixedTransition mixed = createRecentsMixedTransition(
                    MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition);
                    MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition,
                    request.getTriggerTask().displayId);
            mixed.mLeftoversHandler = handler.first;
            mActiveTransitions.add(mixed);
            return handler.second;
@@ -474,13 +475,13 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
                        displayId));
        if (mRecentsHandler != null) {
            if (mSplitHandler.isSplitScreenVisible()) {
                return this::setRecentsTransitionDuringSplit;
                return transition -> setRecentsTransitionDuringSplit(transition, displayId);
            } else if (mKeyguardHandler.isKeyguardShowing()
                    && !mKeyguardHandler.isKeyguardAnimating()) {
                return this::setRecentsTransitionDuringKeyguard;
                return transition -> setRecentsTransitionDuringKeyguard(transition, displayId);
            } else if (mDesktopTasksController != null
                    && mDesktopTasksController.isAnyDeskActive(displayId)) {
                return this::setRecentsTransitionDuringDesktop;
                return transition -> setRecentsTransitionDuringDesktop(transition, displayId);
            }
        }
        return null;
@@ -504,30 +505,32 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
        }
    }

    private void setRecentsTransitionDuringSplit(IBinder transition) {
    private void setRecentsTransitionDuringSplit(IBinder transition, int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a recents request while "
                + "Split-Screen is foreground, so treat it as Mixed.");
        mActiveTransitions.add(createRecentsMixedTransition(
                MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition));
                MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition, displayId));
    }

    private void setRecentsTransitionDuringKeyguard(IBinder transition) {
    private void setRecentsTransitionDuringKeyguard(IBinder transition, int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a recents request while "
                + "keyguard is visible, so treat it as Mixed.");
        mActiveTransitions.add(createRecentsMixedTransition(
                MixedTransition.TYPE_RECENTS_DURING_KEYGUARD, transition));
                MixedTransition.TYPE_RECENTS_DURING_KEYGUARD, transition, displayId));
    }

    private void setRecentsTransitionDuringDesktop(IBinder transition) {
    private void setRecentsTransitionDuringDesktop(IBinder transition, int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a recents request while "
                + "desktop mode is active, so treat it as Mixed.");
        mActiveTransitions.add(createRecentsMixedTransition(
                MixedTransition.TYPE_RECENTS_DURING_DESKTOP, transition));
                MixedTransition.TYPE_RECENTS_DURING_DESKTOP, transition, displayId));
    }

    private MixedTransition createRecentsMixedTransition(int type, IBinder transition) {
    private MixedTransition createRecentsMixedTransition(int type, IBinder transition,
            int displayId) {
        return new RecentsMixedTransition(type, transition, mPlayer, this, mPipHandler,
                mSplitHandler, mKeyguardHandler, mRecentsHandler, mDesktopTasksController);
                mSplitHandler, mKeyguardHandler, mRecentsHandler, mDesktopTasksController,
                displayId);
    }

    static TransitionInfo subCopy(@NonNull TransitionInfo info,
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.wm.shell.transition;

import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_UNOCCLUDING;

import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
@@ -54,13 +53,14 @@ class RecentsMixedTransition extends DefaultMixedHandler.MixedTransition {
            MixedTransitionHandler mixedHandler, PipTransitionController pipHandler,
            StageCoordinator splitHandler, KeyguardTransitionHandler keyguardHandler,
            RecentsTransitionHandler recentsHandler,
            DesktopTasksController desktopTasksController) {
            DesktopTasksController desktopTasksController,
            int displayId) {
        super(type, transition, player, mixedHandler, pipHandler, splitHandler, keyguardHandler);
        mRecentsHandler = recentsHandler;
        mDesktopTasksController = desktopTasksController;
        mLeftoversHandler = mRecentsHandler;
        mActiveDeskIdOnStart = mType == TYPE_RECENTS_DURING_DESKTOP
                ? mDesktopTasksController.getActiveDeskId(DEFAULT_DISPLAY) : null;
                ? mDesktopTasksController.getActiveDeskId(displayId) : null;
    }

    @Override