Loading core/java/android/window/WindowContainerTransaction.java +4 −2 Original line number Diff line number Diff line Loading @@ -506,15 +506,17 @@ public final class WindowContainerTransaction implements Parcelable { * {@link #setAdjacentRoots(WindowContainerToken, WindowContainerToken)}, but can be used with * fragmentTokens when that TaskFragments haven't been created (but will be created in the same * {@link WindowContainerTransaction}). * To reset it, pass {@code null} for {@code fragmentToken2}. * @param fragmentToken1 client assigned unique token to create TaskFragment with specified * in {@link TaskFragmentCreationParams#getFragmentToken()}. * @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 */ @NonNull public WindowContainerTransaction setAdjacentTaskFragments( @NonNull IBinder fragmentToken1, @NonNull IBinder fragmentToken2) { @NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2) { final HierarchyOp hierarchyOp = new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS) .setContainer(fragmentToken1) Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java +4 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { secondaryFragmentBounds, WINDOWING_MODE_MULTI_WINDOW, activityIntent, activityOptions); // Set adjacent to each other so that the containers below will be invisible. wct.setAdjacentTaskFragments(launchingFragmentToken, secondaryFragmentToken); applyTransaction(wct); } Loading @@ -126,6 +129,7 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { */ void expandTaskFragment(WindowContainerTransaction wct, IBinder fragmentToken) { resizeTaskFragment(wct, fragmentToken, new Rect()); wct.setAdjacentTaskFragments(fragmentToken, null); } /** Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/SplitPresenter.java +3 −5 Original line number Diff line number Diff line Loading @@ -142,8 +142,9 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer { resizeTaskFragmentIfRegistered(wct, secondaryContainer, secondaryRectBounds); } // TODO(b/190433398): The primary container and the secondary container should also be set // as adjacent (WCT#setAdjacentRoots) to make activities behind invisible. // Set adjacent to each other so that the containers below will be invisible. wct.setAdjacentTaskFragments( primaryContainer.getTaskFragmentToken(), secondaryContainer.getTaskFragmentToken()); applyTransaction(wct); mController.registerSplit(primaryContainer, primaryActivity, secondaryContainer, rule); Loading Loading @@ -184,9 +185,6 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer { primaryContainer.setLastRequestedBounds(primaryRectBounds); 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, rule); } Loading services/core/java/com/android/server/wm/TaskFragment.java +20 −4 Original line number Diff line number Diff line Loading @@ -161,7 +161,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { /** Avoid reentrant of {@link #removeImmediately()}. */ private boolean mRemoving; // The TaskFragment that adjacent to this one. /** The TaskFragment that is adjacent to this one. */ @Nullable private TaskFragment mAdjacentTaskFragment; /** Loading Loading @@ -282,9 +283,23 @@ class TaskFragment extends WindowContainer<WindowContainer> { mRemoteToken = new RemoteToken(this); } void setAdjacentTaskFragment(TaskFragment taskFragment) { void setAdjacentTaskFragment(@Nullable TaskFragment taskFragment) { if (mAdjacentTaskFragment == taskFragment) { return; } resetAdjacentTaskFragment(); if (taskFragment != null) { mAdjacentTaskFragment = taskFragment; taskFragment.mAdjacentTaskFragment = this; 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) { Loading Loading @@ -1951,6 +1966,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { return; } mRemoving = true; resetAdjacentTaskFragment(); super.removeImmediately(); sendTaskFragmentVanished(); mRemoving = false; Loading services/core/java/com/android/server/wm/WindowOrganizerController.java +4 −2 Original line number Diff line number Diff line Loading @@ -720,8 +720,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub fragmentToken = hop.getContainer(); final IBinder adjacentFragmentToken = hop.getAdjacentRoot(); final TaskFragment tf1 = mLaunchTaskFragments.get(fragmentToken); final TaskFragment tf2 = mLaunchTaskFragments.get(adjacentFragmentToken); if (tf1 == null || tf2 == null) { final TaskFragment tf2 = adjacentFragmentToken != null ? mLaunchTaskFragments.get(adjacentFragmentToken) : null; if (tf1 == null || (adjacentFragmentToken != null && tf2 == null)) { final Throwable exception = new IllegalArgumentException( "Not allowed to set adjacent on invalid fragment tokens"); sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception); Loading Loading
core/java/android/window/WindowContainerTransaction.java +4 −2 Original line number Diff line number Diff line Loading @@ -506,15 +506,17 @@ public final class WindowContainerTransaction implements Parcelable { * {@link #setAdjacentRoots(WindowContainerToken, WindowContainerToken)}, but can be used with * fragmentTokens when that TaskFragments haven't been created (but will be created in the same * {@link WindowContainerTransaction}). * To reset it, pass {@code null} for {@code fragmentToken2}. * @param fragmentToken1 client assigned unique token to create TaskFragment with specified * in {@link TaskFragmentCreationParams#getFragmentToken()}. * @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 */ @NonNull public WindowContainerTransaction setAdjacentTaskFragments( @NonNull IBinder fragmentToken1, @NonNull IBinder fragmentToken2) { @NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2) { final HierarchyOp hierarchyOp = new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS) .setContainer(fragmentToken1) Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/JetpackTaskFragmentOrganizer.java +4 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { secondaryFragmentBounds, WINDOWING_MODE_MULTI_WINDOW, activityIntent, activityOptions); // Set adjacent to each other so that the containers below will be invisible. wct.setAdjacentTaskFragments(launchingFragmentToken, secondaryFragmentToken); applyTransaction(wct); } Loading @@ -126,6 +129,7 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { */ void expandTaskFragment(WindowContainerTransaction wct, IBinder fragmentToken) { resizeTaskFragment(wct, fragmentToken, new Rect()); wct.setAdjacentTaskFragments(fragmentToken, null); } /** Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/organizer/SplitPresenter.java +3 −5 Original line number Diff line number Diff line Loading @@ -142,8 +142,9 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer { resizeTaskFragmentIfRegistered(wct, secondaryContainer, secondaryRectBounds); } // TODO(b/190433398): The primary container and the secondary container should also be set // as adjacent (WCT#setAdjacentRoots) to make activities behind invisible. // Set adjacent to each other so that the containers below will be invisible. wct.setAdjacentTaskFragments( primaryContainer.getTaskFragmentToken(), secondaryContainer.getTaskFragmentToken()); applyTransaction(wct); mController.registerSplit(primaryContainer, primaryActivity, secondaryContainer, rule); Loading Loading @@ -184,9 +185,6 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer { primaryContainer.setLastRequestedBounds(primaryRectBounds); 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, rule); } Loading
services/core/java/com/android/server/wm/TaskFragment.java +20 −4 Original line number Diff line number Diff line Loading @@ -161,7 +161,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { /** Avoid reentrant of {@link #removeImmediately()}. */ private boolean mRemoving; // The TaskFragment that adjacent to this one. /** The TaskFragment that is adjacent to this one. */ @Nullable private TaskFragment mAdjacentTaskFragment; /** Loading Loading @@ -282,9 +283,23 @@ class TaskFragment extends WindowContainer<WindowContainer> { mRemoteToken = new RemoteToken(this); } void setAdjacentTaskFragment(TaskFragment taskFragment) { void setAdjacentTaskFragment(@Nullable TaskFragment taskFragment) { if (mAdjacentTaskFragment == taskFragment) { return; } resetAdjacentTaskFragment(); if (taskFragment != null) { mAdjacentTaskFragment = taskFragment; taskFragment.mAdjacentTaskFragment = this; 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) { Loading Loading @@ -1951,6 +1966,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { return; } mRemoving = true; resetAdjacentTaskFragment(); super.removeImmediately(); sendTaskFragmentVanished(); mRemoving = false; Loading
services/core/java/com/android/server/wm/WindowOrganizerController.java +4 −2 Original line number Diff line number Diff line Loading @@ -720,8 +720,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub fragmentToken = hop.getContainer(); final IBinder adjacentFragmentToken = hop.getAdjacentRoot(); final TaskFragment tf1 = mLaunchTaskFragments.get(fragmentToken); final TaskFragment tf2 = mLaunchTaskFragments.get(adjacentFragmentToken); if (tf1 == null || tf2 == null) { final TaskFragment tf2 = adjacentFragmentToken != null ? mLaunchTaskFragments.get(adjacentFragmentToken) : null; if (tf1 == null || (adjacentFragmentToken != null && tf2 == null)) { final Throwable exception = new IllegalArgumentException( "Not allowed to set adjacent on invalid fragment tokens"); sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception); Loading