Loading core/java/android/window/WindowContainerTransaction.java +39 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,33 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Sets the container as launch adjacent flag root. Task starting with * {@link FLAG_ACTIVITY_LAUNCH_ADJACENT} will be launching to. * * @hide */ @NonNull public WindowContainerTransaction setLaunchAdjacentFlagRoot( @NonNull WindowContainerToken container) { mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), false /* clearRoot */)); return this; } /** * Clears launch adjacent flag root for the display area of passing container. * * @hide */ @NonNull public WindowContainerTransaction clearLaunchAdjacentFlagRoot( @NonNull WindowContainerToken container) { mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), true /* clearRoot */)); return this; } /** * Starts a task by id. The task is expected to already exist (eg. as a recent task). * @param taskId Id of task to start. Loading Loading @@ -677,6 +704,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT = 3; public static final int HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS = 4; public static final int HIERARCHY_OP_TYPE_LAUNCH_TASK = 5; public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT = 6; // The following key(s) are for use with mLaunchOptions: // When launching a task (eg. from recents), this is the taskId to be launched. Loading Loading @@ -734,6 +762,14 @@ public final class WindowContainerTransaction implements Parcelable { fullOptions); } /** Create a hierarchy op for setting launch adjacent flag root. */ public static HierarchyOp createForSetLaunchAdjacentFlagRoot(IBinder container, boolean clearRoot) { return new HierarchyOp(HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT, container, null, null, null, clearRoot, null); } private HierarchyOp(int type, @Nullable IBinder container, @Nullable IBinder reparent, int[] windowingModes, int[] activityTypes, boolean toTop, @Nullable Bundle launchOptions) { Loading Loading @@ -829,6 +865,9 @@ public final class WindowContainerTransaction implements Parcelable { + " adjacentRoot=" + mReparent + "}"; case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "{LaunchTask: " + mLaunchOptions + "}"; case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "{SetAdjacentFlagRoot: container=" + mContainer + " clearRoot=" + mToTop + "}"; default: return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent + " mToTop=" + mToTop + " mWindowingMode=" + mWindowingModes Loading libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +3 −0 Original line number Diff line number Diff line Loading @@ -337,6 +337,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Make the stages adjacent to each other so they occlude what's behind them. wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token); wct.setLaunchAdjacentFlagRoot(mSideStage.mRootTaskInfo.token); mTaskOrganizer.applyTransaction(wct); } } Loading @@ -346,6 +347,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Deactivate the main stage if it no longer has a root task. mMainStage.deactivate(wct); wct.clearLaunchAdjacentFlagRoot(mSideStage.mRootTaskInfo.token); mTaskOrganizer.applyTransaction(wct); } } Loading Loading @@ -449,6 +451,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Make sure the main stage is active. mMainStage.activate(getMainStageBounds(), wct); mSideStage.setBounds(getSideStageBounds(), wct); mTaskOrganizer.applyTransaction(wct); } } Loading services/core/java/com/android/server/wm/ActivityStarter.java +2 −2 Original line number Diff line number Diff line Loading @@ -2761,8 +2761,8 @@ class ActivityStarter { final boolean onTop = (aOptions == null || !aOptions.getAvoidMoveToFront()) && !mLaunchTaskBehind; return mRootWindowContainer.getLaunchRootTask(r, aOptions, task, onTop, mLaunchParams, mRequest.realCallingPid, mRequest.realCallingUid); return mRootWindowContainer.getLaunchRootTask(r, aOptions, task, mSourceRootTask, onTop, mLaunchParams, launchFlags, mRequest.realCallingPid, mRequest.realCallingUid); } private boolean isLaunchModeOneOf(int mode1, int mode2) { Loading services/core/java/com/android/server/wm/RootWindowContainer.java +14 −10 Original line number Diff line number Diff line Loading @@ -2810,10 +2810,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return false; } Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop) { return getLaunchRootTask(r, options, candidateTask, onTop, null /* launchParams */, -1 /* no realCallingPid */, -1 /* no realCallingUid */); Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop) { return getLaunchRootTask(r, options, candidateTask, null /* sourceTask */, onTop, null /* launchParams */, 0 /* launchFlags */, -1 /* no realCallingPid */, -1 /* no realCallingUid */); } /** Loading @@ -2822,15 +2823,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent> * @param r The activity we are trying to launch. Can be null. * @param options The activity options used to the launch. Can be null. * @param candidateTask The possible task the activity might be launched in. Can be null. * @param sourceTask The task requesting to start activity. Can be null. * @param launchParams The resolved launch params to use. * @param launchFlags The launch flags for this launch. * @param realCallingPid The pid from {@link ActivityStarter#setRealCallingPid} * @param realCallingUid The uid from {@link ActivityStarter#setRealCallingUid} * @return The root task to use for the launch or INVALID_TASK_ID. */ Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop, @Nullable LaunchParamsController.LaunchParams launchParams, int realCallingPid, int realCallingUid) { @Nullable ActivityOptions options, @Nullable Task candidateTask, @Nullable Task sourceTask, boolean onTop, @Nullable LaunchParamsController.LaunchParams launchParams, int launchFlags, int realCallingPid, int realCallingUid) { int taskId = INVALID_TASK_ID; int displayId = INVALID_DISPLAY; TaskDisplayArea taskDisplayArea = null; Loading Loading @@ -2894,7 +2898,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // Falling back to default task container taskDisplayArea = taskDisplayArea.mDisplayContent.getDefaultTaskDisplayArea(); rootTask = taskDisplayArea.getOrCreateRootTask(r, options, candidateTask, launchParams, activityType, onTop); sourceTask, launchParams, launchFlags, activityType, onTop); if (rootTask != null) { return rootTask; } Loading Loading @@ -2949,8 +2953,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } return container.getOrCreateRootTask( r, options, candidateTask, launchParams, activityType, onTop); return container.getOrCreateRootTask(r, options, candidateTask, sourceTask, launchParams, launchFlags, activityType, onTop); } /** @return true if activity record is null or can be launched on provided display. */ Loading services/core/java/com/android/server/wm/Task.java +27 −1 Original line number Diff line number Diff line Loading @@ -7952,6 +7952,17 @@ class Task extends WindowContainer<WindowContainer> { private boolean mHasBeenVisible; private boolean mRemoveWithTaskOrganizer; /** * Records the source task that requesting to build a new task, used to determine which of * the adjacent roots should be launch root of the new task. */ private Task mSourceTask; /** * Records launch flags to apply when launching new task. */ private int mLaunchFlags; Builder(ActivityTaskManagerService atm) { mAtmService = atm; } Loading @@ -7961,6 +7972,16 @@ class Task extends WindowContainer<WindowContainer> { return this; } Builder setSourceTask(Task sourceTask) { mSourceTask = sourceTask; return this; } Builder setLaunchFlags(int launchFlags) { mLaunchFlags = launchFlags; return this; } Builder setTaskId(int taskId) { mTaskId = taskId; return this; Loading Loading @@ -8215,9 +8236,14 @@ class Task extends WindowContainer<WindowContainer> { tda.getRootPinnedTask().dismissPip(); } if (mIntent != null) { mLaunchFlags |= mIntent.getFlags(); } // Task created by organizer are added as root. final Task launchRootTask = mCreatedByOrganizer ? null : tda.getLaunchRootTask(mWindowingMode, mActivityType, mActivityOptions); ? null : tda.getLaunchRootTask(mWindowingMode, mActivityType, mActivityOptions, mSourceTask, mLaunchFlags); if (launchRootTask != null) { // Since this task will be put into a root task, its windowingMode will be // inherited. Loading Loading
core/java/android/window/WindowContainerTransaction.java +39 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,33 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Sets the container as launch adjacent flag root. Task starting with * {@link FLAG_ACTIVITY_LAUNCH_ADJACENT} will be launching to. * * @hide */ @NonNull public WindowContainerTransaction setLaunchAdjacentFlagRoot( @NonNull WindowContainerToken container) { mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), false /* clearRoot */)); return this; } /** * Clears launch adjacent flag root for the display area of passing container. * * @hide */ @NonNull public WindowContainerTransaction clearLaunchAdjacentFlagRoot( @NonNull WindowContainerToken container) { mHierarchyOps.add(HierarchyOp.createForSetLaunchAdjacentFlagRoot(container.asBinder(), true /* clearRoot */)); return this; } /** * Starts a task by id. The task is expected to already exist (eg. as a recent task). * @param taskId Id of task to start. Loading Loading @@ -677,6 +704,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT = 3; public static final int HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS = 4; public static final int HIERARCHY_OP_TYPE_LAUNCH_TASK = 5; public static final int HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT = 6; // The following key(s) are for use with mLaunchOptions: // When launching a task (eg. from recents), this is the taskId to be launched. Loading Loading @@ -734,6 +762,14 @@ public final class WindowContainerTransaction implements Parcelable { fullOptions); } /** Create a hierarchy op for setting launch adjacent flag root. */ public static HierarchyOp createForSetLaunchAdjacentFlagRoot(IBinder container, boolean clearRoot) { return new HierarchyOp(HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT, container, null, null, null, clearRoot, null); } private HierarchyOp(int type, @Nullable IBinder container, @Nullable IBinder reparent, int[] windowingModes, int[] activityTypes, boolean toTop, @Nullable Bundle launchOptions) { Loading Loading @@ -829,6 +865,9 @@ public final class WindowContainerTransaction implements Parcelable { + " adjacentRoot=" + mReparent + "}"; case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "{LaunchTask: " + mLaunchOptions + "}"; case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "{SetAdjacentFlagRoot: container=" + mContainer + " clearRoot=" + mToTop + "}"; default: return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent + " mToTop=" + mToTop + " mWindowingMode=" + mWindowingModes Loading
libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +3 −0 Original line number Diff line number Diff line Loading @@ -337,6 +337,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Make the stages adjacent to each other so they occlude what's behind them. wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token); wct.setLaunchAdjacentFlagRoot(mSideStage.mRootTaskInfo.token); mTaskOrganizer.applyTransaction(wct); } } Loading @@ -346,6 +347,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Deactivate the main stage if it no longer has a root task. mMainStage.deactivate(wct); wct.clearLaunchAdjacentFlagRoot(mSideStage.mRootTaskInfo.token); mTaskOrganizer.applyTransaction(wct); } } Loading Loading @@ -449,6 +451,7 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener, final WindowContainerTransaction wct = new WindowContainerTransaction(); // Make sure the main stage is active. mMainStage.activate(getMainStageBounds(), wct); mSideStage.setBounds(getSideStageBounds(), wct); mTaskOrganizer.applyTransaction(wct); } } Loading
services/core/java/com/android/server/wm/ActivityStarter.java +2 −2 Original line number Diff line number Diff line Loading @@ -2761,8 +2761,8 @@ class ActivityStarter { final boolean onTop = (aOptions == null || !aOptions.getAvoidMoveToFront()) && !mLaunchTaskBehind; return mRootWindowContainer.getLaunchRootTask(r, aOptions, task, onTop, mLaunchParams, mRequest.realCallingPid, mRequest.realCallingUid); return mRootWindowContainer.getLaunchRootTask(r, aOptions, task, mSourceRootTask, onTop, mLaunchParams, launchFlags, mRequest.realCallingPid, mRequest.realCallingUid); } private boolean isLaunchModeOneOf(int mode1, int mode2) { Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +14 −10 Original line number Diff line number Diff line Loading @@ -2810,10 +2810,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return false; } Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop) { return getLaunchRootTask(r, options, candidateTask, onTop, null /* launchParams */, -1 /* no realCallingPid */, -1 /* no realCallingUid */); Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop) { return getLaunchRootTask(r, options, candidateTask, null /* sourceTask */, onTop, null /* launchParams */, 0 /* launchFlags */, -1 /* no realCallingPid */, -1 /* no realCallingUid */); } /** Loading @@ -2822,15 +2823,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent> * @param r The activity we are trying to launch. Can be null. * @param options The activity options used to the launch. Can be null. * @param candidateTask The possible task the activity might be launched in. Can be null. * @param sourceTask The task requesting to start activity. Can be null. * @param launchParams The resolved launch params to use. * @param launchFlags The launch flags for this launch. * @param realCallingPid The pid from {@link ActivityStarter#setRealCallingPid} * @param realCallingUid The uid from {@link ActivityStarter#setRealCallingUid} * @return The root task to use for the launch or INVALID_TASK_ID. */ Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options, @Nullable Task candidateTask, boolean onTop, @Nullable LaunchParamsController.LaunchParams launchParams, int realCallingPid, int realCallingUid) { @Nullable ActivityOptions options, @Nullable Task candidateTask, @Nullable Task sourceTask, boolean onTop, @Nullable LaunchParamsController.LaunchParams launchParams, int launchFlags, int realCallingPid, int realCallingUid) { int taskId = INVALID_TASK_ID; int displayId = INVALID_DISPLAY; TaskDisplayArea taskDisplayArea = null; Loading Loading @@ -2894,7 +2898,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // Falling back to default task container taskDisplayArea = taskDisplayArea.mDisplayContent.getDefaultTaskDisplayArea(); rootTask = taskDisplayArea.getOrCreateRootTask(r, options, candidateTask, launchParams, activityType, onTop); sourceTask, launchParams, launchFlags, activityType, onTop); if (rootTask != null) { return rootTask; } Loading Loading @@ -2949,8 +2953,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } return container.getOrCreateRootTask( r, options, candidateTask, launchParams, activityType, onTop); return container.getOrCreateRootTask(r, options, candidateTask, sourceTask, launchParams, launchFlags, activityType, onTop); } /** @return true if activity record is null or can be launched on provided display. */ Loading
services/core/java/com/android/server/wm/Task.java +27 −1 Original line number Diff line number Diff line Loading @@ -7952,6 +7952,17 @@ class Task extends WindowContainer<WindowContainer> { private boolean mHasBeenVisible; private boolean mRemoveWithTaskOrganizer; /** * Records the source task that requesting to build a new task, used to determine which of * the adjacent roots should be launch root of the new task. */ private Task mSourceTask; /** * Records launch flags to apply when launching new task. */ private int mLaunchFlags; Builder(ActivityTaskManagerService atm) { mAtmService = atm; } Loading @@ -7961,6 +7972,16 @@ class Task extends WindowContainer<WindowContainer> { return this; } Builder setSourceTask(Task sourceTask) { mSourceTask = sourceTask; return this; } Builder setLaunchFlags(int launchFlags) { mLaunchFlags = launchFlags; return this; } Builder setTaskId(int taskId) { mTaskId = taskId; return this; Loading Loading @@ -8215,9 +8236,14 @@ class Task extends WindowContainer<WindowContainer> { tda.getRootPinnedTask().dismissPip(); } if (mIntent != null) { mLaunchFlags |= mIntent.getFlags(); } // Task created by organizer are added as root. final Task launchRootTask = mCreatedByOrganizer ? null : tda.getLaunchRootTask(mWindowingMode, mActivityType, mActivityOptions); ? null : tda.getLaunchRootTask(mWindowingMode, mActivityType, mActivityOptions, mSourceTask, mLaunchFlags); if (launchRootTask != null) { // Since this task will be put into a root task, its windowingMode will be // inherited. Loading