Promote #setAdjacentTaskFragment to TestApi

Also rename TaskFragmentAdjacentOptions to TaskFragmentAdjacentParams to
make metalava happy.

Test: build & run
Bug: 192442647

Change-Id: Iab256ce8c745635a51834f44e72493e204224f36
This commit is contained in:
Charles Chen
2021-08-11 22:52:32 +08:00
parent 0bce85311c
commit 3d7ad43140
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 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);

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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;
}