summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-05-09 05:05:19 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-05-09 05:05:19 +0000
commitd401d88fe16c8ddbfe3224fec3a42e092603a8f9 (patch)
tree94f27be95d174478fe5cb4924dbfbbd4753ed686
parent07dbf8e88a2d0b61b57fd6331a5a633bd978427b (diff)
parente8e9069b3a93b430bd8bd144ed8f792fa810fe76 (diff)
Merge "Return right activities in getTopVisibleActivities method" into udc-dev
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java3
-rw-r--r--services/core/java/com/android/server/wm/RootWindowContainer.java20
2 files changed, 20 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
index 3f4a775bc37a..7926216fe15d 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
@@ -178,6 +178,9 @@ public abstract class ActivityTaskManagerInternal {
/**
* Returns the top activity from each of the currently visible root tasks, and the related task
* id. The first entry will be the focused activity.
+ *
+ * <p>NOTE: If the top activity is in the split screen, the other activities in the same split
+ * screen will also be returned.
*/
public abstract List<ActivityAssistInfo> getTopVisibleActivities();
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 5149985f8ff9..0074ebd579cf 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -1746,9 +1746,13 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
/**
* @return a list of pairs, containing activities and their task id which are the top ones in
* each visible root task. The first entry will be the focused activity.
+ *
+ * <p>NOTE: If the top activity is in the split screen, the other activities in the same split
+ * screen will also be returned.
*/
List<ActivityAssistInfo> getTopVisibleActivities() {
final ArrayList<ActivityAssistInfo> topVisibleActivities = new ArrayList<>();
+ final ArrayList<ActivityAssistInfo> activityAssistInfos = new ArrayList<>();
final Task topFocusedRootTask = getTopDisplayFocusedRootTask();
// Traverse all displays.
forAllRootTasks(rootTask -> {
@@ -1756,11 +1760,21 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
if (rootTask.shouldBeVisible(null /* starting */)) {
final ActivityRecord top = rootTask.getTopNonFinishingActivity();
if (top != null) {
- ActivityAssistInfo visibleActivity = new ActivityAssistInfo(top);
+ activityAssistInfos.clear();
+ activityAssistInfos.add(new ActivityAssistInfo(top));
+ // Check if the activity on the split screen.
+ final Task adjacentTask = top.getTask().getAdjacentTask();
+ if (adjacentTask != null) {
+ final ActivityRecord adjacentActivityRecord =
+ adjacentTask.getTopNonFinishingActivity();
+ if (adjacentActivityRecord != null) {
+ activityAssistInfos.add(new ActivityAssistInfo(adjacentActivityRecord));
+ }
+ }
if (rootTask == topFocusedRootTask) {
- topVisibleActivities.add(0, visibleActivity);
+ topVisibleActivities.addAll(0, activityAssistInfos);
} else {
- topVisibleActivities.add(visibleActivity);
+ topVisibleActivities.addAll(activityAssistInfos);
}
}
}