Loading core/java/android/window/WindowContainerTransaction.java +41 −0 Original line number Diff line number Diff line Loading @@ -826,6 +826,26 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Sets/removes the reparent leaf task flag for this {@code windowContainer}. * When this is set, the server side will try to reparent the leaf task to task display area * if there is an existing activity in history during the activity launch. This operation only * support on the organized root task. * @hide */ @NonNull public WindowContainerTransaction setReparentLeafTaskIfRelaunch( @NonNull WindowContainerToken windowContainer, boolean reparentLeafTaskIfRelaunch) { final HierarchyOp hierarchyOp = new HierarchyOp.Builder( HierarchyOp.HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH) .setContainer(windowContainer.asBinder()) .setReparentLeafTaskIfRelaunch(reparentLeafTaskIfRelaunch) .build(); mHierarchyOps.add(hierarchyOp); return this; } /** * Merges another WCT into this one. * @param transfer When true, this will transfer everything from other potentially leaving Loading Loading @@ -1241,6 +1261,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int HIERARCHY_OP_TYPE_REMOVE_TASK = 20; public static final int HIERARCHY_OP_TYPE_FINISH_ACTIVITY = 21; public static final int HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT = 22; public static final int HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH = 23; // 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 @@ -1293,6 +1314,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mAlwaysOnTop; private boolean mReparentLeafTaskIfRelaunch; public static HierarchyOp createForReparent( @NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) { return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT) Loading Loading @@ -1398,6 +1421,7 @@ public final class WindowContainerTransaction implements Parcelable { mPendingIntent = copy.mPendingIntent; mShortcutInfo = copy.mShortcutInfo; mAlwaysOnTop = copy.mAlwaysOnTop; mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch; } protected HierarchyOp(Parcel in) { Loading @@ -1420,6 +1444,7 @@ public final class WindowContainerTransaction implements Parcelable { mPendingIntent = in.readTypedObject(PendingIntent.CREATOR); mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR); mAlwaysOnTop = in.readBoolean(); mReparentLeafTaskIfRelaunch = in.readBoolean(); } public int getType() { Loading Loading @@ -1494,6 +1519,10 @@ public final class WindowContainerTransaction implements Parcelable { return mAlwaysOnTop; } public boolean isReparentLeafTaskIfRelaunch() { return mReparentLeafTaskIfRelaunch; } @Nullable public TaskFragmentCreationParams getTaskFragmentCreationOptions() { return mTaskFragmentCreationOptions; Loading Loading @@ -1572,6 +1601,9 @@ public final class WindowContainerTransaction implements Parcelable { case HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT: return "{setCompanionTaskFragment: container = " + mContainer + " companion = " + mReparent + "}"; case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH: return "{setReparentLeafTaskIfRelaunch: container= " + mContainer + " reparentLeafTaskIfRelaunch= " + mReparentLeafTaskIfRelaunch + "}"; default: return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent + " mToTop=" + mToTop Loading Loading @@ -1602,6 +1634,7 @@ public final class WindowContainerTransaction implements Parcelable { dest.writeTypedObject(mPendingIntent, flags); dest.writeTypedObject(mShortcutInfo, flags); dest.writeBoolean(mAlwaysOnTop); dest.writeBoolean(mReparentLeafTaskIfRelaunch); } @Override Loading Loading @@ -1662,6 +1695,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mAlwaysOnTop; private boolean mReparentLeafTaskIfRelaunch; Builder(int type) { mType = type; } Loading Loading @@ -1732,6 +1767,11 @@ public final class WindowContainerTransaction implements Parcelable { return this; } Builder setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) { mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch; return this; } Builder setShortcutInfo(@Nullable ShortcutInfo shortcutInfo) { mShortcutInfo = shortcutInfo; return this; Loading @@ -1757,6 +1797,7 @@ public final class WindowContainerTransaction implements Parcelable { hierarchyOp.mAlwaysOnTop = mAlwaysOnTop; hierarchyOp.mTaskFragmentCreationOptions = mTaskFragmentCreationOptions; hierarchyOp.mShortcutInfo = mShortcutInfo; hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch; return hierarchyOp; } Loading services/core/java/com/android/server/wm/Task.java +12 −0 Original line number Diff line number Diff line Loading @@ -499,6 +499,12 @@ class Task extends TaskFragment { */ boolean mInRemoveTask; /** * When set, disassociate the leaf task if relaunched and reparented it to TDA as root task if * possible. */ boolean mReparentLeafTaskIfRelaunch; private final AnimatingActivityRegistry mAnimatingActivityRegistry = new AnimatingActivityRegistry(); Loading Loading @@ -6142,6 +6148,12 @@ class Task extends TaskFragment { } } void setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) { if (isOrganized()) { mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch; } } @Override public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { Loading services/core/java/com/android/server/wm/TaskDisplayArea.java +7 −6 Original line number Diff line number Diff line Loading @@ -899,15 +899,16 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } else if (candidateTask != null) { final int position = onTop ? POSITION_TOP : POSITION_BOTTOM; final Task launchRootTask = getLaunchRootTask(resolvedWindowingMode, activityType, final Task launchParentTask = getLaunchRootTask(resolvedWindowingMode, activityType, options, sourceTask, launchFlags, candidateTask); if (launchRootTask != null) { if (launchParentTask != null) { if (candidateTask.getParent() == null) { launchRootTask.addChild(candidateTask, position); } else if (candidateTask.getParent() != launchRootTask) { candidateTask.reparent(launchRootTask, position); launchParentTask.addChild(candidateTask, position); } else if (candidateTask.getParent() != launchParentTask) { candidateTask.reparent(launchParentTask, position); } } else if (candidateTask.getDisplayArea() != this) { } else if (candidateTask.getDisplayArea() != this || candidateTask.getRootTask().mReparentLeafTaskIfRelaunch) { if (candidateTask.getParent() == null) { addChild(candidateTask, position); } else { Loading services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +4 −2 Original line number Diff line number Diff line Loading @@ -164,9 +164,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } // If the launch windowing mode is still undefined, inherit from the target task if the // task is already on the right display area (otherwise, the task may be on a different // display area that has incompatible windowing mode). // display area that has incompatible windowing mode or the task organizer request to // disassociate the leaf task if relaunched and reparented it to TDA as root task). if (launchMode == WINDOWING_MODE_UNDEFINED && task != null && task.getTaskDisplayArea() == suggestedDisplayArea) { && task != null && task.getTaskDisplayArea() == suggestedDisplayArea && !task.getRootTask().mReparentLeafTaskIfRelaunch) { launchMode = task.getWindowingMode(); if (DEBUG) { appendLog("inherit-from-task=" Loading services/core/java/com/android/server/wm/WindowOrganizerController.java +22 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_SHORTCUT; Loading Loading @@ -1236,7 +1237,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub WindowContainer.fromBinder(hop.getContainer()) .removeLocalInsetsSourceProvider(hop.getInsetsTypes()); break; case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: { final WindowContainer container = WindowContainer.fromBinder(hop.getContainer()); if (container == null || container.asDisplayArea() == null || !container.isAttached()) { Loading @@ -1247,7 +1248,26 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub container.setAlwaysOnTop(hop.isAlwaysOnTop()); effects |= TRANSACT_EFFECTS_LIFECYCLE; break; } case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH: { final WindowContainer container = WindowContainer.fromBinder(hop.getContainer()); final Task task = container != null ? container.asTask() : null; if (task == null || !task.isAttached()) { Slog.e(TAG, "Attempt to operate on unknown or detached container: " + container); break; } if (!task.mCreatedByOrganizer) { throw new UnsupportedOperationException( "Cannot set reparent leaf task flag on non-organized task : " + task); } if (!task.isRootTask()) { throw new UnsupportedOperationException( "Cannot set reparent leaf task flag on non-root task : " + task); } task.setReparentLeafTaskIfRelaunch(hop.isReparentLeafTaskIfRelaunch()); break; } } return effects; } Loading Loading
core/java/android/window/WindowContainerTransaction.java +41 −0 Original line number Diff line number Diff line Loading @@ -826,6 +826,26 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Sets/removes the reparent leaf task flag for this {@code windowContainer}. * When this is set, the server side will try to reparent the leaf task to task display area * if there is an existing activity in history during the activity launch. This operation only * support on the organized root task. * @hide */ @NonNull public WindowContainerTransaction setReparentLeafTaskIfRelaunch( @NonNull WindowContainerToken windowContainer, boolean reparentLeafTaskIfRelaunch) { final HierarchyOp hierarchyOp = new HierarchyOp.Builder( HierarchyOp.HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH) .setContainer(windowContainer.asBinder()) .setReparentLeafTaskIfRelaunch(reparentLeafTaskIfRelaunch) .build(); mHierarchyOps.add(hierarchyOp); return this; } /** * Merges another WCT into this one. * @param transfer When true, this will transfer everything from other potentially leaving Loading Loading @@ -1241,6 +1261,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int HIERARCHY_OP_TYPE_REMOVE_TASK = 20; public static final int HIERARCHY_OP_TYPE_FINISH_ACTIVITY = 21; public static final int HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT = 22; public static final int HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH = 23; // 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 @@ -1293,6 +1314,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mAlwaysOnTop; private boolean mReparentLeafTaskIfRelaunch; public static HierarchyOp createForReparent( @NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) { return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT) Loading Loading @@ -1398,6 +1421,7 @@ public final class WindowContainerTransaction implements Parcelable { mPendingIntent = copy.mPendingIntent; mShortcutInfo = copy.mShortcutInfo; mAlwaysOnTop = copy.mAlwaysOnTop; mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch; } protected HierarchyOp(Parcel in) { Loading @@ -1420,6 +1444,7 @@ public final class WindowContainerTransaction implements Parcelable { mPendingIntent = in.readTypedObject(PendingIntent.CREATOR); mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR); mAlwaysOnTop = in.readBoolean(); mReparentLeafTaskIfRelaunch = in.readBoolean(); } public int getType() { Loading Loading @@ -1494,6 +1519,10 @@ public final class WindowContainerTransaction implements Parcelable { return mAlwaysOnTop; } public boolean isReparentLeafTaskIfRelaunch() { return mReparentLeafTaskIfRelaunch; } @Nullable public TaskFragmentCreationParams getTaskFragmentCreationOptions() { return mTaskFragmentCreationOptions; Loading Loading @@ -1572,6 +1601,9 @@ public final class WindowContainerTransaction implements Parcelable { case HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT: return "{setCompanionTaskFragment: container = " + mContainer + " companion = " + mReparent + "}"; case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH: return "{setReparentLeafTaskIfRelaunch: container= " + mContainer + " reparentLeafTaskIfRelaunch= " + mReparentLeafTaskIfRelaunch + "}"; default: return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent + " mToTop=" + mToTop Loading Loading @@ -1602,6 +1634,7 @@ public final class WindowContainerTransaction implements Parcelable { dest.writeTypedObject(mPendingIntent, flags); dest.writeTypedObject(mShortcutInfo, flags); dest.writeBoolean(mAlwaysOnTop); dest.writeBoolean(mReparentLeafTaskIfRelaunch); } @Override Loading Loading @@ -1662,6 +1695,8 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mAlwaysOnTop; private boolean mReparentLeafTaskIfRelaunch; Builder(int type) { mType = type; } Loading Loading @@ -1732,6 +1767,11 @@ public final class WindowContainerTransaction implements Parcelable { return this; } Builder setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) { mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch; return this; } Builder setShortcutInfo(@Nullable ShortcutInfo shortcutInfo) { mShortcutInfo = shortcutInfo; return this; Loading @@ -1757,6 +1797,7 @@ public final class WindowContainerTransaction implements Parcelable { hierarchyOp.mAlwaysOnTop = mAlwaysOnTop; hierarchyOp.mTaskFragmentCreationOptions = mTaskFragmentCreationOptions; hierarchyOp.mShortcutInfo = mShortcutInfo; hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch; return hierarchyOp; } Loading
services/core/java/com/android/server/wm/Task.java +12 −0 Original line number Diff line number Diff line Loading @@ -499,6 +499,12 @@ class Task extends TaskFragment { */ boolean mInRemoveTask; /** * When set, disassociate the leaf task if relaunched and reparented it to TDA as root task if * possible. */ boolean mReparentLeafTaskIfRelaunch; private final AnimatingActivityRegistry mAnimatingActivityRegistry = new AnimatingActivityRegistry(); Loading Loading @@ -6142,6 +6148,12 @@ class Task extends TaskFragment { } } void setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) { if (isOrganized()) { mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch; } } @Override public void dumpDebug(ProtoOutputStream proto, long fieldId, @WindowTraceLogLevel int logLevel) { Loading
services/core/java/com/android/server/wm/TaskDisplayArea.java +7 −6 Original line number Diff line number Diff line Loading @@ -899,15 +899,16 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } else if (candidateTask != null) { final int position = onTop ? POSITION_TOP : POSITION_BOTTOM; final Task launchRootTask = getLaunchRootTask(resolvedWindowingMode, activityType, final Task launchParentTask = getLaunchRootTask(resolvedWindowingMode, activityType, options, sourceTask, launchFlags, candidateTask); if (launchRootTask != null) { if (launchParentTask != null) { if (candidateTask.getParent() == null) { launchRootTask.addChild(candidateTask, position); } else if (candidateTask.getParent() != launchRootTask) { candidateTask.reparent(launchRootTask, position); launchParentTask.addChild(candidateTask, position); } else if (candidateTask.getParent() != launchParentTask) { candidateTask.reparent(launchParentTask, position); } } else if (candidateTask.getDisplayArea() != this) { } else if (candidateTask.getDisplayArea() != this || candidateTask.getRootTask().mReparentLeafTaskIfRelaunch) { if (candidateTask.getParent() == null) { addChild(candidateTask, position); } else { Loading
services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +4 −2 Original line number Diff line number Diff line Loading @@ -164,9 +164,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } // If the launch windowing mode is still undefined, inherit from the target task if the // task is already on the right display area (otherwise, the task may be on a different // display area that has incompatible windowing mode). // display area that has incompatible windowing mode or the task organizer request to // disassociate the leaf task if relaunched and reparented it to TDA as root task). if (launchMode == WINDOWING_MODE_UNDEFINED && task != null && task.getTaskDisplayArea() == suggestedDisplayArea) { && task != null && task.getTaskDisplayArea() == suggestedDisplayArea && !task.getRootTask().mReparentLeafTaskIfRelaunch) { launchMode = task.getWindowingMode(); if (DEBUG) { appendLog("inherit-from-task=" Loading
services/core/java/com/android/server/wm/WindowOrganizerController.java +22 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT; import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_SHORTCUT; Loading Loading @@ -1236,7 +1237,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub WindowContainer.fromBinder(hop.getContainer()) .removeLocalInsetsSourceProvider(hop.getInsetsTypes()); break; case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: { final WindowContainer container = WindowContainer.fromBinder(hop.getContainer()); if (container == null || container.asDisplayArea() == null || !container.isAttached()) { Loading @@ -1247,7 +1248,26 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub container.setAlwaysOnTop(hop.isAlwaysOnTop()); effects |= TRANSACT_EFFECTS_LIFECYCLE; break; } case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH: { final WindowContainer container = WindowContainer.fromBinder(hop.getContainer()); final Task task = container != null ? container.asTask() : null; if (task == null || !task.isAttached()) { Slog.e(TAG, "Attempt to operate on unknown or detached container: " + container); break; } if (!task.mCreatedByOrganizer) { throw new UnsupportedOperationException( "Cannot set reparent leaf task flag on non-organized task : " + task); } if (!task.isRootTask()) { throw new UnsupportedOperationException( "Cannot set reparent leaf task flag on non-root task : " + task); } task.setReparentLeafTaskIfRelaunch(hop.isReparentLeafTaskIfRelaunch()); break; } } return effects; } Loading