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
This commit is contained in:
Winson Chung 2018-10-29 10:45:25 -07:00
parent d4dc9545c3
commit f107c9ef6d
2 changed files with 4 additions and 3 deletions

View File

@ -143,8 +143,8 @@ public class RecentsModel extends TaskStackChangeListener {
} }
// Keep the cache up to date with the latest thumbnails // Keep the cache up to date with the latest thumbnails
mTaskList.getTasks(mThumbnailCache.getCacheSize(), true /* keysOnly */, (tasks) -> {
int runningTaskId = RecentsModel.getRunningTaskId(); int runningTaskId = RecentsModel.getRunningTaskId();
mTaskList.getTasks(mThumbnailCache.getCacheSize(), true /* keysOnly */, (tasks) -> {
for (Task task : tasks) { for (Task task : tasks) {
if (task.key.id == runningTaskId) { if (task.key.id == runningTaskId) {
// Skip the running task, it's not going to have an up-to-date snapshot by the // Skip the running task, it's not going to have an up-to-date snapshot by the

View File

@ -108,8 +108,9 @@ public class TaskThumbnailCache {
Preconditions.assertUIThread(); Preconditions.assertUIThread();
// Fetch the thumbnail for this task and put it in the cache // Fetch the thumbnail for this task and put it in the cache
mCache.put(task.key, ActivityManagerWrapper.getInstance().getTaskThumbnail( updateThumbnailInBackground(task, true /* reducedResolution */, (t) -> {
task.key.id, true /* reducedResolution */)); mCache.put(task.key, t.thumbnail);
});
} }