Replace tasks in the same split with the dropping app
When launching a new app into a specific split, evicts all child tasks
that were originally in the same split.
Fix: 202739668
Test: atest WMShellUnitTests
Test: manual check dropping an app to a specific split evicts other
tasks in the same split.
Change-Id: I3f52a3675d6ead742f0b75c83393462e5778a524
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.wm.shell.splitscreen;
|
||||
|
||||
import static android.app.ActivityManager.START_SUCCESS;
|
||||
import static android.app.ActivityManager.START_TASK_TO_FRONT;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.RemoteAnimationTarget.MODE_OPENING;
|
||||
|
||||
@@ -213,7 +215,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
||||
options = mStageCoordinator.resolveStartStage(stage, position, options, null /* wct */);
|
||||
|
||||
try {
|
||||
ActivityTaskManager.getService().startActivityFromRecents(taskId, options);
|
||||
final int result =
|
||||
ActivityTaskManager.getService().startActivityFromRecents(taskId, options);
|
||||
if (result == START_SUCCESS || result == START_TASK_TO_FRONT) {
|
||||
mStageCoordinator.evictOccludedChildren(position);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to launch task", e);
|
||||
}
|
||||
@@ -229,6 +235,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
||||
mContext.getSystemService(LauncherApps.class);
|
||||
launcherApps.startShortcut(packageName, shortcutId, null /* sourceBounds */,
|
||||
options, user);
|
||||
mStageCoordinator.evictOccludedChildren(position);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Slog.e(TAG, "Failed to launch shortcut", e);
|
||||
}
|
||||
@@ -272,6 +279,10 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
||||
Slog.e(TAG, "Error finishing legacy transition: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Launching a new app into a specific split evicts tasks previously in the same
|
||||
// split.
|
||||
mStageCoordinator.evictOccludedChildren(position);
|
||||
}
|
||||
};
|
||||
WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
|
||||
@@ -394,6 +394,12 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE, wct, remoteTransition, this);
|
||||
}
|
||||
|
||||
void evictOccludedChildren(@SplitPosition int position) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
(position == mSideStagePosition ? mSideStage : mMainStage).evictOccludedChildren(wct);
|
||||
mTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
|
||||
Bundle resolveStartStage(@SplitScreen.StageType int stage,
|
||||
@SplitPosition int position, @androidx.annotation.Nullable Bundle options,
|
||||
@androidx.annotation.Nullable WindowContainerTransaction wct) {
|
||||
|
||||
@@ -68,6 +68,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);
|
||||
|
||||
void onRootTaskVanished();
|
||||
|
||||
void onNoLongerSupportMultiWindow();
|
||||
}
|
||||
|
||||
@@ -247,6 +248,15 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
wct.reorder(mChildrenTaskInfo.get(taskId).token, onTop /* onTop */);
|
||||
}
|
||||
|
||||
void evictOccludedChildren(WindowContainerTransaction wct) {
|
||||
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; i--) {
|
||||
final ActivityManager.RunningTaskInfo taskInfo = mChildrenTaskInfo.valueAt(i);
|
||||
if (!taskInfo.isVisible) {
|
||||
wct.reparent(taskInfo.token, null /* parent */, false /* onTop */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setVisibility(boolean visible, WindowContainerTransaction wct) {
|
||||
wct.reorder(mRootTaskInfo.token, visible /* onTop */);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user