From f107c9ef6ddc59763c1b60507c6ea7b09ecee8f9 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 29 Oct 2018 10:45:25 -0700 Subject: [PATCH] Fixing regression in background task loading. Bug: 117603579 Test: Take systrace, ensure that we aren't loading thumbnails on the UI thread Change-Id: I4b522246a5ab12dc37c1dffdccd05232bbc1f6fe --- quickstep/src/com/android/quickstep/RecentsModel.java | 2 +- quickstep/src/com/android/quickstep/TaskThumbnailCache.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index e184a9bb18..2e4d4d2b83 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -143,8 +143,8 @@ public class RecentsModel extends TaskStackChangeListener { } // Keep the cache up to date with the latest thumbnails + int runningTaskId = RecentsModel.getRunningTaskId(); mTaskList.getTasks(mThumbnailCache.getCacheSize(), true /* keysOnly */, (tasks) -> { - int runningTaskId = RecentsModel.getRunningTaskId(); for (Task task : tasks) { if (task.key.id == runningTaskId) { // Skip the running task, it's not going to have an up-to-date snapshot by the diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java index c47101b827..61a191f3fa 100644 --- a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java +++ b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java @@ -108,8 +108,9 @@ public class TaskThumbnailCache { Preconditions.assertUIThread(); // Fetch the thumbnail for this task and put it in the cache - mCache.put(task.key, ActivityManagerWrapper.getInstance().getTaskThumbnail( - task.key.id, true /* reducedResolution */)); + updateThumbnailInBackground(task, true /* reducedResolution */, (t) -> { + mCache.put(task.key, t.thumbnail); + }); }