Merge "Promote #setAdjacentTaskFragment to TestApi" into sc-v2-dev am: 2c452240ea

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

Change-Id: I5116fe69b2a674d3428c014c91e450340c2207b8
This commit is contained in:
Charles Chen
2021-09-13 05:48:29 +00:00
committed by Automerger Merge Worker
4 changed files with 43 additions and 21 deletions

View File

@@ -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 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 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 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 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 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); 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; 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 { public abstract class WindowContainerTransactionCallback {
ctor public WindowContainerTransactionCallback(); ctor public WindowContainerTransactionCallback();
method public abstract void onTransactionReady(int, @NonNull android.view.SurfaceControl.Transaction); method public abstract void onTransactionReady(int, @NonNull android.view.SurfaceControl.Transaction);

View File

@@ -512,17 +512,16 @@ public final class WindowContainerTransaction implements Parcelable {
* @param fragmentToken2 client assigned unique token to create TaskFragment with specified * @param fragmentToken2 client assigned unique token to create TaskFragment with specified
* in {@link TaskFragmentCreationParams#getFragmentToken()}. If it is * in {@link TaskFragmentCreationParams#getFragmentToken()}. If it is
* {@code null}, the transaction will reset the adjacent TaskFragment. * {@code null}, the transaction will reset the adjacent TaskFragment.
* @hide
*/ */
@NonNull @NonNull
public WindowContainerTransaction setAdjacentTaskFragments( public WindowContainerTransaction setAdjacentTaskFragments(
@NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2, @NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2,
@Nullable TaskFragmentAdjacentOptions options) { @Nullable TaskFragmentAdjacentParams params) {
final HierarchyOp hierarchyOp = final HierarchyOp hierarchyOp =
new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS) new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS)
.setContainer(fragmentToken1) .setContainer(fragmentToken1)
.setReparentContainer(fragmentToken2) .setReparentContainer(fragmentToken2)
.setLaunchOptions(options != null ? options.toBundle() : null) .setLaunchOptions(params != null ? params.toBundle() : null)
.build(); .build();
mHierarchyOps.add(hierarchyOp); mHierarchyOps.add(hierarchyOp);
return this; 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 * Helper class for building an options Bundle that can be used to set adjacent rules of
* TaskFragments. * TaskFragments.
* @hide
*/ */
public static class TaskFragmentAdjacentOptions { public static class TaskFragmentAdjacentParams {
private static final String DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL = private static final String DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL =
"android:transaction.adjacent.option.delay_primary_removal"; "android:transaction.adjacent.option.delay_primary_removal";
private static final String DELAY_SECONDARY_LAST_ACTIVITY_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 mDelayPrimaryLastActivityRemoval;
private boolean mDelaySecondaryLastActivityRemoval; private boolean mDelaySecondaryLastActivityRemoval;
public TaskFragmentAdjacentOptions() { public TaskFragmentAdjacentParams() {
} }
public TaskFragmentAdjacentOptions(@NonNull Bundle bundle) { public TaskFragmentAdjacentParams(@NonNull Bundle bundle) {
mDelayPrimaryLastActivityRemoval = bundle.getBoolean( mDelayPrimaryLastActivityRemoval = bundle.getBoolean(
DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL); DELAY_PRIMARY_LAST_ACTIVITY_REMOVAL);
mDelaySecondaryLastActivityRemoval = bundle.getBoolean( mDelaySecondaryLastActivityRemoval = bundle.getBoolean(
DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL); DELAY_SECONDARY_LAST_ACTIVITY_REMOVAL);
} }
public void setDelayPrimaryLastActivityRemoval(boolean delay) { /** @see #shouldDelayPrimaryLastActivityRemoval() */
public void setShouldDelayPrimaryLastActivityRemoval(boolean delay) {
mDelayPrimaryLastActivityRemoval = delay; mDelayPrimaryLastActivityRemoval = delay;
} }
public void setDelaySecondaryLastActivityRemoval(boolean delay) { /** @see #shouldDelaySecondaryLastActivityRemoval() */
public void setShouldDelaySecondaryLastActivityRemoval(boolean delay) {
mDelaySecondaryLastActivityRemoval = 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; return mDelayPrimaryLastActivityRemoval;
} }
public boolean isDelaySecondaryLastActivityRemoval() { /**
* Similar to {@link #shouldDelayPrimaryLastActivityRemoval()}, but for the secondary
* TaskFragment.
*/
public boolean shouldDelaySecondaryLastActivityRemoval() {
return mDelaySecondaryLastActivityRemoval; return mDelaySecondaryLastActivityRemoval;
} }

View File

@@ -210,17 +210,17 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
void setAdjacentTaskFragments(@NonNull WindowContainerTransaction wct, void setAdjacentTaskFragments(@NonNull WindowContainerTransaction wct,
@NonNull IBinder primary, @Nullable IBinder secondary, @Nullable SplitRule splitRule) { @NonNull IBinder primary, @Nullable IBinder secondary, @Nullable SplitRule splitRule) {
WindowContainerTransaction.TaskFragmentAdjacentOptions adjacentOptions = null; WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams = null;
final boolean finishSecondaryWithPrimary = final boolean finishSecondaryWithPrimary =
splitRule != null && SplitContainer.shouldFinishSecondaryWithPrimary(splitRule); splitRule != null && SplitContainer.shouldFinishSecondaryWithPrimary(splitRule);
final boolean finishPrimaryWithSecondary = final boolean finishPrimaryWithSecondary =
splitRule != null && SplitContainer.shouldFinishPrimaryWithSecondary(splitRule); splitRule != null && SplitContainer.shouldFinishPrimaryWithSecondary(splitRule);
if (finishSecondaryWithPrimary || finishPrimaryWithSecondary) { if (finishSecondaryWithPrimary || finishPrimaryWithSecondary) {
adjacentOptions = new WindowContainerTransaction.TaskFragmentAdjacentOptions(); adjacentParams = new WindowContainerTransaction.TaskFragmentAdjacentParams();
adjacentOptions.setDelayPrimaryLastActivityRemoval(finishSecondaryWithPrimary); adjacentParams.setShouldDelayPrimaryLastActivityRemoval(finishSecondaryWithPrimary);
adjacentOptions.setDelaySecondaryLastActivityRemoval(finishPrimaryWithSecondary); adjacentParams.setShouldDelaySecondaryLastActivityRemoval(finishPrimaryWithSecondary);
} }
wct.setAdjacentTaskFragments(primary, secondary, adjacentOptions); wct.setAdjacentTaskFragments(primary, secondary, adjacentParams);
} }
TaskFragmentCreationParams createFragmentOptions(IBinder fragmentToken, IBinder ownerToken, TaskFragmentCreationParams createFragmentOptions(IBinder fragmentToken, IBinder ownerToken,

View File

@@ -733,18 +733,18 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
tf1.setAdjacentTaskFragment(tf2); tf1.setAdjacentTaskFragment(tf2);
final Bundle bundle = hop.getLaunchOptions(); final Bundle bundle = hop.getLaunchOptions();
final WindowContainerTransaction.TaskFragmentAdjacentOptions adjacentOptions = final WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams =
bundle != null ? new WindowContainerTransaction.TaskFragmentAdjacentOptions( bundle != null ? new WindowContainerTransaction.TaskFragmentAdjacentParams(
bundle) : null; bundle) : null;
if (adjacentOptions == null) { if (adjacentParams == null) {
break; break;
} }
tf1.setDelayLastActivityRemoval( tf1.setDelayLastActivityRemoval(
adjacentOptions.isDelayPrimaryLastActivityRemoval()); adjacentParams.shouldDelayPrimaryLastActivityRemoval());
if (tf2 != null) { if (tf2 != null) {
tf2.setDelayLastActivityRemoval( tf2.setDelayLastActivityRemoval(
adjacentOptions.isDelaySecondaryLastActivityRemoval()); adjacentParams.shouldDelaySecondaryLastActivityRemoval());
} }
break; break;
} }