summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2023-06-01 01:31:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-06-01 01:31:26 +0000
commit6c8d57d8b520ceee0eac9944b486c8cbfa219436 (patch)
treefc006ecb72a36c0fc1cdce49a9926e2d5bbd67e7 /src
parent5fe61d4ff7ecea2c76357a6d9d3ce8066697768f (diff)
parent41737b3e8bbe4c72ed8570771b7d64fdbcfcebbb (diff)
downloadLauncher3-6c8d57d8b520ceee0eac9944b486c8cbfa219436.tar.gz
Merge "Fixing icon cache thrashing due to an unsupported icon" into udc-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/icons/IconCache.java34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index 1e3b0030b8..2f7f51e6f7 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -100,6 +100,7 @@ public class IconCache extends BaseIconCache {
private final UserCache mUserManager;
private final InstantAppResolver mInstantAppResolver;
private final IconProvider mIconProvider;
+ private final HandlerRunnable mCancelledRunnable;
private final SparseArray<BitmapInfo> mWidgetCategoryBitmapInfos;
@@ -117,6 +118,10 @@ public class IconCache extends BaseIconCache {
mInstantAppResolver = InstantAppResolver.newInstance(mContext);
mIconProvider = iconProvider;
mWidgetCategoryBitmapInfos = new SparseArray<>();
+
+ mCancelledRunnable = new HandlerRunnable(
+ mWorkerHandler, () -> null, MAIN_EXECUTOR, c -> { });
+ mCancelledRunnable.cancel();
}
@Override
@@ -172,23 +177,30 @@ public class IconCache extends BaseIconCache {
public HandlerRunnable updateIconInBackground(final ItemInfoUpdateReceiver caller,
final ItemInfoWithIcon info) {
Preconditions.assertUIThread();
+ Supplier<ItemInfoWithIcon> task;
+ if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
+ task = () -> {
+ getTitleAndIcon(info, false);
+ return info;
+ };
+ } else if (info instanceof PackageItemInfo pii) {
+ task = () -> {
+ getTitleAndIconForApp(pii, false);
+ return pii;
+ };
+ } else {
+ Log.i(TAG, "Icon update not supported for "
+ + info == null ? "null" : info.getClass().getName());
+ return mCancelledRunnable;
+ }
+
if (mPendingIconRequestCount <= 0) {
MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
}
mPendingIconRequestCount++;
HandlerRunnable<ItemInfoWithIcon> request = new HandlerRunnable<>(mWorkerHandler,
- () -> {
- if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
- getTitleAndIcon(info, false);
- } else if (info instanceof PackageItemInfo) {
- getTitleAndIconForApp((PackageItemInfo) info, false);
- }
- return info;
- },
- MAIN_EXECUTOR,
- caller::reapplyItemInfo,
- this::onIconRequestEnd);
+ task, MAIN_EXECUTOR, caller::reapplyItemInfo, this::onIconRequestEnd);
Utilities.postAsyncCallback(mWorkerHandler, request);
return request;
}