Thumbnail Cache - check canceled status on the right thread.

The cache was checking the canceled status on the background
thread, but the cancel call was being made on the main thread.
This was leading to canceled requests still delivering this thumbnail
in some cases.

Bug: 159840851
Test: local build and non-repo of bug
Change-Id: I9a3556f6570eee1db39ebec202c115d58010d7f8
This commit is contained in:
Zak Cohen
2020-06-28 20:34:48 -07:00
parent 0538863c58
commit 19797b419b
@@ -166,11 +166,13 @@ public class TaskThumbnailCache {
public void run() {
ThumbnailData thumbnail = ActivityManagerWrapper.getInstance().getTaskThumbnail(
key.id, lowResolution);
if (isCanceled()) {
// We don't call back to the provided callback in this case
return;
}
MAIN_EXECUTOR.execute(() -> {
if (isCanceled()) {
// We don't call back to the provided callback in this case
return;
}
mCache.put(key, thumbnail);
callback.accept(thumbnail);
onEnd();