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

Commit a0786f3f authored by mattsziklay's avatar mattsziklay
Browse files

Allow entering split screen on an app currently open in desktop mode.

Registers a SplitScreenListener to perform necessary windowing changes
when split is requested for an app currently open in desktop mode.

Test: Manual; open a task in desktop, go to overview, perform a split
transition where the second app is the one open in desktop.
Bug: 279586624

Change-Id: Ib00e0fe5d0dd0dfa49b025d78de994fd68af2145
parent 670ecab0
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.wm.shell.common.split;
package com.android.wm.shell.common.split;


import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -60,7 +61,8 @@ public class SplitScreenConstants {
    public static final int[] CONTROLLED_WINDOWING_MODES =
    public static final int[] CONTROLLED_WINDOWING_MODES =
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED};
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED};
    public static final int[] CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE =
    public static final int[] CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE =
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW};
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW,
            WINDOWING_MODE_FREEFORM};


    /** Flag applied to a transition change to identify it as a divider bar for animation. */
    /** Flag applied to a transition change to identify it as a divider bar for animation. */
    public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM;
    public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM;
+19 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.desktopmode


import android.R
import android.R
import android.app.ActivityManager.RunningTaskInfo
import android.app.ActivityManager.RunningTaskInfo
import android.app.WindowConfiguration
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
@@ -301,6 +302,24 @@ class DesktopTasksController(
        }
        }
    }
    }


    /** Move a desktop app to split screen. */
    fun moveToSplit(task: RunningTaskInfo) {
        KtProtoLog.v(
            WM_SHELL_DESKTOP_MODE,
            "DesktopTasksController: moveToSplit taskId=%d",
            task.taskId
        )
        val wct = WindowContainerTransaction()
        wct.setWindowingMode(task.token, WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW)
        wct.setBounds(task.token, null)
        wct.setDensityDpi(task.token, getDefaultDensityDpi())
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
        } else {
            shellTaskOrganizer.applyTransaction(wct)
        }
    }

    /**
    /**
     * The second part of the animated move to desktop transition, called after
     * The second part of the animated move to desktop transition, called after
     * {@link startMoveToDesktop}. Move a task to fullscreen after being dragged from fullscreen
     * {@link startMoveToDesktop}. Move a task to fullscreen after being dragged from fullscreen
+14 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopTasksController;
import com.android.wm.shell.desktopmode.DesktopTasksController;
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.KeyguardChangeListener;
import com.android.wm.shell.sysui.KeyguardChangeListener;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellController;
@@ -200,6 +201,19 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    @Override
    @Override
    public void setSplitScreenController(SplitScreenController splitScreenController) {
    public void setSplitScreenController(SplitScreenController splitScreenController) {
        mSplitScreenController = splitScreenController;
        mSplitScreenController = splitScreenController;
        mSplitScreenController.registerSplitScreenListener(new SplitScreen.SplitScreenListener() {
            @Override
            public void onTaskStageChanged(int taskId, int stage, boolean visible) {
                if (visible) {
                    DesktopModeWindowDecoration decor = mWindowDecorByTaskId.get(taskId);
                    if (decor != null && DesktopModeStatus.isActive(mContext)
                            && decor.mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
                        mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false));
                        mDesktopTasksController.ifPresent(c -> c.moveToSplit(decor.mTaskInfo));
                    }
                }
            }
        });
    }
    }


    @Override
    @Override