diff options
author | Winson Chung <winsonc@google.com> | 2019-06-25 14:44:05 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2019-06-25 14:44:05 -0700 |
commit | df9fc63e8c0dd75af1bd1d50d090f9821fd62fc6 (patch) | |
tree | f1fc7a606f71e1b38b9468a625c30ea2b55dc1ee | |
parent | a90531cd00ad64fb8501c8190f99e068f9d581d6 (diff) | |
download | Launcher3-df9fc63e8c0dd75af1bd1d50d090f9821fd62fc6.tar.gz |
Clean up some more refs to thumbnail data
- Always return a copy of the task list to ensure that the model doesn't
hold refs to the thumbnail data if it was loaded into the same task
- Always clear the task thumbnail data ref once the visibility of the
task view changes to be invisible
Bug: 132309376
Test: Enter overview scroll to the end of the list, relaunch app and take
heap dump
Change-Id: I4437fd30172a5fe2a78c111f780163a1e6bbbb54
-rw-r--r-- | quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java | 6 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/RecentTasksList.java | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index e7e41893cf..b26fdce92f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -368,6 +368,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { } else { mSnapshotView.setThumbnail(null, null); setIcon(null); + // Reset the task thumbnail reference as well (it will be fetched from the cache or + // reloaded next time we need it) + mTask.thumbnail = null; } } @@ -488,9 +491,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mSnapshotView.setThumbnail(mTask, null); setOverlayEnabled(false); onTaskListVisibilityChanged(false); - if (mTask != null) { - mTask.thumbnail = null; - } } @Override diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 3538373122..f27ba85388 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -84,7 +84,7 @@ public class RecentTasksList extends TaskStackChangeListener { final int requestLoadId = mChangeId; Runnable resultCallback = callback == null ? () -> { } - : () -> callback.accept(mTasks); + : () -> callback.accept(copyOf(mTasks)); if (mLastLoadedId == mChangeId && (!mLastLoadHadKeysOnly || loadKeysOnly)) { // The list is up to date, callback with the same list @@ -183,4 +183,14 @@ public class RecentTasksList extends TaskStackChangeListener { return allTasks; } + + private ArrayList<Task> copyOf(ArrayList<Task> tasks) { + ArrayList<Task> newTasks = new ArrayList<>(); + for (int i = 0; i < tasks.size(); i++) { + Task t = tasks.get(i); + newTasks.add(new Task(t.key, t.colorPrimary, t.colorBackground, t.isDockable, + t.isLocked, t.taskDescription, t.topActivity)); + } + return newTasks; + } }
\ No newline at end of file |