summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2015-12-11 10:23:59 -0500
committer Winson Chung <winsonc@google.com> 2015-12-14 15:15:57 +0000
commit2b9ef6548be89d36ea7629f4a3d8ba7bba1422ce (patch)
tree9e166df96985ac14c6a1f538cbf160167d4e5e46
parent88b3b57341e03fb4da2a798c547da40f2e1427c8 (diff)
Fix: Affiliated tasks not showing when history is enabled.
- Because these tasks may not have valid last-active times (they can be launched in the background), the historical state should reflect the task that they are affiliated with. Bug: 26043228 Change-Id: I04db9effc371783a80bea80bd0a45b666269ead1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java40
2 files changed, 43 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index 60bedaecdf2d..512effab047a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -93,7 +93,8 @@ public class Task {
public TaskKey key;
public TaskGrouping group;
- public int taskAffiliation;
+ // The taskAffiliationId is the task id of the parent task or itself if it is not affiliated with any task
+ public int taskAffiliationId;
public int taskAffiliationColor;
public boolean isLaunchTarget;
public Drawable applicationIcon;
@@ -123,7 +124,7 @@ public class Task {
boolean isInAffiliationGroup = (taskAffiliation != key.id);
boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0);
this.key = key;
- this.taskAffiliation = taskAffiliation;
+ this.taskAffiliationId = taskAffiliation;
this.taskAffiliationColor = taskAffiliationColor;
this.activityLabel = activityTitle;
this.contentDescription = contentDescription;
@@ -142,7 +143,7 @@ public class Task {
/** Copies the other task. */
public void copyFrom(Task o) {
this.key = o.key;
- this.taskAffiliation = o.taskAffiliation;
+ this.taskAffiliationId = o.taskAffiliationId;
this.taskAffiliationColor = o.taskAffiliationColor;
this.activityLabel = o.activityLabel;
this.contentDescription = o.contentDescription;
@@ -206,6 +207,13 @@ public class Task {
}
}
+ /**
+ * Returns whether this task is affiliated with another task.
+ */
+ public boolean isAffiliatedTask() {
+ return key.id != taskAffiliationId;
+ }
+
@Override
public boolean equals(Object o) {
// Check that the id matches
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index 7a9839365498..13ab3920065e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -23,6 +23,7 @@ import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
+import android.util.SparseArray;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsDebugFlags;
@@ -50,7 +51,7 @@ import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
*/
interface TaskFilter {
/** Returns whether the filter accepts the specified task */
- public boolean acceptTask(Task t, int index);
+ public boolean acceptTask(SparseArray<Task> taskIdMap, Task t, int index);
}
/**
@@ -157,10 +158,17 @@ class FilteredTaskList {
private void updateFilteredTasks() {
mFilteredTasks.clear();
if (mFilter != null) {
+ // Create a sparse array from task id to Task
+ SparseArray<Task> taskIdMap = new SparseArray<>();
int taskCount = mTasks.size();
for (int i = 0; i < taskCount; i++) {
Task t = mTasks.get(i);
- if (mFilter.acceptTask(t, i)) {
+ taskIdMap.put(t.key.id, t);
+ }
+
+ for (int i = 0; i < taskCount; i++) {
+ Task t = mTasks.get(i);
+ if (mFilter.acceptTask(taskIdMap, t, i)) {
mFilteredTasks.add(t);
}
}
@@ -318,13 +326,29 @@ public class TaskStack {
// Ensure that we only show non-docked tasks
mStackTaskList.setFilter(new TaskFilter() {
@Override
- public boolean acceptTask(Task t, int index) {
+ public boolean acceptTask(SparseArray<Task> taskIdMap, Task t, int index) {
+ if (t.isAffiliatedTask()) {
+ // If this task is affiliated with another parent in the stack, then the historical state of this
+ // task depends on the state of the parent task
+ Task parentTask = taskIdMap.get(t.taskAffiliationId);
+ if (parentTask != null) {
+ t = parentTask;
+ }
+ }
return !t.isHistorical && !SystemServicesProxy.isDockedStack(t.key.stackId);
}
});
mHistoryTaskList.setFilter(new TaskFilter() {
@Override
- public boolean acceptTask(Task t, int index) {
+ public boolean acceptTask(SparseArray<Task> taskIdMap, Task t, int index) {
+ if (t.isAffiliatedTask()) {
+ // If this task is affiliated with another parent in the stack, then the historical state of this
+ // task depends on the state of the parent task
+ Task parentTask = taskIdMap.get(t.taskAffiliationId);
+ if (parentTask != null) {
+ t = parentTask;
+ }
+ }
return t.isHistorical && !SystemServicesProxy.isDockedStack(t.key.stackId);
}
});
@@ -585,8 +609,8 @@ public class TaskStack {
taskGrouping2.latestActiveTimeInGroup);
}
});
- // Sort group tasks by increasing firstActiveTime of the task, and also build a new list of
- // tasks
+ // Sort group tasks by increasing firstActiveTime of the task, and also build a new list
+ // of tasks
int taskIndex = 0;
int groupCount = mGroups.size();
for (int i = 0; i < groupCount; i++) {
@@ -607,13 +631,13 @@ public class TaskStack {
mStackTaskList.set(tasks);
} else {
// Create the task groups
- HashMap<Task.TaskKey, Task> tasksMap = new HashMap<Task.TaskKey, Task>();
+ HashMap<Task.TaskKey, Task> tasksMap = new HashMap<>();
ArrayList<Task> tasks = mStackTaskList.getTasks();
int taskCount = tasks.size();
for (int i = 0; i < taskCount; i++) {
Task t = tasks.get(i);
TaskGrouping group;
- int affiliation = t.taskAffiliation > 0 ? t.taskAffiliation :
+ int affiliation = t.taskAffiliationId > 0 ? t.taskAffiliationId :
IndividualTaskIdOffset + t.key.id;
if (mAffinitiesGroups.containsKey(affiliation)) {
group = getGroupWithAffiliation(affiliation);