Merge "Reuse tasks in background in priority for split screen" into tm-qpr-dev
This commit is contained in:
@@ -24,6 +24,7 @@ import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTas
|
|||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.app.TaskInfo;
|
import android.app.TaskInfo;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -327,6 +328,28 @@ public class RecentTasksController implements TaskStackListenerCallback,
|
|||||||
return recentTasks;
|
return recentTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the background task that match the given component.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ActivityManager.RecentTaskInfo findTaskInBackground(ComponentName componentName) {
|
||||||
|
if (componentName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<ActivityManager.RecentTaskInfo> tasks = getRawRecentTasks(Integer.MAX_VALUE,
|
||||||
|
ActivityManager.RECENT_IGNORE_UNAVAILABLE, ActivityManager.getCurrentUser());
|
||||||
|
for (int i = 0; i < tasks.size(); i++) {
|
||||||
|
final ActivityManager.RecentTaskInfo task = tasks.get(i);
|
||||||
|
if (task.isVisible) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (componentName.equals(task.baseIntent.getComponent())) {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void dump(@NonNull PrintWriter pw, String prefix) {
|
public void dump(@NonNull PrintWriter pw, String prefix) {
|
||||||
final String innerPrefix = prefix + " ";
|
final String innerPrefix = prefix + " ";
|
||||||
pw.println(prefix + TAG);
|
pw.println(prefix + TAG);
|
||||||
|
|||||||
@@ -385,6 +385,9 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancelled(boolean isKeyguardOccluded) {
|
public void onAnimationCancelled(boolean isKeyguardOccluded) {
|
||||||
|
final WindowContainerTransaction evictWct = new WindowContainerTransaction();
|
||||||
|
mStageCoordinator.prepareEvictInvisibleChildTasks(evictWct);
|
||||||
|
mSyncQueue.queue(evictWct);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
options = mStageCoordinator.resolveStartStage(STAGE_TYPE_UNDEFINED, position, options,
|
options = mStageCoordinator.resolveStartStage(STAGE_TYPE_UNDEFINED, position, options,
|
||||||
@@ -472,8 +475,16 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
fillInIntent.addFlags(FLAG_ACTIVITY_NO_USER_ACTION);
|
fillInIntent.addFlags(FLAG_ACTIVITY_NO_USER_ACTION);
|
||||||
|
|
||||||
// Flag with MULTIPLE_TASK if this is launching the same activity into both sides of the
|
// Flag with MULTIPLE_TASK if this is launching the same activity into both sides of the
|
||||||
// split.
|
// split and there is no reusable background task.
|
||||||
if (shouldAddMultipleTaskFlag(intent.getIntent(), position)) {
|
if (shouldAddMultipleTaskFlag(intent.getIntent(), position)) {
|
||||||
|
final ActivityManager.RecentTaskInfo taskInfo = mRecentTasksOptional.isPresent()
|
||||||
|
? mRecentTasksOptional.get().findTaskInBackground(
|
||||||
|
intent.getIntent().getComponent())
|
||||||
|
: null;
|
||||||
|
if (taskInfo != null) {
|
||||||
|
startTask(taskInfo.taskId, position, options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK");
|
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user