diff options
| author | Louis Chang <louischang@google.com> | 2022-07-21 05:12:14 +0000 |
|---|---|---|
| committer | Louis Chang <louischang@google.com> | 2022-07-28 01:36:38 +0000 |
| commit | 61bfe6e0dc58edff0a84a139fc30f1e87491c10c (patch) | |
| tree | ef616a1ccac676a49d5719c48714f6cdbb4cd6ad /core/java/android/window/TaskFragmentOrganizer.java | |
| parent | 64f07c0057b3e2b5f07fc47235c7372118dfb608 (diff) | |
Sending TaskFragmentInfo and operation type in #onTaskFragmentError
So, the TaskFragmentOrganizer can know what exact operation was
failed and perform error handles if needed.
Removes the pending appeared activities when starting/reparenting
activity into a TaskFragment was failed.
Deprecating the #onTaskFragmentError method with another overloaded
version, but still making sure the deprecated one is called in order
to make it compatible with Android T CTS.
Bug: 236668365
Bug: 233989810
Test: atest TaskFragmentTest
Test: atest TaskFragmentOrganizerControllerTest
Test: atest TaskFragmentOrganizerTest
Test: atest TaskFragmentOrganizerPolicyTest
Change-Id: Id328d037536d32b3acb9c424d36052b6dca8628a
Merged-In: Id328d037536d32b3acb9c424d36052b6dca8628a
Diffstat (limited to 'core/java/android/window/TaskFragmentOrganizer.java')
| -rw-r--r-- | core/java/android/window/TaskFragmentOrganizer.java | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/core/java/android/window/TaskFragmentOrganizer.java b/core/java/android/window/TaskFragmentOrganizer.java index 2ef49c3e2aac..e4a6ad87053c 100644 --- a/core/java/android/window/TaskFragmentOrganizer.java +++ b/core/java/android/window/TaskFragmentOrganizer.java @@ -18,6 +18,7 @@ package android.window; import android.annotation.CallSuper; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.TestApi; import android.content.Intent; import android.content.res.Configuration; @@ -39,16 +40,23 @@ public class TaskFragmentOrganizer extends WindowOrganizer { * Key to the exception in {@link Bundle} in {@link ITaskFragmentOrganizer#onTaskFragmentError}. */ private static final String KEY_ERROR_CALLBACK_EXCEPTION = "fragment_exception"; + private static final String KEY_ERROR_CALLBACK_TASK_FRAGMENT_INFO = "task_fragment_info"; + private static final String KEY_ERROR_CALLBACK_OP_TYPE = "operation_type"; /** - * Creates a {@link Bundle} with an exception that can be passed to - * {@link ITaskFragmentOrganizer#onTaskFragmentError}. + * Creates a {@link Bundle} with an exception, operation type and TaskFragmentInfo (if any) + * that can be passed to {@link ITaskFragmentOrganizer#onTaskFragmentError}. * @hide */ - public static Bundle putExceptionInBundle(@NonNull Throwable exception) { - final Bundle exceptionBundle = new Bundle(); - exceptionBundle.putSerializable(KEY_ERROR_CALLBACK_EXCEPTION, exception); - return exceptionBundle; + public static @NonNull Bundle putErrorInfoInBundle(@NonNull Throwable exception, + @Nullable TaskFragmentInfo info, int opType) { + final Bundle errorBundle = new Bundle(); + errorBundle.putSerializable(KEY_ERROR_CALLBACK_EXCEPTION, exception); + if (info != null) { + errorBundle.putParcelable(KEY_ERROR_CALLBACK_TASK_FRAGMENT_INFO, info); + } + errorBundle.putInt(KEY_ERROR_CALLBACK_OP_TYPE, opType); + return errorBundle; } /** @@ -151,11 +159,34 @@ 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(IBinder, TaskFragmentInfo, int, Throwable)} + * 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 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 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 * orginial Task. In this case, we need to notify the organizer so that it can check if the @@ -217,10 +248,16 @@ public class TaskFragmentOrganizer extends WindowOrganizer { @Override public void onTaskFragmentError( - @NonNull IBinder errorCallbackToken, @NonNull Bundle exceptionBundle) { - mExecutor.execute(() -> TaskFragmentOrganizer.this.onTaskFragmentError( - errorCallbackToken, - (Throwable) exceptionBundle.getSerializable(KEY_ERROR_CALLBACK_EXCEPTION))); + @NonNull IBinder errorCallbackToken, @NonNull Bundle errorBundle) { + mExecutor.execute(() -> { + final TaskFragmentInfo info = errorBundle.getParcelable( + KEY_ERROR_CALLBACK_TASK_FRAGMENT_INFO, TaskFragmentInfo.class); + TaskFragmentOrganizer.this.onTaskFragmentError( + errorCallbackToken, info, + errorBundle.getInt(KEY_ERROR_CALLBACK_OP_TYPE), + (Throwable) errorBundle.getSerializable(KEY_ERROR_CALLBACK_EXCEPTION, + java.lang.Throwable.class)); + }); } @Override |
