Merge "Cleanup unused TestApi in TaskFragmentOrganizer" into tm-qpr-dev am: 5ef4e81b20

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19693522

Change-Id: I1af9afb62ad4d9aa78f1c70d2d31955d26de1f9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chris Li
2022-09-13 05:10:20 +00:00
committed by Automerger Merge Worker
3 changed files with 36 additions and 148 deletions

View File

@@ -3350,17 +3350,11 @@ package android.window {
ctor public TaskFragmentOrganizer(@NonNull java.util.concurrent.Executor); ctor public TaskFragmentOrganizer(@NonNull java.util.concurrent.Executor);
method @NonNull public java.util.concurrent.Executor getExecutor(); method @NonNull public java.util.concurrent.Executor getExecutor();
method @NonNull public android.window.TaskFragmentOrganizerToken getOrganizerToken(); 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 @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 @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 @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 @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 @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 registerOrganizer();
method @CallSuper public void unregisterOrganizer(); method @CallSuper public void unregisterOrganizer();
} }

View File

@@ -35,7 +35,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.TestApi; import android.annotation.TestApi;
import android.app.WindowConfiguration; import android.app.WindowConfiguration;
import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
@@ -203,7 +202,7 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* Routes to {@link ITaskFragmentOrganizerController#applyTransaction} instead of * Routes to {@link ITaskFragmentOrganizerController#applyTransaction} instead of
* {@link IWindowOrganizerController#applyTransaction} for the different transition options. * {@link IWindowOrganizerController#applyTransaction} for the different transition options.
* *
* @see #applyTransaction(WindowContainerTransaction, int, boolean, boolean) * @see #applyTransaction(WindowContainerTransaction, int, boolean)
*/ */
@Override @Override
public void applyTransaction(@NonNull WindowContainerTransaction wct) { public void applyTransaction(@NonNull WindowContainerTransaction wct) {
@@ -285,71 +284,29 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* Called when a TaskFragment is created and organized by this organizer. * Called when a TaskFragment is created and organized by this organizer.
* *
* @param taskFragmentInfo Info of the TaskFragment that is created. * @param taskFragmentInfo Info of the TaskFragment that is created.
* @deprecated Use {@link #onTaskFragmentAppeared(WindowContainerTransaction, TaskFragmentInfo)} * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
* instead.
*/ */
@Deprecated @Deprecated
public void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo) {} 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. * Called when the status of an organized TaskFragment is changed.
* *
* @param taskFragmentInfo Info of the TaskFragment that is changed. * @param taskFragmentInfo Info of the TaskFragment that is changed.
* @deprecated Use {@link #onTaskFragmentInfoChanged(WindowContainerTransaction, * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
* TaskFragmentInfo)} instead.
*/ */
@Deprecated @Deprecated
public void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo) {} 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. * Called when an organized TaskFragment is removed.
* *
* @param taskFragmentInfo Info of the TaskFragment that is removed. * @param taskFragmentInfo Info of the TaskFragment that is removed.
* @deprecated Use {@link #onTaskFragmentVanished(WindowContainerTransaction, * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
* TaskFragmentInfo)} instead.
*/ */
@Deprecated @Deprecated
public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) {} 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. * 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 * When the leaf Task is changed, the organizer may want to update the TaskFragments in one
@@ -361,39 +318,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* *
* @param fragmentToken The parent Task this TaskFragment is changed. * @param fragmentToken The parent Task this TaskFragment is changed.
* @param parentConfig Config of the parent Task. * @param parentConfig Config of the parent Task.
* @deprecated Use {@link #onTaskFragmentParentInfoChanged(WindowContainerTransaction, int, * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
* Configuration)} instead.
*/ */
@Deprecated @Deprecated
public void onTaskFragmentParentInfoChanged( public void onTaskFragmentParentInfoChanged(
@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) {} @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 * Called when the {@link WindowContainerTransaction} created with
* {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side. * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side.
@@ -401,53 +331,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
* @param errorCallbackToken token set in * @param errorCallbackToken token set in
* {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)}
* @param exception exception from the server side. * @param exception exception from the server side.
* @deprecated Use {@link #onTaskFragmentError(WindowContainerTransaction, IBinder, * @deprecated Use {@link #onTransactionReady(TaskFragmentTransaction)} instead.
* TaskFragmentInfo, int, Throwable)} instead.
*/ */
@Deprecated @Deprecated
public void onTaskFragmentError( public void onTaskFragmentError(
@NonNull IBinder errorCallbackToken, @NonNull Throwable exception) {} @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 * Called when the transaction is ready so that the organizer can update the TaskFragments based
* on the changes in transaction. * on the changes in transaction.
@@ -463,23 +352,18 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
final int taskId = change.getTaskId(); final int taskId = change.getTaskId();
switch (change.getType()) { switch (change.getType()) {
case TYPE_TASK_FRAGMENT_APPEARED: case TYPE_TASK_FRAGMENT_APPEARED:
// TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next
// release.
if (!mTaskIdToFragmentTokens.contains(taskId)) { if (!mTaskIdToFragmentTokens.contains(taskId)) {
mTaskIdToFragmentTokens.put(taskId, new ArrayList<>()); mTaskIdToFragmentTokens.put(taskId, new ArrayList<>());
} }
mTaskIdToFragmentTokens.get(taskId).add(change.getTaskFragmentToken()); mTaskIdToFragmentTokens.get(taskId).add(change.getTaskFragmentToken());
onTaskFragmentParentInfoChanged(change.getTaskFragmentToken(), onTaskFragmentParentInfoChanged(change.getTaskFragmentToken(),
mTaskIdToConfigurations.get(taskId)); mTaskIdToConfigurations.get(taskId));
onTaskFragmentAppeared(change.getTaskFragmentInfo());
onTaskFragmentAppeared(wct, change.getTaskFragmentInfo());
break; break;
case TYPE_TASK_FRAGMENT_INFO_CHANGED: case TYPE_TASK_FRAGMENT_INFO_CHANGED:
onTaskFragmentInfoChanged(wct, change.getTaskFragmentInfo()); onTaskFragmentInfoChanged(change.getTaskFragmentInfo());
break; break;
case TYPE_TASK_FRAGMENT_VANISHED: case TYPE_TASK_FRAGMENT_VANISHED:
// TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next
// release.
if (mTaskIdToFragmentTokens.contains(taskId)) { if (mTaskIdToFragmentTokens.contains(taskId)) {
final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId); final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId);
tokens.remove(change.getTaskFragmentToken()); tokens.remove(change.getTaskFragmentToken());
@@ -488,33 +372,30 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
mTaskIdToConfigurations.remove(taskId); mTaskIdToConfigurations.remove(taskId);
} }
} }
onTaskFragmentVanished(change.getTaskFragmentInfo());
onTaskFragmentVanished(wct, change.getTaskFragmentInfo());
break; break;
case TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED: case TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED:
// TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next final Configuration parentConfig = change.getTaskConfiguration();
// release. mTaskIdToConfigurations.put(taskId, parentConfig);
mTaskIdToConfigurations.put(taskId, change.getTaskConfiguration()); final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId);
if (tokens == null || tokens.isEmpty()) {
onTaskFragmentParentInfoChanged(wct, taskId, change.getTaskConfiguration()); break;
}
for (int i = tokens.size() - 1; i >= 0; i--) {
onTaskFragmentParentInfoChanged(tokens.get(i), parentConfig);
}
break; break;
case TYPE_TASK_FRAGMENT_ERROR: case TYPE_TASK_FRAGMENT_ERROR:
final Bundle errorBundle = change.getErrorBundle(); final Bundle errorBundle = change.getErrorBundle();
onTaskFragmentError( onTaskFragmentError(
wct,
change.getErrorCallbackToken(), 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, errorBundle.getSerializable(KEY_ERROR_CALLBACK_THROWABLE,
java.lang.Throwable.class)); java.lang.Throwable.class));
break; break;
case TYPE_ACTIVITY_REPARENTED_TO_TASK: case TYPE_ACTIVITY_REPARENTED_TO_TASK:
onActivityReparentedToTask( // This is for CTS compat:
wct, // There is no TestApi for CTS to handle this type of change, but we don't want
change.getTaskId(), // it to throw exception as default. This has been updated in next release.
change.getActivityIntent(),
change.getActivityToken());
break; break;
default: default:
throw new IllegalArgumentException( throw new IllegalArgumentException(

View File

@@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Binder; import android.os.Binder;
@@ -63,6 +64,7 @@ public final class TaskFragmentTransaction implements Parcelable {
dest.writeTypedList(mChanges); dest.writeTypedList(mChanges);
} }
@NonNull
public IBinder getTransactionToken() { public IBinder getTransactionToken() {
return mTransactionToken; return mTransactionToken;
} }
@@ -105,6 +107,7 @@ public final class TaskFragmentTransaction implements Parcelable {
return 0; return 0;
} }
@NonNull
public static final Creator<TaskFragmentTransaction> CREATOR = new Creator<>() { public static final Creator<TaskFragmentTransaction> CREATOR = new Creator<>() {
@Override @Override
public TaskFragmentTransaction createFromParcel(Parcel in) { public TaskFragmentTransaction createFromParcel(Parcel in) {
@@ -218,24 +221,28 @@ public final class TaskFragmentTransaction implements Parcelable {
} }
/** The change is related to the TaskFragment created with this unique token. */ /** The change is related to the TaskFragment created with this unique token. */
@NonNull
public Change setTaskFragmentToken(@NonNull IBinder taskFragmentToken) { public Change setTaskFragmentToken(@NonNull IBinder taskFragmentToken) {
mTaskFragmentToken = requireNonNull(taskFragmentToken); mTaskFragmentToken = requireNonNull(taskFragmentToken);
return this; return this;
} }
/** Info of the embedded TaskFragment. */ /** Info of the embedded TaskFragment. */
@NonNull
public Change setTaskFragmentInfo(@NonNull TaskFragmentInfo info) { public Change setTaskFragmentInfo(@NonNull TaskFragmentInfo info) {
mTaskFragmentInfo = requireNonNull(info); mTaskFragmentInfo = requireNonNull(info);
return this; return this;
} }
/** Task id the parent Task. */ /** Task id the parent Task. */
@NonNull
public Change setTaskId(int taskId) { public Change setTaskId(int taskId) {
mTaskId = taskId; mTaskId = taskId;
return this; return this;
} }
/** Configuration of the parent Task. */ /** Configuration of the parent Task. */
@NonNull
public Change setTaskConfiguration(@NonNull Configuration configuration) { public Change setTaskConfiguration(@NonNull Configuration configuration) {
mTaskConfiguration = requireNonNull(configuration); mTaskConfiguration = requireNonNull(configuration);
return this; return this;
@@ -246,6 +253,7 @@ public final class TaskFragmentTransaction implements Parcelable {
* from the {@link TaskFragmentOrganizer}, it may come with an error callback token to * from the {@link TaskFragmentOrganizer}, it may come with an error callback token to
* report back. * report back.
*/ */
@NonNull
public Change setErrorCallbackToken(@Nullable IBinder errorCallbackToken) { public Change setErrorCallbackToken(@Nullable IBinder errorCallbackToken) {
mErrorCallbackToken = errorCallbackToken; mErrorCallbackToken = errorCallbackToken;
return this; return this;
@@ -255,6 +263,7 @@ public final class TaskFragmentTransaction implements Parcelable {
* Bundle with necessary info about the failure operation of * Bundle with necessary info about the failure operation of
* {@link #TYPE_TASK_FRAGMENT_ERROR}. * {@link #TYPE_TASK_FRAGMENT_ERROR}.
*/ */
@NonNull
public Change setErrorBundle(@NonNull Bundle errorBundle) { public Change setErrorBundle(@NonNull Bundle errorBundle) {
mErrorBundle = requireNonNull(errorBundle); mErrorBundle = requireNonNull(errorBundle);
return this; return this;
@@ -264,6 +273,7 @@ public final class TaskFragmentTransaction implements Parcelable {
* Intent of the activity that is reparented to the Task for * Intent of the activity that is reparented to the Task for
* {@link #TYPE_ACTIVITY_REPARENTED_TO_TASK}. * {@link #TYPE_ACTIVITY_REPARENTED_TO_TASK}.
*/ */
@NonNull
public Change setActivityIntent(@NonNull Intent intent) { public Change setActivityIntent(@NonNull Intent intent) {
mActivityIntent = requireNonNull(intent); mActivityIntent = requireNonNull(intent);
return this; return this;
@@ -276,6 +286,7 @@ public final class TaskFragmentTransaction implements Parcelable {
* a temporary token that the organizer can use to reparent the activity through * a temporary token that the organizer can use to reparent the activity through
* {@link WindowContainerTransaction} if needed. * {@link WindowContainerTransaction} if needed.
*/ */
@NonNull
public Change setActivityToken(@NonNull IBinder activityToken) { public Change setActivityToken(@NonNull IBinder activityToken) {
mActivityToken = requireNonNull(activityToken); mActivityToken = requireNonNull(activityToken);
return this; return this;
@@ -310,11 +321,12 @@ public final class TaskFragmentTransaction implements Parcelable {
return mErrorCallbackToken; return mErrorCallbackToken;
} }
@Nullable @NonNull
public Bundle getErrorBundle() { public Bundle getErrorBundle() {
return mErrorBundle; return mErrorBundle != null ? mErrorBundle : Bundle.EMPTY;
} }
@SuppressLint("IntentBuilderName") // This is not creating new Intent.
@Nullable @Nullable
public Intent getActivityIntent() { public Intent getActivityIntent() {
return mActivityIntent; return mActivityIntent;
@@ -335,6 +347,7 @@ public final class TaskFragmentTransaction implements Parcelable {
return 0; return 0;
} }
@NonNull
public static final Creator<Change> CREATOR = new Creator<>() { public static final Creator<Change> CREATOR = new Creator<>() {
@Override @Override
public Change createFromParcel(Parcel in) { public Change createFromParcel(Parcel in) {