diff options
| author | 2016-02-01 18:15:53 +0000 | |
|---|---|---|
| committer | 2016-02-01 18:15:53 +0000 | |
| commit | 6bbf598b11feb3bd04bbcda0904a3a4bd32c2ff4 (patch) | |
| tree | 42cd7a817b86a06b75589d75256e5977fe226357 | |
| parent | 8e7fffd17d3b6f267879e5b6b8f002d2b4a70bd6 (diff) | |
| parent | df1020c539f012fbd72fb25831c39b6515876509 (diff) | |
Merge "Fixing crash loop when the parent affiliated task is removed."
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java index 4e08bc27c0c6..c51aa7ce38c9 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java @@ -138,18 +138,29 @@ public class RecentsTaskLoadPlan { lastStackActiveTime = 0; } long newLastStackActiveTime = -1; + long prevLastActiveTime = lastStackActiveTime; int taskCount = mRawTasks.size(); for (int i = 0; i < taskCount; i++) { ActivityManager.RecentTaskInfo t = mRawTasks.get(i); - // Affiliated tasks are returned in a specific order from ActivityManager but without a - // lastActiveTime since it hasn't yet been started. However, we later sort the task list - // by lastActiveTime, which rearranges the tasks. For now, we need to workaround this - // by updating the lastActiveTime of this task to the lastActiveTime of the task it is - // affiliated with, in the same order that we encounter it in the original list (just - // its index in the task group for the task it is affiliated with). + /* + * Affiliated tasks are returned in a specific order from ActivityManager but without a + * lastActiveTime since it hasn't yet been started. However, we later sort the task list + * by lastActiveTime, which rearranges the tasks. For now, we need to workaround this + * by updating the lastActiveTime of this task to the lastActiveTime of the task it is + * affiliated with, in the same order that we encounter it in the original list (just + * its index in the task group for the task it is affiliated with). + * + * If the parent task is not available, then we will use the last active time of the + * previous task as a base point (since the task itself may not have an active time) + * for the entire affiliated group. + */ if (t.persistentId != t.affiliatedTaskId) { - t.lastActiveTime = affiliatedTasks.get(t.affiliatedTaskId).lastActiveTime + + Task.TaskKey parentTask = affiliatedTasks.get(t.affiliatedTaskId); + long parentTaskLastActiveTime = parentTask != null + ? parentTask.lastActiveTime + : prevLastActiveTime; + t.lastActiveTime = parentTaskLastActiveTime + affiliatedTaskCounts.get(t.affiliatedTaskId, 0) + 1; } @@ -186,6 +197,8 @@ public class RecentsTaskLoadPlan { allTasks.add(task); affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1); affiliatedTasks.put(taskKey.id, taskKey); + + prevLastActiveTime = t.lastActiveTime; } if (newLastStackActiveTime != -1) { Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, |