Merge "setAdjacentTaskFragments for paired TaskFragment" into sc-v2-dev
This commit is contained in:
@@ -506,15 +506,17 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
* {@link #setAdjacentRoots(WindowContainerToken, WindowContainerToken)}, but can be used with
|
* {@link #setAdjacentRoots(WindowContainerToken, WindowContainerToken)}, but can be used with
|
||||||
* fragmentTokens when that TaskFragments haven't been created (but will be created in the same
|
* fragmentTokens when that TaskFragments haven't been created (but will be created in the same
|
||||||
* {@link WindowContainerTransaction}).
|
* {@link WindowContainerTransaction}).
|
||||||
|
* To reset it, pass {@code null} for {@code fragmentToken2}.
|
||||||
* @param fragmentToken1 client assigned unique token to create TaskFragment with specified
|
* @param fragmentToken1 client assigned unique token to create TaskFragment with specified
|
||||||
* in {@link TaskFragmentCreationParams#getFragmentToken()}.
|
* in {@link TaskFragmentCreationParams#getFragmentToken()}.
|
||||||
* @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()}.
|
* in {@link TaskFragmentCreationParams#getFragmentToken()}. If it is
|
||||||
|
* {@code null}, the transaction will reset the adjacent TaskFragment.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public WindowContainerTransaction setAdjacentTaskFragments(
|
public WindowContainerTransaction setAdjacentTaskFragments(
|
||||||
@NonNull IBinder fragmentToken1, @NonNull IBinder fragmentToken2) {
|
@NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2) {
|
||||||
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)
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
|
|||||||
secondaryFragmentBounds, WINDOWING_MODE_MULTI_WINDOW, activityIntent,
|
secondaryFragmentBounds, WINDOWING_MODE_MULTI_WINDOW, activityIntent,
|
||||||
activityOptions);
|
activityOptions);
|
||||||
|
|
||||||
|
// Set adjacent to each other so that the containers below will be invisible.
|
||||||
|
wct.setAdjacentTaskFragments(launchingFragmentToken, secondaryFragmentToken);
|
||||||
|
|
||||||
applyTransaction(wct);
|
applyTransaction(wct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +129,7 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
|
|||||||
*/
|
*/
|
||||||
void expandTaskFragment(WindowContainerTransaction wct, IBinder fragmentToken) {
|
void expandTaskFragment(WindowContainerTransaction wct, IBinder fragmentToken) {
|
||||||
resizeTaskFragment(wct, fragmentToken, new Rect());
|
resizeTaskFragment(wct, fragmentToken, new Rect());
|
||||||
|
wct.setAdjacentTaskFragments(fragmentToken, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
|
|||||||
resizeTaskFragmentIfRegistered(wct, secondaryContainer, secondaryRectBounds);
|
resizeTaskFragmentIfRegistered(wct, secondaryContainer, secondaryRectBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/190433398): The primary container and the secondary container should also be set
|
// Set adjacent to each other so that the containers below will be invisible.
|
||||||
// as adjacent (WCT#setAdjacentRoots) to make activities behind invisible.
|
wct.setAdjacentTaskFragments(
|
||||||
|
primaryContainer.getTaskFragmentToken(), secondaryContainer.getTaskFragmentToken());
|
||||||
applyTransaction(wct);
|
applyTransaction(wct);
|
||||||
|
|
||||||
mController.registerSplit(primaryContainer, primaryActivity, secondaryContainer, rule);
|
mController.registerSplit(primaryContainer, primaryActivity, secondaryContainer, rule);
|
||||||
@@ -184,9 +185,6 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
|
|||||||
primaryContainer.setLastRequestedBounds(primaryRectBounds);
|
primaryContainer.setLastRequestedBounds(primaryRectBounds);
|
||||||
secondaryContainer.setLastRequestedBounds(secondaryRectBounds);
|
secondaryContainer.setLastRequestedBounds(secondaryRectBounds);
|
||||||
|
|
||||||
// TODO(b/190433398): The primary container and the secondary container should also be set
|
|
||||||
// as adjacent (WCT#setAdjacentRoots) to make activities behind invisible.
|
|
||||||
|
|
||||||
mController.registerSplit(primaryContainer, launchingActivity, secondaryContainer,
|
mController.registerSplit(primaryContainer, launchingActivity, secondaryContainer,
|
||||||
rule);
|
rule);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
/** Avoid reentrant of {@link #removeImmediately()}. */
|
/** Avoid reentrant of {@link #removeImmediately()}. */
|
||||||
private boolean mRemoving;
|
private boolean mRemoving;
|
||||||
|
|
||||||
// The TaskFragment that adjacent to this one.
|
/** The TaskFragment that is adjacent to this one. */
|
||||||
|
@Nullable
|
||||||
private TaskFragment mAdjacentTaskFragment;
|
private TaskFragment mAdjacentTaskFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -282,9 +283,23 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
mRemoteToken = new RemoteToken(this);
|
mRemoteToken = new RemoteToken(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAdjacentTaskFragment(TaskFragment taskFragment) {
|
void setAdjacentTaskFragment(@Nullable TaskFragment taskFragment) {
|
||||||
mAdjacentTaskFragment = taskFragment;
|
if (mAdjacentTaskFragment == taskFragment) {
|
||||||
taskFragment.mAdjacentTaskFragment = this;
|
return;
|
||||||
|
}
|
||||||
|
resetAdjacentTaskFragment();
|
||||||
|
if (taskFragment != null) {
|
||||||
|
mAdjacentTaskFragment = taskFragment;
|
||||||
|
taskFragment.setAdjacentTaskFragment(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetAdjacentTaskFragment() {
|
||||||
|
// Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment.
|
||||||
|
if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) {
|
||||||
|
mAdjacentTaskFragment.mAdjacentTaskFragment = null;
|
||||||
|
}
|
||||||
|
mAdjacentTaskFragment = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTaskFragmentOrganizer(TaskFragmentOrganizerToken organizer, int pid) {
|
void setTaskFragmentOrganizer(TaskFragmentOrganizerToken organizer, int pid) {
|
||||||
@@ -1951,6 +1966,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mRemoving = true;
|
mRemoving = true;
|
||||||
|
resetAdjacentTaskFragment();
|
||||||
super.removeImmediately();
|
super.removeImmediately();
|
||||||
sendTaskFragmentVanished();
|
sendTaskFragmentVanished();
|
||||||
mRemoving = false;
|
mRemoving = false;
|
||||||
|
|||||||
@@ -720,8 +720,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
fragmentToken = hop.getContainer();
|
fragmentToken = hop.getContainer();
|
||||||
final IBinder adjacentFragmentToken = hop.getAdjacentRoot();
|
final IBinder adjacentFragmentToken = hop.getAdjacentRoot();
|
||||||
final TaskFragment tf1 = mLaunchTaskFragments.get(fragmentToken);
|
final TaskFragment tf1 = mLaunchTaskFragments.get(fragmentToken);
|
||||||
final TaskFragment tf2 = mLaunchTaskFragments.get(adjacentFragmentToken);
|
final TaskFragment tf2 = adjacentFragmentToken != null
|
||||||
if (tf1 == null || tf2 == null) {
|
? mLaunchTaskFragments.get(adjacentFragmentToken)
|
||||||
|
: null;
|
||||||
|
if (tf1 == null || (adjacentFragmentToken != null && tf2 == null)) {
|
||||||
final Throwable exception = new IllegalArgumentException(
|
final Throwable exception = new IllegalArgumentException(
|
||||||
"Not allowed to set adjacent on invalid fragment tokens");
|
"Not allowed to set adjacent on invalid fragment tokens");
|
||||||
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
||||||
|
|||||||
Reference in New Issue
Block a user