Loading core/api/test-current.txt +0 −6 Original line number Diff line number Diff line Loading @@ -3360,17 +3360,11 @@ package android.window { ctor public TaskFragmentOrganizer(@NonNull java.util.concurrent.Executor); method @NonNull public java.util.concurrent.Executor getExecutor(); method @NonNull public android.window.TaskFragmentOrganizerToken getOrganizerToken(); method public void onActivityReparentedToTask(@NonNull android.window.WindowContainerTransaction, int, @NonNull android.content.Intent, @NonNull android.os.IBinder); method @Deprecated public void onTaskFragmentAppeared(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentAppeared(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @Deprecated public void onTaskFragmentError(@NonNull android.os.IBinder, @NonNull Throwable); method public void onTaskFragmentError(@NonNull android.window.WindowContainerTransaction, @NonNull android.os.IBinder, @Nullable android.window.TaskFragmentInfo, int, @NonNull Throwable); method @Deprecated public void onTaskFragmentInfoChanged(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentInfoChanged(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @Deprecated public void onTaskFragmentParentInfoChanged(@NonNull android.os.IBinder, @NonNull android.content.res.Configuration); method public void onTaskFragmentParentInfoChanged(@NonNull android.window.WindowContainerTransaction, int, @NonNull android.content.res.Configuration); method @Deprecated public void onTaskFragmentVanished(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentVanished(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @CallSuper public void registerOrganizer(); method @CallSuper public void unregisterOrganizer(); } Loading core/java/android/window/TaskFragmentOrganizer.java +21 −140 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -285,71 +284,29 @@ 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 Loading @@ -361,39 +318,12 @@ 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. Loading @@ -401,53 +331,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer { * @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. Loading @@ -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()); Loading @@ -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( Loading core/java/android/window/TaskFragmentTransaction.java +15 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.Configuration; import android.os.Binder; Loading Loading @@ -63,6 +64,7 @@ public final class TaskFragmentTransaction implements Parcelable { dest.writeTypedList(mChanges); } @NonNull public IBinder getTransactionToken() { return mTransactionToken; } Loading Loading @@ -105,6 +107,7 @@ public final class TaskFragmentTransaction implements Parcelable { return 0; } @NonNull public static final Creator<TaskFragmentTransaction> CREATOR = new Creator<>() { @Override public TaskFragmentTransaction createFromParcel(Parcel in) { Loading Loading @@ -218,24 +221,28 @@ public final class TaskFragmentTransaction implements Parcelable { } /** The change is related to the TaskFragment created with this unique token. */ @NonNull public Change setTaskFragmentToken(@NonNull IBinder taskFragmentToken) { mTaskFragmentToken = requireNonNull(taskFragmentToken); return this; } /** Info of the embedded TaskFragment. */ @NonNull public Change setTaskFragmentInfo(@NonNull TaskFragmentInfo info) { mTaskFragmentInfo = requireNonNull(info); return this; } /** Task id the parent Task. */ @NonNull public Change setTaskId(int taskId) { mTaskId = taskId; return this; } /** Configuration of the parent Task. */ @NonNull public Change setTaskConfiguration(@NonNull Configuration configuration) { mTaskConfiguration = requireNonNull(configuration); return this; Loading @@ -246,6 +253,7 @@ public final class TaskFragmentTransaction implements Parcelable { * from the {@link TaskFragmentOrganizer}, it may come with an error callback token to * report back. */ @NonNull public Change setErrorCallbackToken(@Nullable IBinder errorCallbackToken) { mErrorCallbackToken = errorCallbackToken; return this; Loading @@ -255,6 +263,7 @@ public final class TaskFragmentTransaction implements Parcelable { * Bundle with necessary info about the failure operation of * {@link #TYPE_TASK_FRAGMENT_ERROR}. */ @NonNull public Change setErrorBundle(@NonNull Bundle errorBundle) { mErrorBundle = requireNonNull(errorBundle); return this; Loading @@ -264,6 +273,7 @@ public final class TaskFragmentTransaction implements Parcelable { * Intent of the activity that is reparented to the Task for * {@link #TYPE_ACTIVITY_REPARENTED_TO_TASK}. */ @NonNull public Change setActivityIntent(@NonNull Intent intent) { mActivityIntent = requireNonNull(intent); return this; Loading @@ -276,6 +286,7 @@ public final class TaskFragmentTransaction implements Parcelable { * a temporary token that the organizer can use to reparent the activity through * {@link WindowContainerTransaction} if needed. */ @NonNull public Change setActivityToken(@NonNull IBinder activityToken) { mActivityToken = requireNonNull(activityToken); return this; Loading Loading @@ -310,11 +321,12 @@ public final class TaskFragmentTransaction implements Parcelable { return mErrorCallbackToken; } @Nullable @NonNull public Bundle getErrorBundle() { return mErrorBundle; return mErrorBundle != null ? mErrorBundle : Bundle.EMPTY; } @SuppressLint("IntentBuilderName") // This is not creating new Intent. @Nullable public Intent getActivityIntent() { return mActivityIntent; Loading @@ -335,6 +347,7 @@ public final class TaskFragmentTransaction implements Parcelable { return 0; } @NonNull public static final Creator<Change> CREATOR = new Creator<>() { @Override public Change createFromParcel(Parcel in) { Loading Loading
core/api/test-current.txt +0 −6 Original line number Diff line number Diff line Loading @@ -3360,17 +3360,11 @@ package android.window { ctor public TaskFragmentOrganizer(@NonNull java.util.concurrent.Executor); method @NonNull public java.util.concurrent.Executor getExecutor(); method @NonNull public android.window.TaskFragmentOrganizerToken getOrganizerToken(); method public void onActivityReparentedToTask(@NonNull android.window.WindowContainerTransaction, int, @NonNull android.content.Intent, @NonNull android.os.IBinder); method @Deprecated public void onTaskFragmentAppeared(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentAppeared(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @Deprecated public void onTaskFragmentError(@NonNull android.os.IBinder, @NonNull Throwable); method public void onTaskFragmentError(@NonNull android.window.WindowContainerTransaction, @NonNull android.os.IBinder, @Nullable android.window.TaskFragmentInfo, int, @NonNull Throwable); method @Deprecated public void onTaskFragmentInfoChanged(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentInfoChanged(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @Deprecated public void onTaskFragmentParentInfoChanged(@NonNull android.os.IBinder, @NonNull android.content.res.Configuration); method public void onTaskFragmentParentInfoChanged(@NonNull android.window.WindowContainerTransaction, int, @NonNull android.content.res.Configuration); method @Deprecated public void onTaskFragmentVanished(@NonNull android.window.TaskFragmentInfo); method public void onTaskFragmentVanished(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.TaskFragmentInfo); method @CallSuper public void registerOrganizer(); method @CallSuper public void unregisterOrganizer(); } Loading
core/java/android/window/TaskFragmentOrganizer.java +21 −140 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -285,71 +284,29 @@ 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 Loading @@ -361,39 +318,12 @@ 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. Loading @@ -401,53 +331,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer { * @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. Loading @@ -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()); Loading @@ -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( Loading
core/java/android/window/TaskFragmentTransaction.java +15 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.Configuration; import android.os.Binder; Loading Loading @@ -63,6 +64,7 @@ public final class TaskFragmentTransaction implements Parcelable { dest.writeTypedList(mChanges); } @NonNull public IBinder getTransactionToken() { return mTransactionToken; } Loading Loading @@ -105,6 +107,7 @@ public final class TaskFragmentTransaction implements Parcelable { return 0; } @NonNull public static final Creator<TaskFragmentTransaction> CREATOR = new Creator<>() { @Override public TaskFragmentTransaction createFromParcel(Parcel in) { Loading Loading @@ -218,24 +221,28 @@ public final class TaskFragmentTransaction implements Parcelable { } /** The change is related to the TaskFragment created with this unique token. */ @NonNull public Change setTaskFragmentToken(@NonNull IBinder taskFragmentToken) { mTaskFragmentToken = requireNonNull(taskFragmentToken); return this; } /** Info of the embedded TaskFragment. */ @NonNull public Change setTaskFragmentInfo(@NonNull TaskFragmentInfo info) { mTaskFragmentInfo = requireNonNull(info); return this; } /** Task id the parent Task. */ @NonNull public Change setTaskId(int taskId) { mTaskId = taskId; return this; } /** Configuration of the parent Task. */ @NonNull public Change setTaskConfiguration(@NonNull Configuration configuration) { mTaskConfiguration = requireNonNull(configuration); return this; Loading @@ -246,6 +253,7 @@ public final class TaskFragmentTransaction implements Parcelable { * from the {@link TaskFragmentOrganizer}, it may come with an error callback token to * report back. */ @NonNull public Change setErrorCallbackToken(@Nullable IBinder errorCallbackToken) { mErrorCallbackToken = errorCallbackToken; return this; Loading @@ -255,6 +263,7 @@ public final class TaskFragmentTransaction implements Parcelable { * Bundle with necessary info about the failure operation of * {@link #TYPE_TASK_FRAGMENT_ERROR}. */ @NonNull public Change setErrorBundle(@NonNull Bundle errorBundle) { mErrorBundle = requireNonNull(errorBundle); return this; Loading @@ -264,6 +273,7 @@ public final class TaskFragmentTransaction implements Parcelable { * Intent of the activity that is reparented to the Task for * {@link #TYPE_ACTIVITY_REPARENTED_TO_TASK}. */ @NonNull public Change setActivityIntent(@NonNull Intent intent) { mActivityIntent = requireNonNull(intent); return this; Loading @@ -276,6 +286,7 @@ public final class TaskFragmentTransaction implements Parcelable { * a temporary token that the organizer can use to reparent the activity through * {@link WindowContainerTransaction} if needed. */ @NonNull public Change setActivityToken(@NonNull IBinder activityToken) { mActivityToken = requireNonNull(activityToken); return this; Loading Loading @@ -310,11 +321,12 @@ public final class TaskFragmentTransaction implements Parcelable { return mErrorCallbackToken; } @Nullable @NonNull public Bundle getErrorBundle() { return mErrorBundle; return mErrorBundle != null ? mErrorBundle : Bundle.EMPTY; } @SuppressLint("IntentBuilderName") // This is not creating new Intent. @Nullable public Intent getActivityIntent() { return mActivityIntent; Loading @@ -335,6 +347,7 @@ public final class TaskFragmentTransaction implements Parcelable { return 0; } @NonNull public static final Creator<Change> CREATOR = new Creator<>() { @Override public Change createFromParcel(Parcel in) { Loading