summaryrefslogtreecommitdiff
path: root/core/java/android/window/TaskFragmentOrganizer.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/window/TaskFragmentOrganizer.java')
-rw-r--r--core/java/android/window/TaskFragmentOrganizer.java161
1 files changed, 21 insertions, 140 deletions
diff --git a/core/java/android/window/TaskFragmentOrganizer.java b/core/java/android/window/TaskFragmentOrganizer.java
index 649785a80f43..648541bf62c7 100644
--- a/core/java/android/window/TaskFragmentOrganizer.java
+++ b/core/java/android/window/TaskFragmentOrganizer.java
@@ -35,7 +35,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.WindowConfiguration;
-import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
@@ -203,7 +202,7 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* Routes to {@link ITaskFragmentOrganizerController#applyTransaction} instead of
* {@link IWindowOrganizerController#applyTransaction} for the different transition options.
*
- * @see #applyTransaction(WindowContainerTransaction, int, boolean, boolean)
+ * @see #applyTransaction(WindowContainerTransaction, int, boolean)
*/
@Override
public void applyTransaction(@NonNull WindowContainerTransaction wct) {
@@ -285,72 +284,30 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* Called when a TaskFragment is created and organized by this organizer.
*
* @param taskFragmentInfo Info of the TaskFragment that is created.
- * @deprecated Use {@link #onTaskFragmentAppeared(WindowContainerTransaction, TaskFragmentInfo)}
- * instead.
+ * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
*/
@Deprecated
public void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo) {}
/**
- * Called when a TaskFragment is created and organized by this organizer.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @param taskFragmentInfo Info of the TaskFragment that is created.
- */
- public void onTaskFragmentAppeared(@NonNull WindowContainerTransaction wct,
- @NonNull TaskFragmentInfo taskFragmentInfo) {
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release.
- onTaskFragmentAppeared(taskFragmentInfo);
- }
-
- /**
* Called when the status of an organized TaskFragment is changed.
*
* @param taskFragmentInfo Info of the TaskFragment that is changed.
- * @deprecated Use {@link #onTaskFragmentInfoChanged(WindowContainerTransaction,
- * TaskFragmentInfo)} instead.
+ * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
*/
@Deprecated
public void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo) {}
/**
- * Called when the status of an organized TaskFragment is changed.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @param taskFragmentInfo Info of the TaskFragment that is changed.
- */
- public void onTaskFragmentInfoChanged(@NonNull WindowContainerTransaction wct,
- @NonNull TaskFragmentInfo taskFragmentInfo) {
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release.
- onTaskFragmentInfoChanged(taskFragmentInfo);
- }
-
- /**
* Called when an organized TaskFragment is removed.
*
* @param taskFragmentInfo Info of the TaskFragment that is removed.
- * @deprecated Use {@link #onTaskFragmentVanished(WindowContainerTransaction,
- * TaskFragmentInfo)} instead.
+ * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
*/
@Deprecated
public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) {}
/**
- * Called when an organized TaskFragment is removed.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @param taskFragmentInfo Info of the TaskFragment that is removed.
- */
- public void onTaskFragmentVanished(@NonNull WindowContainerTransaction wct,
- @NonNull TaskFragmentInfo taskFragmentInfo) {
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release.
- onTaskFragmentVanished(taskFragmentInfo);
- }
-
- /**
* Called when the parent leaf Task of organized TaskFragments is changed.
* When the leaf Task is changed, the organizer may want to update the TaskFragments in one
* transaction.
@@ -361,94 +318,26 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
*
* @param fragmentToken The parent Task this TaskFragment is changed.
* @param parentConfig Config of the parent Task.
- * @deprecated Use {@link #onTaskFragmentParentInfoChanged(WindowContainerTransaction, int,
- * Configuration)} instead.
+ * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
*/
@Deprecated
public void onTaskFragmentParentInfoChanged(
@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) {}
/**
- * Called when the parent leaf Task of organized TaskFragments is changed.
- * When the leaf Task is changed, the organizer may want to update the TaskFragments in one
- * transaction.
- *
- * For case like screen size change, it will trigger onTaskFragmentParentInfoChanged with new
- * Task bounds, but may not trigger onTaskFragmentInfoChanged because there can be an override
- * bounds.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @param taskId Id of the parent Task that is changed.
- * @param parentConfig Config of the parent Task.
- */
- public void onTaskFragmentParentInfoChanged(@NonNull WindowContainerTransaction wct, int taskId,
- @NonNull Configuration parentConfig) {
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release.
- final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId);
- if (tokens == null || tokens.isEmpty()) {
- return;
- }
- for (int i = tokens.size() - 1; i >= 0; i--) {
- onTaskFragmentParentInfoChanged(tokens.get(i), parentConfig);
- }
- }
-
- /**
* Called when the {@link WindowContainerTransaction} created with
* {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side.
*
* @param errorCallbackToken token set in
* {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)}
* @param exception exception from the server side.
- * @deprecated Use {@link #onTaskFragmentError(WindowContainerTransaction, IBinder,
- * TaskFragmentInfo, int, Throwable)} instead.
+ * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
*/
@Deprecated
public void onTaskFragmentError(
@NonNull IBinder errorCallbackToken, @NonNull Throwable exception) {}
/**
- * Called when the {@link WindowContainerTransaction} created with
- * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @param errorCallbackToken token set in
- * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)}
- * @param taskFragmentInfo The {@link TaskFragmentInfo}. This could be {@code null} if no
- * TaskFragment created.
- * @param opType The {@link WindowContainerTransaction.HierarchyOp} of the failed
- * transaction operation.
- * @param exception exception from the server side.
- */
- public void onTaskFragmentError(@NonNull WindowContainerTransaction wct,
- @NonNull IBinder errorCallbackToken, @Nullable TaskFragmentInfo taskFragmentInfo,
- int opType, @NonNull Throwable exception) {
- // Doing so to keep compatibility. This will be removed in the next release.
- onTaskFragmentError(errorCallbackToken, 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
- * original Task. In this case, we need to notify the organizer so that it can check if the
- * Activity matches any split rule.
- *
- * @param wct The {@link WindowContainerTransaction} to make any changes with if needed. No
- * need to call {@link #applyTransaction} as it will be applied by the caller.
- * @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.
- */
- public void onActivityReparentedToTask(@NonNull WindowContainerTransaction wct,
- int taskId, @NonNull Intent activityIntent, @NonNull IBinder activityToken) {}
-
- /**
* Called when the transaction is ready so that the organizer can update the TaskFragments based
* on the changes in transaction.
* @hide
@@ -463,23 +352,18 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
final int taskId = change.getTaskId();
switch (change.getType()) {
case TYPE_TASK_FRAGMENT_APPEARED:
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next
- // release.
if (!mTaskIdToFragmentTokens.contains(taskId)) {
mTaskIdToFragmentTokens.put(taskId, new ArrayList<>());
}
mTaskIdToFragmentTokens.get(taskId).add(change.getTaskFragmentToken());
onTaskFragmentParentInfoChanged(change.getTaskFragmentToken(),
mTaskIdToConfigurations.get(taskId));
-
- onTaskFragmentAppeared(wct, change.getTaskFragmentInfo());
+ onTaskFragmentAppeared(change.getTaskFragmentInfo());
break;
case TYPE_TASK_FRAGMENT_INFO_CHANGED:
- onTaskFragmentInfoChanged(wct, change.getTaskFragmentInfo());
+ onTaskFragmentInfoChanged(change.getTaskFragmentInfo());
break;
case TYPE_TASK_FRAGMENT_VANISHED:
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next
- // release.
if (mTaskIdToFragmentTokens.contains(taskId)) {
final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId);
tokens.remove(change.getTaskFragmentToken());
@@ -488,33 +372,30 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
mTaskIdToConfigurations.remove(taskId);
}
}
-
- onTaskFragmentVanished(wct, change.getTaskFragmentInfo());
+ onTaskFragmentVanished(change.getTaskFragmentInfo());
break;
case TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED:
- // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next
- // release.
- mTaskIdToConfigurations.put(taskId, change.getTaskConfiguration());
-
- onTaskFragmentParentInfoChanged(wct, taskId, change.getTaskConfiguration());
+ final Configuration parentConfig = change.getTaskConfiguration();
+ mTaskIdToConfigurations.put(taskId, parentConfig);
+ final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId);
+ if (tokens == null || tokens.isEmpty()) {
+ break;
+ }
+ for (int i = tokens.size() - 1; i >= 0; i--) {
+ onTaskFragmentParentInfoChanged(tokens.get(i), parentConfig);
+ }
break;
case TYPE_TASK_FRAGMENT_ERROR:
final Bundle errorBundle = change.getErrorBundle();
onTaskFragmentError(
- wct,
change.getErrorCallbackToken(),
- errorBundle.getParcelable(
- KEY_ERROR_CALLBACK_TASK_FRAGMENT_INFO, TaskFragmentInfo.class),
- errorBundle.getInt(KEY_ERROR_CALLBACK_OP_TYPE),
errorBundle.getSerializable(KEY_ERROR_CALLBACK_THROWABLE,
java.lang.Throwable.class));
break;
case TYPE_ACTIVITY_REPARENTED_TO_TASK:
- onActivityReparentedToTask(
- wct,
- change.getTaskId(),
- change.getActivityIntent(),
- change.getActivityToken());
+ // This is for CTS compat:
+ // There is no TestApi for CTS to handle this type of change, but we don't want
+ // it to throw exception as default. This has been updated in next release.
break;
default:
throw new IllegalArgumentException(