[RESTRICT AUTOMERGE] WCT#setReparentLeafTaskIfRelaunch
This CL allows disassociating the leaf task if relaunched and reparented it to TDA as root task for split-screen. Bug: 236317871 Test: atest WindowOrganizerTests Change-Id: I6704fab733ed7d239d7004c93d3d2f471ac94822 Merged-In: I6704fab733ed7d239d7004c93d3d2f471ac94822
This commit is contained in:
@@ -826,6 +826,26 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
return this;
|
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.
|
* Merges another WCT into this one.
|
||||||
* @param transfer When true, this will transfer everything from other potentially leaving
|
* @param transfer When true, this will transfer everything from other potentially leaving
|
||||||
@@ -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_REMOVE_TASK = 20;
|
||||||
public static final int HIERARCHY_OP_TYPE_FINISH_ACTIVITY = 21;
|
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_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:
|
// The following key(s) are for use with mLaunchOptions:
|
||||||
// When launching a task (eg. from recents), this is the taskId to be launched.
|
// When launching a task (eg. from recents), this is the taskId to be launched.
|
||||||
@@ -1293,6 +1314,8 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
|
|
||||||
private boolean mAlwaysOnTop;
|
private boolean mAlwaysOnTop;
|
||||||
|
|
||||||
|
private boolean mReparentLeafTaskIfRelaunch;
|
||||||
|
|
||||||
public static HierarchyOp createForReparent(
|
public static HierarchyOp createForReparent(
|
||||||
@NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) {
|
@NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) {
|
||||||
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT)
|
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT)
|
||||||
@@ -1398,6 +1421,7 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
mPendingIntent = copy.mPendingIntent;
|
mPendingIntent = copy.mPendingIntent;
|
||||||
mShortcutInfo = copy.mShortcutInfo;
|
mShortcutInfo = copy.mShortcutInfo;
|
||||||
mAlwaysOnTop = copy.mAlwaysOnTop;
|
mAlwaysOnTop = copy.mAlwaysOnTop;
|
||||||
|
mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HierarchyOp(Parcel in) {
|
protected HierarchyOp(Parcel in) {
|
||||||
@@ -1420,6 +1444,7 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
|
mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
|
||||||
mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR);
|
mShortcutInfo = in.readTypedObject(ShortcutInfo.CREATOR);
|
||||||
mAlwaysOnTop = in.readBoolean();
|
mAlwaysOnTop = in.readBoolean();
|
||||||
|
mReparentLeafTaskIfRelaunch = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
@@ -1494,6 +1519,10 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
return mAlwaysOnTop;
|
return mAlwaysOnTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isReparentLeafTaskIfRelaunch() {
|
||||||
|
return mReparentLeafTaskIfRelaunch;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TaskFragmentCreationParams getTaskFragmentCreationOptions() {
|
public TaskFragmentCreationParams getTaskFragmentCreationOptions() {
|
||||||
return mTaskFragmentCreationOptions;
|
return mTaskFragmentCreationOptions;
|
||||||
@@ -1572,6 +1601,9 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
case HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT:
|
case HIERARCHY_OP_TYPE_SET_COMPANION_TASK_FRAGMENT:
|
||||||
return "{setCompanionTaskFragment: container = " + mContainer + " companion = "
|
return "{setCompanionTaskFragment: container = " + mContainer + " companion = "
|
||||||
+ mReparent + "}";
|
+ mReparent + "}";
|
||||||
|
case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH:
|
||||||
|
return "{setReparentLeafTaskIfRelaunch: container= " + mContainer
|
||||||
|
+ " reparentLeafTaskIfRelaunch= " + mReparentLeafTaskIfRelaunch + "}";
|
||||||
default:
|
default:
|
||||||
return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent
|
return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent
|
||||||
+ " mToTop=" + mToTop
|
+ " mToTop=" + mToTop
|
||||||
@@ -1602,6 +1634,7 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
dest.writeTypedObject(mPendingIntent, flags);
|
dest.writeTypedObject(mPendingIntent, flags);
|
||||||
dest.writeTypedObject(mShortcutInfo, flags);
|
dest.writeTypedObject(mShortcutInfo, flags);
|
||||||
dest.writeBoolean(mAlwaysOnTop);
|
dest.writeBoolean(mAlwaysOnTop);
|
||||||
|
dest.writeBoolean(mReparentLeafTaskIfRelaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1662,6 +1695,8 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
|
|
||||||
private boolean mAlwaysOnTop;
|
private boolean mAlwaysOnTop;
|
||||||
|
|
||||||
|
private boolean mReparentLeafTaskIfRelaunch;
|
||||||
|
|
||||||
Builder(int type) {
|
Builder(int type) {
|
||||||
mType = type;
|
mType = type;
|
||||||
}
|
}
|
||||||
@@ -1732,6 +1767,11 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Builder setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) {
|
||||||
|
mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
Builder setShortcutInfo(@Nullable ShortcutInfo shortcutInfo) {
|
Builder setShortcutInfo(@Nullable ShortcutInfo shortcutInfo) {
|
||||||
mShortcutInfo = shortcutInfo;
|
mShortcutInfo = shortcutInfo;
|
||||||
return this;
|
return this;
|
||||||
@@ -1757,6 +1797,7 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
hierarchyOp.mAlwaysOnTop = mAlwaysOnTop;
|
hierarchyOp.mAlwaysOnTop = mAlwaysOnTop;
|
||||||
hierarchyOp.mTaskFragmentCreationOptions = mTaskFragmentCreationOptions;
|
hierarchyOp.mTaskFragmentCreationOptions = mTaskFragmentCreationOptions;
|
||||||
hierarchyOp.mShortcutInfo = mShortcutInfo;
|
hierarchyOp.mShortcutInfo = mShortcutInfo;
|
||||||
|
hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch;
|
||||||
|
|
||||||
return hierarchyOp;
|
return hierarchyOp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -499,6 +499,12 @@ class Task extends TaskFragment {
|
|||||||
*/
|
*/
|
||||||
boolean mInRemoveTask;
|
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 =
|
private final AnimatingActivityRegistry mAnimatingActivityRegistry =
|
||||||
new AnimatingActivityRegistry();
|
new AnimatingActivityRegistry();
|
||||||
|
|
||||||
@@ -6142,6 +6148,12 @@ class Task extends TaskFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setReparentLeafTaskIfRelaunch(boolean reparentLeafTaskIfRelaunch) {
|
||||||
|
if (isOrganized()) {
|
||||||
|
mReparentLeafTaskIfRelaunch = reparentLeafTaskIfRelaunch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dumpDebug(ProtoOutputStream proto, long fieldId,
|
public void dumpDebug(ProtoOutputStream proto, long fieldId,
|
||||||
@WindowTraceLogLevel int logLevel) {
|
@WindowTraceLogLevel int logLevel) {
|
||||||
|
|||||||
@@ -899,15 +899,16 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
|||||||
}
|
}
|
||||||
} else if (candidateTask != null) {
|
} else if (candidateTask != null) {
|
||||||
final int position = onTop ? POSITION_TOP : POSITION_BOTTOM;
|
final int position = onTop ? POSITION_TOP : POSITION_BOTTOM;
|
||||||
final Task launchRootTask = getLaunchRootTask(resolvedWindowingMode, activityType,
|
final Task launchParentTask = getLaunchRootTask(resolvedWindowingMode, activityType,
|
||||||
options, sourceTask, launchFlags, candidateTask);
|
options, sourceTask, launchFlags, candidateTask);
|
||||||
if (launchRootTask != null) {
|
if (launchParentTask != null) {
|
||||||
if (candidateTask.getParent() == null) {
|
if (candidateTask.getParent() == null) {
|
||||||
launchRootTask.addChild(candidateTask, position);
|
launchParentTask.addChild(candidateTask, position);
|
||||||
} else if (candidateTask.getParent() != launchRootTask) {
|
} else if (candidateTask.getParent() != launchParentTask) {
|
||||||
candidateTask.reparent(launchRootTask, position);
|
candidateTask.reparent(launchParentTask, position);
|
||||||
}
|
}
|
||||||
} else if (candidateTask.getDisplayArea() != this) {
|
} else if (candidateTask.getDisplayArea() != this
|
||||||
|
|| candidateTask.getRootTask().mReparentLeafTaskIfRelaunch) {
|
||||||
if (candidateTask.getParent() == null) {
|
if (candidateTask.getParent() == null) {
|
||||||
addChild(candidateTask, position);
|
addChild(candidateTask, position);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -164,9 +164,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
|||||||
}
|
}
|
||||||
// If the launch windowing mode is still undefined, inherit from the target task if the
|
// 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
|
// 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
|
if (launchMode == WINDOWING_MODE_UNDEFINED
|
||||||
&& task != null && task.getTaskDisplayArea() == suggestedDisplayArea) {
|
&& task != null && task.getTaskDisplayArea() == suggestedDisplayArea
|
||||||
|
&& !task.getRootTask().mReparentLeafTaskIfRelaunch) {
|
||||||
launchMode = task.getWindowingMode();
|
launchMode = task.getWindowingMode();
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
appendLog("inherit-from-task="
|
appendLog("inherit-from-task="
|
||||||
|
|||||||
@@ -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_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_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_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_ACTIVITY_IN_TASK_FRAGMENT;
|
||||||
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_SHORTCUT;
|
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_START_SHORTCUT;
|
||||||
|
|
||||||
@@ -1236,7 +1237,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
WindowContainer.fromBinder(hop.getContainer())
|
WindowContainer.fromBinder(hop.getContainer())
|
||||||
.removeLocalInsetsSourceProvider(hop.getInsetsTypes());
|
.removeLocalInsetsSourceProvider(hop.getInsetsTypes());
|
||||||
break;
|
break;
|
||||||
case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP:
|
case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: {
|
||||||
final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
|
final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
|
||||||
if (container == null || container.asDisplayArea() == null
|
if (container == null || container.asDisplayArea() == null
|
||||||
|| !container.isAttached()) {
|
|| !container.isAttached()) {
|
||||||
@@ -1247,7 +1248,26 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
container.setAlwaysOnTop(hop.isAlwaysOnTop());
|
container.setAlwaysOnTop(hop.isAlwaysOnTop());
|
||||||
effects |= TRANSACT_EFFECTS_LIFECYCLE;
|
effects |= TRANSACT_EFFECTS_LIFECYCLE;
|
||||||
break;
|
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;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user