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

Commit 3bc34195 authored by Matt Sziklay's avatar Matt Sziklay Committed by Android (Google) Code Review
Browse files

Merge "Enable split screen button in handle menu." into udc-qpr-dev

parents b31b6675 72f9136b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -325,12 +325,13 @@ public abstract class WMShellModule {
            Optional<RecentTasksController> recentTasks,
            LaunchAdjacentController launchAdjacentController,
            Optional<WindowDecorViewModel> windowDecorViewModel,
            Optional<DesktopTasksController> desktopTasksController,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new SplitScreenController(context, shellInit, shellCommandHandler, shellController,
                shellTaskOrganizer, syncQueue, rootTaskDisplayAreaOrganizer, displayController,
                displayImeController, displayInsetsController, dragAndDropController, transitions,
                transactionPool, iconProvider, recentTasks, launchAdjacentController,
                windowDecorViewModel, mainExecutor);
                windowDecorViewModel, desktopTasksController, mainExecutor);
    }

    //
+5 −0
Original line number Diff line number Diff line
@@ -534,6 +534,11 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
            return result[0];
        }

        @Override
        public void onDesktopSplitSelectAnimComplete(RunningTaskInfo taskInfo) {

        }

        @Override
        public void stashDesktopApps(int displayId) throws RemoteException {
            // Stashing of desktop apps not needed. Apps always launch on desktop
+57 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN
import android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW
import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED
import android.app.WindowConfiguration.WindowingMode
import android.content.Context
@@ -33,7 +34,6 @@ import android.os.IBinder
import android.os.SystemProperties
import android.util.DisplayMetrics.DENSITY_DEFAULT
import android.view.SurfaceControl
import android.view.SurfaceControl.Transaction
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TRANSIT_NONE
import android.view.WindowManager.TRANSIT_OPEN
@@ -56,6 +56,7 @@ import com.android.wm.shell.common.annotations.ExternalThread
import com.android.wm.shell.common.annotations.ShellMainThread
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository.VisibleTasksListener
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.splitscreen.SplitScreenController
import com.android.wm.shell.sysui.ShellCommandHandler
import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.sysui.ShellInit
@@ -105,6 +106,9 @@ class DesktopTasksController(
        get() = context.resources.getDimensionPixelSize(
                com.android.wm.shell.R.dimen.desktop_mode_transition_area_height)

    // This is public to avoid cyclic dependency; it is set by SplitScreenController
    lateinit var splitScreenController: SplitScreenController

    init {
        desktopMode = DesktopModeImpl()
        if (DesktopModeStatus.isProto2Enabled()) {
@@ -262,6 +266,19 @@ class DesktopTasksController(
        }
    }

    /**
     * Perform needed cleanup transaction once animation is complete. Bounds need to be set
     * here instead of initial wct to both avoid flicker and to have task bounds to use for
     * the staging animation.
     *
     * @param taskInfo task entering split that requires a bounds update
     */
    fun onDesktopSplitSelectAnimComplete(taskInfo: RunningTaskInfo) {
        val wct = WindowContainerTransaction()
        wct.setBounds(taskInfo.token, null)
        shellTaskOrganizer.applyTransaction(wct)
    }

    /** Move a task with given `taskId` to fullscreen */
    fun moveToFullscreen(taskId: Int) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToFullscreen(task) }
@@ -688,11 +705,41 @@ class DesktopTasksController(
        wct.setWindowingMode(taskInfo.token, targetWindowingMode)
        wct.setBounds(taskInfo.token, null)
        if (isDesktopDensityOverrideSet()) {
            wct.setDensityDpi(taskInfo.token, getFullscreenDensityDpi())
            wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi())
        }
    }

    private fun getFullscreenDensityDpi(): Int {
    /**
     * Adds split screen changes to a transaction. Note that bounds are not reset here due to
     * animation; see {@link onDesktopSplitSelectAnimComplete}
     */
    private fun addMoveToSplitChanges(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo
    ) {
        wct.setWindowingMode(taskInfo.token, WINDOWING_MODE_MULTI_WINDOW)
        // The task's density may have been overridden in freeform; revert it here as we don't
        // want it overridden in multi-window.
        wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi())
    }

    /**
     * Requests a task be transitioned from desktop to split select. Applies needed windowing
     * changes if this transition is enabled.
     */
    fun requestSplit(
        taskInfo: RunningTaskInfo
    ) {
        val windowingMode = taskInfo.windowingMode
        if (windowingMode == WINDOWING_MODE_FULLSCREEN || windowingMode == WINDOWING_MODE_FREEFORM
        ) {
            val wct = WindowContainerTransaction()
            addMoveToSplitChanges(wct, taskInfo)
            splitScreenController.requestEnterSplitSelect(taskInfo, wct)
        }
    }

    private fun getDefaultDensityDpi(): Int {
        return context.resources.displayMetrics.densityDpi
    }

@@ -969,6 +1016,13 @@ class DesktopTasksController(
            return result[0]
        }

        override fun onDesktopSplitSelectAnimComplete(taskInfo: RunningTaskInfo) {
            ExecutorUtils.executeRemoteCallWithTaskPermission(
                controller,
                "onDesktopSplitSelectAnimComplete"
            ) { c -> c.onDesktopSplitSelectAnimComplete(taskInfo) }
        }

        override fun setTaskListener(listener: IDesktopTaskListener?) {
            KtProtoLog.v(
                    WM_SHELL_DESKTOP_MODE,
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.desktopmode;

import android.app.ActivityManager.RunningTaskInfo;
import com.android.wm.shell.desktopmode.IDesktopTaskListener;

/**
@@ -38,6 +39,9 @@ interface IDesktopMode {
    /** Get count of visible desktop tasks on the given display */
    int getVisibleTaskCount(int displayId);

    /** Perform cleanup transactions after the animation to split select is complete */
    oneway void onDesktopSplitSelectAnimComplete(in RunningTaskInfo taskInfo);

    /** Set listener that will receive callbacks about updates to desktop tasks */
    oneway void setTaskListener(IDesktopTaskListener listener);
}
 No newline at end of file
+12 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.RemoteAnimationTarget;
import android.window.RemoteTransition;

import com.android.wm.shell.splitscreen.ISplitScreenListener;
import com.android.wm.shell.splitscreen.ISplitSelectListener;

/**
 * Interface that is exposed to remote callers to manipulate the splitscreen feature.
@@ -43,6 +44,16 @@ interface ISplitScreen {
     */
    oneway void unregisterSplitScreenListener(in ISplitScreenListener listener) = 2;

    /**
     * Registers a split select listener.
     */
    oneway void registerSplitSelectListener(in ISplitSelectListener listener) = 20;

    /**
     * Unregisters a split select listener.
     */
    oneway void unregisterSplitSelectListener(in ISplitSelectListener listener) = 21;

    /**
     * Removes a task from the side stage.
     */
@@ -148,4 +159,4 @@ interface ISplitScreen {
     */
    RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;
}
// Last id = 19
 No newline at end of file
// Last id = 21
 No newline at end of file
Loading