summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMaryam <mdehaini@google.com>2022-08-16 14:17:54 -0700
committerMaryam Dehaini <mdehaini@google.com>2022-08-30 22:17:21 +0000
commit193d515420d7660ae056ed3310be059a33ae97c8 (patch)
treef943f3868456f25a67c08487bfc40914a5c55c8d /core/java/android
parent9d16d9dacbd2e048a24b1077d1ac202689b00cb2 (diff)
Move Task Close to WindowContainerTransaction
Added removeTask HierarchyOp so that CaptionWIndowDecorModel now uses WindowContainerTransaction to remove task rather than IActivityTaskManager#removeTask(int) Bug: 242094334 Test: Manual testing using acloud and unit testing (atest WmTests:WindowContainerTransactionTests) Change-Id: I9e2f1946a517bdba6a75b7049f00943d729045f0
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/window/WindowContainerTransaction.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index 567b1642b620..0eb037c6f094 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -456,6 +456,17 @@ public final class WindowContainerTransaction implements Parcelable {
}
/**
+ * Finds and removes a task and its children using its container token. The task is removed
+ * from recents.
+ * @param containerToken ContainerToken of Task to be removed
+ */
+ @NonNull
+ public WindowContainerTransaction removeTask(@NonNull WindowContainerToken containerToken) {
+ mHierarchyOps.add(HierarchyOp.createForRemoveTask(containerToken.asBinder()));
+ return this;
+ }
+
+ /**
* Sends a pending intent in sync.
* @param sender The PendingIntent sender.
* @param intent The fillIn intent to patch over the sender's base intent.
@@ -1154,6 +1165,7 @@ public final class WindowContainerTransaction implements Parcelable {
public static final int HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER = 17;
public static final int HIERARCHY_OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT = 18;
public static final int HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP = 19;
+ public static final int HIERARCHY_OP_TYPE_REMOVE_TASK = 20;
// The following key(s) are for use with mLaunchOptions:
// When launching a task (eg. from recents), this is the taskId to be launched.
@@ -1283,6 +1295,13 @@ public final class WindowContainerTransaction implements Parcelable {
.build();
}
+ /** create a hierarchy op for deleting a task **/
+ public static HierarchyOp createForRemoveTask(@NonNull IBinder container) {
+ return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REMOVE_TASK)
+ .setContainer(container)
+ .build();
+ }
+
/** Only creates through {@link Builder}. */
private HierarchyOp(int type) {
mType = type;
@@ -1466,6 +1485,8 @@ public final class WindowContainerTransaction implements Parcelable {
case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP:
return "{setAlwaysOnTop: container=" + mContainer
+ " alwaysOnTop=" + mAlwaysOnTop + "}";
+ case HIERARCHY_OP_TYPE_REMOVE_TASK:
+ return "{RemoveTask: task=" + mContainer + "}";
default:
return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent
+ " mToTop=" + mToTop