diff options
| author | 2021-09-13 05:36:42 +0000 | |
|---|---|---|
| committer | 2021-09-13 05:36:42 +0000 | |
| commit | 2c452240eac94d72def84a2f8571f8d0bd40f312 (patch) | |
| tree | 0820fe4f4a7a5e541d45e3d4d48e75dbd77f7af2 | |
| parent | c8d003a518baa5c62522ac7a327c7dcb5fb6fd3c (diff) | |
| parent | 3d7ad43140cfbd71f780950e19606306910126e6 (diff) | |
Merge "Promote #setAdjacentTaskFragment to TestApi" into sc-v2-dev
4 files changed, 43 insertions, 21 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt index f7164cf3761e..df46822472fa 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -3295,6 +3295,7 @@ package android.window { method @NonNull public android.window.WindowContainerTransaction scheduleFinishEnterPip(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setActivityWindowingMode(@NonNull android.window.WindowContainerToken, int); method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken); + method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @Nullable android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams); method @NonNull public android.window.WindowContainerTransaction setAppBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect); method @NonNull public android.window.WindowContainerTransaction setBoundsChangeTransaction(@NonNull android.window.WindowContainerToken, @NonNull android.view.SurfaceControl.Transaction); @@ -3310,6 +3311,15 @@ package android.window { field @NonNull public static final android.os.Parcelable.Creator<android.window.WindowContainerTransaction> CREATOR; } + public static class WindowContainerTransaction.TaskFragmentAdjacentParams { + ctor public WindowContainerTransaction.TaskFragmentAdjacentParams(); + ctor public WindowContainerTransaction.TaskFragmentAdjacentParams(@NonNull android.os.Bundle); + method public void setShouldDelayPrimaryLastActivityRemoval(boolean); + method public void setShouldDelaySecondaryLastActivityRemoval(boolean); + method public boolean shouldDelayPrimaryLastActivityRemoval(); + method public boolean shouldDelaySecondaryLastActivityRemoval(); + } + public abstract class WindowContainerTransactionCallback { ctor public WindowContainerTransactionCallback(); method public abstract void onTransactionReady(int, @NonNull android.view.SurfaceControl.Transaction); diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java index 387837d82acf..9d6488d7aa14 100644 --- a/core/java/android/window/WindowContainerTransaction.java +++ b/core/java/android/window/WindowContainerTransaction.java @@ -512,17 +512,16 @@ public final class WindowContainerTransaction implements Parcelable { * @param fragmentToken2 client assigned unique token to create TaskFragment with specified * in {@link TaskFragmentCreationParams#getFragmentToken()}. If it is * {@code null}, the transaction will reset the adjacent TaskFragment. - * @hide */ @NonNull public WindowContainerTransaction setAdjacentTaskFragments( @NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2, - @Nullable TaskFragmentAdjacentOptions options) { + @Nullable TaskFragmentAdjacentParams params) { final HierarchyOp hierarchyOp = new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS) .setContainer(fragmentToken1) .setReparentContainer(fragmentToken2) - .setLaunchOptions(options != null ? options.toBundle() : null) + .setLaunchOptions(params != null ? params.toBundle() : null) .build(); mHierarchyOps.add(hierarchyOp); return this; @@ -1304,9 +1303,8 @@ public final class WindowContainerTransaction implements Parcelable { /** * Helper class for building an options Bundle that can be used to set adjacent rules of * TaskFragments. - * @hide */ - public static class TaskFragmentAdjacentOptions { + public static class TaskFragmentAdjacentParams { private static final String DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL = "android:transaction.adjacent.option.delay_primary_removal"; private static final String DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL = @@ -1315,29 +1313,43 @@ public final class WindowContainerTransaction implements Parcelable { private boolean mDelayPrimaryLastActivityRemoval; private boolean mDelaySecondaryLastActivityRemoval; - public TaskFragmentAdjacentOptions() { + public TaskFragmentAdjacentParams() { } - public TaskFragmentAdjacentOptions(@NonNull Bundle bundle) { + public TaskFragmentAdjacentParams(@NonNull Bundle bundle) { mDelayPrimaryLastActivityRemoval = bundle.getBoolean( DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL); mDelaySecondaryLastActivityRemoval = bundle.getBoolean( DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL); } - public void setDelayPrimaryLastActivityRemoval(boolean delay) { + /** @see #shouldDelayPrimaryLastActivityRemoval() */ + public void setShouldDelayPrimaryLastActivityRemoval(boolean delay) { mDelayPrimaryLastActivityRemoval = delay; } - public void setDelaySecondaryLastActivityRemoval(boolean delay) { + /** @see #shouldDelaySecondaryLastActivityRemoval() */ + public void setShouldDelaySecondaryLastActivityRemoval(boolean delay) { mDelaySecondaryLastActivityRemoval = delay; } - public boolean isDelayPrimaryLastActivityRemoval() { + /** + * Whether to delay the last activity of the primary adjacent TaskFragment being immediately + * removed while finishing. + * <p> + * It is usually set to {@code true} to give organizer an opportunity to perform other + * actions or animations. An example is to finish together with the adjacent TaskFragment. + * </p> + */ + public boolean shouldDelayPrimaryLastActivityRemoval() { return mDelayPrimaryLastActivityRemoval; } - public boolean isDelaySecondaryLastActivityRemoval() { + /** + * Similar to {@link #shouldDelayPrimaryLastActivityRemoval()}, but for the secondary + * TaskFragment. + */ + public boolean shouldDelaySecondaryLastActivityRemoval() { return mDelaySecondaryLastActivityRemoval; } diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java index 9212a0f5e6b9..46c8ffe286bd 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java @@ -210,17 +210,17 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { void setAdjacentTaskFragments(@NonNull WindowContainerTransaction wct, @NonNull IBinder primary, @Nullable IBinder secondary, @Nullable SplitRule splitRule) { - WindowContainerTransaction.TaskFragmentAdjacentOptions adjacentOptions = null; + WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams = null; final boolean finishSecondaryWithPrimary = splitRule != null && SplitContainer.shouldFinishSecondaryWithPrimary(splitRule); final boolean finishPrimaryWithSecondary = splitRule != null && SplitContainer.shouldFinishPrimaryWithSecondary(splitRule); if (finishSecondaryWithPrimary || finishPrimaryWithSecondary) { - adjacentOptions = new WindowContainerTransaction.TaskFragmentAdjacentOptions(); - adjacentOptions.setDelayPrimaryLastActivityRemoval(finishSecondaryWithPrimary); - adjacentOptions.setDelaySecondaryLastActivityRemoval(finishPrimaryWithSecondary); + adjacentParams = new WindowContainerTransaction.TaskFragmentAdjacentParams(); + adjacentParams.setShouldDelayPrimaryLastActivityRemoval(finishSecondaryWithPrimary); + adjacentParams.setShouldDelaySecondaryLastActivityRemoval(finishPrimaryWithSecondary); } - wct.setAdjacentTaskFragments(primary, secondary, adjacentOptions); + wct.setAdjacentTaskFragments(primary, secondary, adjacentParams); } TaskFragmentCreationParams createFragmentOptions(IBinder fragmentToken, IBinder ownerToken, diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java index 8bcd62dffca1..834b6e62305d 100644 --- a/services/core/java/com/android/server/wm/WindowOrganizerController.java +++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java @@ -733,18 +733,18 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub tf1.setAdjacentTaskFragment(tf2); final Bundle bundle = hop.getLaunchOptions(); - final WindowContainerTransaction.TaskFragmentAdjacentOptions adjacentOptions = - bundle != null ? new WindowContainerTransaction.TaskFragmentAdjacentOptions( + final WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams = + bundle != null ? new WindowContainerTransaction.TaskFragmentAdjacentParams( bundle) : null; - if (adjacentOptions == null) { + if (adjacentParams == null) { break; } tf1.setDelayLastActivityRemoval( - adjacentOptions.isDelayPrimaryLastActivityRemoval()); + adjacentParams.shouldDelayPrimaryLastActivityRemoval()); if (tf2 != null) { tf2.setDelayLastActivityRemoval( - adjacentOptions.isDelaySecondaryLastActivityRemoval()); + adjacentParams.shouldDelaySecondaryLastActivityRemoval()); } break; } |