summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorChris Li <lihongyu@google.com>2022-09-20 17:39:41 +0800
committerChris Li <lihongyu@google.com>2022-09-23 21:23:03 +0800
commit840218d5df60855261b9c214f0edce5cfe19d2b4 (patch)
tree52bdd5fecba3ec23b8e5cc1ee02fcc6d929ca701 /core/java
parenta4ae390f137b11c5013a450a239b3ba95fbc9f8e (diff)
Allow ActivityEmbedding to finish Activity through WCT
Before, we call Activity#finish() to finish activities when removing TaskFragment. This may start a CLOSE transition before the organizer has a chance to request the actual transition type. Now, we allow the organizer to finish activities through WCT so that the operation is atomic and the organizer can request the correct transition type. Bug: 240519866 Test: atest WmTests:TaskFragmentOrganizerControllerTest Test: atest CtsWindowManagerDeviceTestCases:TaskFragmentOrganizerTest Change-Id: I54671fb2dd34dca952468305429a90d89953de69
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/window/WindowContainerTransaction.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index ffbdf08e99dc..cfad1afe1b5b 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -706,6 +706,23 @@ public final class WindowContainerTransaction implements Parcelable {
}
/**
+ * Finishes the Activity.
+ * Comparing to directly calling {@link android.app.Activity#finish()}, calling this can make
+ * sure the finishing happens in the same transaction with other operations.
+ * @param activityToken activity to be finished.
+ */
+ @NonNull
+ public WindowContainerTransaction finishActivity(@NonNull IBinder activityToken) {
+ final HierarchyOp hierarchyOp =
+ new HierarchyOp.Builder(
+ HierarchyOp.HIERARCHY_OP_TYPE_FINISH_ACTIVITY)
+ .setContainer(activityToken)
+ .build();
+ mHierarchyOps.add(hierarchyOp);
+ return this;
+ }
+
+ /**
* Sets/removes the always on top flag for this {@code windowContainer}. See
* {@link com.android.server.wm.ConfigurationContainer#setAlwaysOnTop(boolean)}.
* Please note that this method is only intended to be used for a
@@ -1163,6 +1180,7 @@ public final class WindowContainerTransaction implements Parcelable {
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;
+ public static final int HIERARCHY_OP_TYPE_FINISH_ACTIVITY = 21;
// The following key(s) are for use with mLaunchOptions:
// When launching a task (eg. from recents), this is the taskId to be launched.
@@ -1484,6 +1502,8 @@ public final class WindowContainerTransaction implements Parcelable {
+ " alwaysOnTop=" + mAlwaysOnTop + "}";
case HIERARCHY_OP_TYPE_REMOVE_TASK:
return "{RemoveTask: task=" + mContainer + "}";
+ case HIERARCHY_OP_TYPE_FINISH_ACTIVITY:
+ return "{finishActivity: activity=" + mContainer + "}";
default:
return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent
+ " mToTop=" + mToTop