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

Commit 89f86c18 authored by Jeff Chang's avatar Jeff Chang
Browse files

Handle the uncontrolled task in split-screen

Exit the split-screen in case users put the uncontrolled task into
split-screen. This CL do below change to support handling this task.
   1. If no controlling activity appeared, dismiss the split screen
      and show a toast to inform users.
   2. Reparent all tasks out of split root when dismissing instead of
      just reparent controlling tasks.
   3. Disable the split-item from launcher for tasks that are
      uncontrolled.

Bug: 230461945
Bug: 208646963
Bug: 238032411
Test: atest MultiWindowTests
      atest WMShellUnitTests
Change-Id: Iab59561e9d532b10dab8f5063047c4b68b73eb87
parent c2df8dda
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -348,8 +348,10 @@ public final class WindowContainerTransaction implements Parcelable {
     * @param currentParent of the tasks to perform the operation no.
     *                      {@code null} will perform the operation on the display.
     * @param newParent for the tasks. {@code null} will perform the operation on the display.
     * @param windowingModes of the tasks to reparent.
     * @param activityTypes of the tasks to reparent.
     * @param windowingModes of the tasks to reparent. {@code null} ignore this attribute when
     *                       perform the operation.
     * @param activityTypes of the tasks to reparent.  {@code null} ignore this attribute when
     *                      perform the operation.
     * @param onTop When {@code true}, the child goes to the top of parent; otherwise it goes to
     *              the bottom.
     */
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,11 @@
 */
package com.android.wm.shell.common.split;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.annotation.IntDef;

/** Helper utility class of methods and constants that are available to be imported in Launcher. */
@@ -44,4 +49,10 @@ public class SplitScreenConstants {
    })
    public @interface SplitPosition {
    }

    public static final int[] CONTROLLED_ACTIVITY_TYPES = {ACTIVITY_TYPE_STANDARD};
    public static final int[] CONTROLLED_WINDOWING_MODES =
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED};
    public static final int[] CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE =
            {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW};
}
+8 −5
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.wm.shell.splitscreen;

import static com.android.wm.shell.common.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES;
import static com.android.wm.shell.common.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES;

import android.content.Context;
import android.view.SurfaceSession;
import android.window.WindowContainerToken;
@@ -76,8 +79,8 @@ class MainStage extends StageTaskListener {
        wct.reparentTasks(
                rootToken,
                null /* newParent */,
                        CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE,
                        CONTROLLED_ACTIVITY_TYPES,
                null /* windowingModes */,
                null /* activityTypes */,
                toTop);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ class SideStage extends StageTaskListener {
        wct.reparentTasks(
                mRootTaskInfo.token,
                null /* newParent */,
                CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE,
                CONTROLLED_ACTIVITY_TYPES,
                null /* windowingModes */,
                null /* activityTypes */,
                toTop);
        return true;
    }
+10 −5
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.RemoteAnimationTarget.MODE_OPENING;

import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission;
import static com.android.wm.shell.common.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES;
import static com.android.wm.shell.common.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
@@ -64,6 +66,7 @@ import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.InstanceId;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ArrayUtils;
import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
@@ -227,6 +230,12 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
                && mStageCoordinator.getStageOfTask(taskId) != STAGE_TYPE_UNDEFINED;
    }

    public boolean isValidToEnterSplitScreen(@NonNull ActivityManager.RunningTaskInfo taskInfo) {
        return taskInfo.supportsMultiWindow
                && ArrayUtils.contains(CONTROLLED_ACTIVITY_TYPES, taskInfo.getActivityType())
                && ArrayUtils.contains(CONTROLLED_WINDOWING_MODES, taskInfo.getWindowingMode());
    }

    public @SplitPosition int getSplitPosition(int taskId) {
        return mStageCoordinator.getSplitPosition(taskId);
    }
@@ -463,11 +472,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
            return Objects.equals(launchingActivity, pairedActivity);
        }

        if (mFocusingTaskInfo != null
                // TODO (b/238032411): have an API to determine whether an activity is valid for
                //  split screen or not.
                && mFocusingTaskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                && mFocusingTaskInfo.getActivityType() == ACTIVITY_TYPE_STANDARD) {
        if (mFocusingTaskInfo != null && isValidToEnterSplitScreen(mFocusingTaskInfo)) {
            return Objects.equals(mFocusingTaskInfo.baseIntent.getComponent(), launchingActivity);
        }

Loading