diff options
author | Pinyao Ting <pinyaoting@google.com> | 2019-09-17 23:34:50 -0700 |
---|---|---|
committer | Pinyao Ting <pinyaoting@google.com> | 2019-09-20 15:24:22 +0000 |
commit | ddd0ff44ba0424427e68016dc676ba006d4f70b0 (patch) | |
tree | ff9a61a2deae335a415cd9562d332732f529dfcc /iconloaderlib | |
parent | ca939f073c42b87035d910928fe87a3f6619abab (diff) | |
download | android_packages_apps_Trebuchet-ddd0ff44ba0424427e68016dc676ba006d4f70b0.tar.gz android_packages_apps_Trebuchet-ddd0ff44ba0424427e68016dc676ba006d4f70b0.tar.bz2 android_packages_apps_Trebuchet-ddd0ff44ba0424427e68016dc676ba006d4f70b0.zip |
Exclude shortcuts in popup from IconCache.
We want to load from/save icons to icon cache for pinned shortcuts only
to reduce memory footprint.
Bug: 140242324
Change-Id: I25c7d59e29c6e27752b36c2c3c226849d4e177af
Diffstat (limited to 'iconloaderlib')
-rw-r--r-- | iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java | 12 | ||||
-rw-r--r-- | iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java | 7 |
2 files changed, 9 insertions, 10 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java index c100f0596..a886c0aa0 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +++ b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java @@ -273,7 +273,7 @@ public abstract class BaseIconCache { if (entry.icon == null) return; entry.title = cachingLogic.getLabel(object); entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user); - mCache.put(key, entry); + if (cachingLogic.addToMemCache()) mCache.put(key, entry); ContentValues values = newContentValues(entry, entry.title.toString(), componentName.getPackageName(), cachingLogic.getKeywords(object, mLocaleList)); @@ -312,20 +312,12 @@ public abstract class BaseIconCache { @NonNull ComponentName componentName, @NonNull UserHandle user, @NonNull Supplier<T> infoProvider, @NonNull CachingLogic<T> cachingLogic, boolean usePackageIcon, boolean useLowResIcon) { - return cacheLocked(componentName, user, infoProvider, cachingLogic, usePackageIcon, - useLowResIcon, true); - } - - protected <T> CacheEntry cacheLocked( - @NonNull ComponentName componentName, @NonNull UserHandle user, - @NonNull Supplier<T> infoProvider, @NonNull CachingLogic<T> cachingLogic, - boolean usePackageIcon, boolean useLowResIcon, boolean addToMemCache) { assertWorkerThread(); ComponentKey cacheKey = new ComponentKey(componentName, user); CacheEntry entry = mCache.get(cacheKey); if (entry == null || (entry.isLowRes() && !useLowResIcon)) { entry = new CacheEntry(); - if (addToMemCache) { + if (cachingLogic.addToMemCache()) { mCache.put(cacheKey, entry); } diff --git a/iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java b/iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java index 16bc7ae83..3aa783a14 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java +++ b/iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java @@ -49,4 +49,11 @@ public interface CachingLogic<T> { default long getLastUpdatedTime(T object, PackageInfo info) { return info.lastUpdateTime; } + + /** + * Returns true the object should be added to mem cache; otherwise returns false. + */ + default boolean addToMemCache() { + return true; + } } |