summaryrefslogtreecommitdiff
path: root/core/java/android/window/TaskFragmentOrganizer.java
diff options
context:
space:
mode:
authorChris Li <lihongyu@google.com>2022-04-18 17:28:35 +0800
committerChris Li <lihongyu@google.com>2022-04-22 17:36:02 +0800
commit9e08260cce7ea6ab24407718cf8e92893bbcd724 (patch)
treeb022938da1cba6a3d055f8b703160e6087616c8d /core/java/android/window/TaskFragmentOrganizer.java
parent701b3f759c8efc7515b2b24386a44f81f1dfee97 (diff)
Add TaskFragmentOrganizer#onActivityReparentToTask
When the activity exits PiP and is reparented to the original Task, the organizer should handle it as a new launch. Bug: 225371112 Test: atest WmTests:TaskFragmentTest Test: atest WmTests:TaskFragmentOrganizerControllerTest Change-Id: Ia7e32e995a35e167b0d76e701c972b269ae068cc
Diffstat (limited to 'core/java/android/window/TaskFragmentOrganizer.java')
-rw-r--r--core/java/android/window/TaskFragmentOrganizer.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/window/TaskFragmentOrganizer.java b/core/java/android/window/TaskFragmentOrganizer.java
index 1d1deacf0eb3..2ef49c3e2aac 100644
--- a/core/java/android/window/TaskFragmentOrganizer.java
+++ b/core/java/android/window/TaskFragmentOrganizer.java
@@ -19,6 +19,7 @@ package android.window;
import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.annotation.TestApi;
+import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
@@ -154,6 +155,24 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
public void onTaskFragmentError(
@NonNull IBinder errorCallbackToken, @NonNull Throwable exception) {}
+ /**
+ * Called when an Activity is reparented to the Task with organized TaskFragment. For example,
+ * when an Activity enters and then exits Picture-in-picture, it will be reparented back to its
+ * orginial Task. In this case, we need to notify the organizer so that it can check if the
+ * Activity matches any split rule.
+ *
+ * @param taskId The Task that the activity is reparented to.
+ * @param activityIntent The intent that the activity is original launched with.
+ * @param activityToken If the activity belongs to the same process as the organizer, this
+ * will be the actual activity token; if the activity belongs to a
+ * different process, the server will generate a temporary token that
+ * the organizer can use to reparent the activity through
+ * {@link WindowContainerTransaction} if needed.
+ * @hide
+ */
+ public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
+ @NonNull IBinder activityToken) {}
+
@Override
public void applyTransaction(@NonNull WindowContainerTransaction t) {
t.setTaskFragmentOrganizer(mInterface);
@@ -203,6 +222,14 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
errorCallbackToken,
(Throwable) exceptionBundle.getSerializable(KEY_ERROR_CALLBACK_EXCEPTION)));
}
+
+ @Override
+ public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
+ @NonNull IBinder activityToken) {
+ mExecutor.execute(
+ () -> TaskFragmentOrganizer.this.onActivityReparentToTask(
+ taskId, activityIntent, activityToken));
+ }
};
private final TaskFragmentOrganizerToken mToken = new TaskFragmentOrganizerToken(mInterface);