Loading core/java/android/window/TaskFragmentOrganizer.java +55 −17 Original line number Diff line number Diff line Loading @@ -32,8 +32,10 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.SparseArray; import android.view.RemoteAnimationDefinition; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; Loading Loading @@ -72,6 +74,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer { */ private final Executor mExecutor; // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release. /** Map from Task id to client tokens of TaskFragments in the Task. */ private final SparseArray<List<IBinder>> mTaskIdToFragmentTokens = new SparseArray<>(); /** Map from Task id to Task configuration. */ private final SparseArray<Configuration> mTaskIdToConfigurations = new SparseArray<>(); public TaskFragmentOrganizer(@NonNull Executor executor) { mExecutor = executor; } Loading Loading @@ -160,6 +168,27 @@ public class TaskFragmentOrganizer extends WindowOrganizer { public void onTaskFragmentParentInfoChanged( @NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) {} /** * Called when the parent leaf Task of organized TaskFragments is changed. * When the leaf Task is changed, the organizer may want to update the TaskFragments in one * transaction. * * For case like screen size change, it will trigger onTaskFragmentParentInfoChanged with new * Task bounds, but may not trigger onTaskFragmentInfoChanged because there can be an override * bounds. * @hide */ public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release. final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId); if (tokens == null || tokens.isEmpty()) { return; } for (int i = tokens.size() - 1; i >= 0; i--) { onTaskFragmentParentInfoChanged(tokens.get(i), parentConfig); } } /** * Called when the {@link WindowContainerTransaction} created with * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side. Loading Loading @@ -221,34 +250,43 @@ public class TaskFragmentOrganizer extends WindowOrganizer { final List<TaskFragmentTransaction.Change> changes = transaction.getChanges(); for (TaskFragmentTransaction.Change change : changes) { // TODO(b/240519866): apply all changes in one WCT. final int taskId = change.getTaskId(); switch (change.getType()) { case TYPE_TASK_FRAGMENT_APPEARED: onTaskFragmentAppeared(change.getTaskFragmentInfo()); if (change.getTaskConfiguration() != null) { // TODO(b/240519866): convert to pass TaskConfiguration for all TFs in the // same Task onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. if (!mTaskIdToFragmentTokens.contains(taskId)) { mTaskIdToFragmentTokens.put(taskId, new ArrayList<>()); } mTaskIdToFragmentTokens.get(taskId).add(change.getTaskFragmentToken()); onTaskFragmentParentInfoChanged(change.getTaskFragmentToken(), mTaskIdToConfigurations.get(taskId)); onTaskFragmentAppeared(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_INFO_CHANGED: if (change.getTaskConfiguration() != null) { // TODO(b/240519866): convert to pass TaskConfiguration for all TFs in the // same Task onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); } onTaskFragmentInfoChanged(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_VANISHED: // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. if (mTaskIdToFragmentTokens.contains(taskId)) { final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId); tokens.remove(change.getTaskFragmentToken()); if (tokens.isEmpty()) { mTaskIdToFragmentTokens.remove(taskId); mTaskIdToConfigurations.remove(taskId); } } onTaskFragmentVanished(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED: onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. mTaskIdToConfigurations.put(taskId, change.getTaskConfiguration()); onTaskFragmentParentInfoChanged(taskId, change.getTaskConfiguration()); break; case TYPE_TASK_FRAGMENT_ERROR: final Bundle errorBundle = change.getErrorBundle(); Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +3 −14 Original line number Diff line number Diff line Loading @@ -51,12 +51,6 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { @VisibleForTesting final Map<IBinder, TaskFragmentInfo> mFragmentInfos = new ArrayMap<>(); /** * Mapping from the client assigned unique token to the TaskFragment parent * {@link Configuration}. */ final Map<IBinder, Configuration> mFragmentParentConfigs = new ArrayMap<>(); private final TaskFragmentCallback mCallback; @VisibleForTesting TaskFragmentAnimationController mAnimationController; Loading @@ -68,8 +62,7 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig); void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig); void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent, @NonNull IBinder activityToken); void onTaskFragmentError(@Nullable TaskFragmentInfo taskFragmentInfo, int opType); Loading Loading @@ -300,7 +293,6 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { @Override public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) { mFragmentInfos.remove(taskFragmentInfo.getFragmentToken()); mFragmentParentConfigs.remove(taskFragmentInfo.getFragmentToken()); if (mCallback != null) { mCallback.onTaskFragmentVanished(taskFragmentInfo); Loading @@ -308,12 +300,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { } @Override public void onTaskFragmentParentInfoChanged( @NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) { mFragmentParentConfigs.put(fragmentToken, parentConfig); public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { if (mCallback != null) { mCallback.onTaskFragmentParentInfoChanged(fragmentToken, parentConfig); mCallback.onTaskFragmentParentInfoChanged(taskId, parentConfig); } } Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java +24 −10 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen container.setInfo(taskFragmentInfo); if (container.isFinished()) { mPresenter.cleanupContainer(container, false /* shouldFinishDependent */); } else { // Update with the latest Task configuration. mPresenter.updateContainer(container); } updateCallbackIfNecessary(); } Loading Loading @@ -233,20 +236,31 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen } @Override public void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) { public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { synchronized (mLock) { final TaskFragmentContainer container = getContainer(fragmentToken); if (container != null) { onTaskConfigurationChanged(container.getTaskId(), parentConfig); onTaskConfigurationChanged(taskId, parentConfig); if (isInPictureInPicture(parentConfig)) { // No need to update presentation in PIP until the Task exit PIP. return; } final TaskContainer taskContainer = getTaskContainer(taskId); if (taskContainer == null || taskContainer.isEmpty()) { Log.e(TAG, "onTaskFragmentParentInfoChanged on empty Task id=" + taskId); return; } // Update all TaskFragments in the Task. Make a copy of the list since some may be // removed on updating. final List<TaskFragmentContainer> containers = new ArrayList<>(taskContainer.mContainers); for (int i = containers.size() - 1; i >= 0; i--) { final TaskFragmentContainer container = containers.get(i); // Wait until onTaskFragmentAppeared to update new container. if (!container.isFinished() && !container.isWaitingActivityAppear()) { mPresenter.updateContainer(container); updateCallbackIfNecessary(); } } updateCallbackIfNecessary(); } } @Override Loading services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +3 −2 Original line number Diff line number Diff line Loading @@ -887,11 +887,12 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { logIfTransactionTooLarge(r.intent, r.getSavedState()); if (r.isEmbedded()) { final TaskFragment organizedTaskFragment = r.getOrganizedTaskFragment(); if (organizedTaskFragment != null) { // Sending TaskFragmentInfo to client to ensure the info is updated before // the activity creation. mService.mTaskFragmentOrganizerController.dispatchPendingInfoChangedEvent( r.getOrganizedTaskFragment()); organizedTaskFragment); } // Create activity launch transaction. Loading services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java +181 −152 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/window/TaskFragmentOrganizer.java +55 −17 Original line number Diff line number Diff line Loading @@ -32,8 +32,10 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.SparseArray; import android.view.RemoteAnimationDefinition; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; Loading Loading @@ -72,6 +74,12 @@ public class TaskFragmentOrganizer extends WindowOrganizer { */ private final Executor mExecutor; // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release. /** Map from Task id to client tokens of TaskFragments in the Task. */ private final SparseArray<List<IBinder>> mTaskIdToFragmentTokens = new SparseArray<>(); /** Map from Task id to Task configuration. */ private final SparseArray<Configuration> mTaskIdToConfigurations = new SparseArray<>(); public TaskFragmentOrganizer(@NonNull Executor executor) { mExecutor = executor; } Loading Loading @@ -160,6 +168,27 @@ public class TaskFragmentOrganizer extends WindowOrganizer { public void onTaskFragmentParentInfoChanged( @NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) {} /** * Called when the parent leaf Task of organized TaskFragments is changed. * When the leaf Task is changed, the organizer may want to update the TaskFragments in one * transaction. * * For case like screen size change, it will trigger onTaskFragmentParentInfoChanged with new * Task bounds, but may not trigger onTaskFragmentInfoChanged because there can be an override * bounds. * @hide */ public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next release. final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId); if (tokens == null || tokens.isEmpty()) { return; } for (int i = tokens.size() - 1; i >= 0; i--) { onTaskFragmentParentInfoChanged(tokens.get(i), parentConfig); } } /** * Called when the {@link WindowContainerTransaction} created with * {@link WindowContainerTransaction#setErrorCallbackToken(IBinder)} failed on the server side. Loading Loading @@ -221,34 +250,43 @@ public class TaskFragmentOrganizer extends WindowOrganizer { final List<TaskFragmentTransaction.Change> changes = transaction.getChanges(); for (TaskFragmentTransaction.Change change : changes) { // TODO(b/240519866): apply all changes in one WCT. final int taskId = change.getTaskId(); switch (change.getType()) { case TYPE_TASK_FRAGMENT_APPEARED: onTaskFragmentAppeared(change.getTaskFragmentInfo()); if (change.getTaskConfiguration() != null) { // TODO(b/240519866): convert to pass TaskConfiguration for all TFs in the // same Task onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. if (!mTaskIdToFragmentTokens.contains(taskId)) { mTaskIdToFragmentTokens.put(taskId, new ArrayList<>()); } mTaskIdToFragmentTokens.get(taskId).add(change.getTaskFragmentToken()); onTaskFragmentParentInfoChanged(change.getTaskFragmentToken(), mTaskIdToConfigurations.get(taskId)); onTaskFragmentAppeared(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_INFO_CHANGED: if (change.getTaskConfiguration() != null) { // TODO(b/240519866): convert to pass TaskConfiguration for all TFs in the // same Task onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); } onTaskFragmentInfoChanged(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_VANISHED: // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. if (mTaskIdToFragmentTokens.contains(taskId)) { final List<IBinder> tokens = mTaskIdToFragmentTokens.get(taskId); tokens.remove(change.getTaskFragmentToken()); if (tokens.isEmpty()) { mTaskIdToFragmentTokens.remove(taskId); mTaskIdToConfigurations.remove(taskId); } } onTaskFragmentVanished(change.getTaskFragmentInfo()); break; case TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED: onTaskFragmentParentInfoChanged( change.getTaskFragmentToken(), change.getTaskConfiguration()); // TODO(b/240519866): doing so to keep CTS compatibility. Remove in the next // release. mTaskIdToConfigurations.put(taskId, change.getTaskConfiguration()); onTaskFragmentParentInfoChanged(taskId, change.getTaskConfiguration()); break; case TYPE_TASK_FRAGMENT_ERROR: final Bundle errorBundle = change.getErrorBundle(); Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +3 −14 Original line number Diff line number Diff line Loading @@ -51,12 +51,6 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { @VisibleForTesting final Map<IBinder, TaskFragmentInfo> mFragmentInfos = new ArrayMap<>(); /** * Mapping from the client assigned unique token to the TaskFragment parent * {@link Configuration}. */ final Map<IBinder, Configuration> mFragmentParentConfigs = new ArrayMap<>(); private final TaskFragmentCallback mCallback; @VisibleForTesting TaskFragmentAnimationController mAnimationController; Loading @@ -68,8 +62,7 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo); void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig); void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig); void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent, @NonNull IBinder activityToken); void onTaskFragmentError(@Nullable TaskFragmentInfo taskFragmentInfo, int opType); Loading Loading @@ -300,7 +293,6 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { @Override public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) { mFragmentInfos.remove(taskFragmentInfo.getFragmentToken()); mFragmentParentConfigs.remove(taskFragmentInfo.getFragmentToken()); if (mCallback != null) { mCallback.onTaskFragmentVanished(taskFragmentInfo); Loading @@ -308,12 +300,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { } @Override public void onTaskFragmentParentInfoChanged( @NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) { mFragmentParentConfigs.put(fragmentToken, parentConfig); public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { if (mCallback != null) { mCallback.onTaskFragmentParentInfoChanged(fragmentToken, parentConfig); mCallback.onTaskFragmentParentInfoChanged(taskId, parentConfig); } } Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java +24 −10 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen container.setInfo(taskFragmentInfo); if (container.isFinished()) { mPresenter.cleanupContainer(container, false /* shouldFinishDependent */); } else { // Update with the latest Task configuration. mPresenter.updateContainer(container); } updateCallbackIfNecessary(); } Loading Loading @@ -233,20 +236,31 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen } @Override public void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken, @NonNull Configuration parentConfig) { public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) { synchronized (mLock) { final TaskFragmentContainer container = getContainer(fragmentToken); if (container != null) { onTaskConfigurationChanged(container.getTaskId(), parentConfig); onTaskConfigurationChanged(taskId, parentConfig); if (isInPictureInPicture(parentConfig)) { // No need to update presentation in PIP until the Task exit PIP. return; } final TaskContainer taskContainer = getTaskContainer(taskId); if (taskContainer == null || taskContainer.isEmpty()) { Log.e(TAG, "onTaskFragmentParentInfoChanged on empty Task id=" + taskId); return; } // Update all TaskFragments in the Task. Make a copy of the list since some may be // removed on updating. final List<TaskFragmentContainer> containers = new ArrayList<>(taskContainer.mContainers); for (int i = containers.size() - 1; i >= 0; i--) { final TaskFragmentContainer container = containers.get(i); // Wait until onTaskFragmentAppeared to update new container. if (!container.isFinished() && !container.isWaitingActivityAppear()) { mPresenter.updateContainer(container); updateCallbackIfNecessary(); } } updateCallbackIfNecessary(); } } @Override Loading
services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +3 −2 Original line number Diff line number Diff line Loading @@ -887,11 +887,12 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { logIfTransactionTooLarge(r.intent, r.getSavedState()); if (r.isEmbedded()) { final TaskFragment organizedTaskFragment = r.getOrganizedTaskFragment(); if (organizedTaskFragment != null) { // Sending TaskFragmentInfo to client to ensure the info is updated before // the activity creation. mService.mTaskFragmentOrganizerController.dispatchPendingInfoChangedEvent( r.getOrganizedTaskFragment()); organizedTaskFragment); } // Create activity launch transaction. Loading
services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java +181 −152 File changed.Preview size limit exceeded, changes collapsed. Show changes