summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/IconCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/IconCache.java')
-rw-r--r--src/com/android/launcher3/IconCache.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 3bcd7afb4..573e8a256 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -47,6 +47,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Provider;
import com.android.launcher3.util.SQLiteCacheHelper;
@@ -94,6 +95,7 @@ public class IconCache {
private final LauncherAppsCompat mLauncherApps;
private final HashMap<ComponentKey, CacheEntry> mCache =
new HashMap<>(INITIAL_ICON_CACHE_CAPACITY);
+ private final InstantAppResolver mInstantAppResolver;
private final int mIconDpi;
@Thunk final IconDB mIconDb;
@@ -106,6 +108,7 @@ public class IconCache {
mPackageManager = context.getPackageManager();
mUserManager = UserManagerCompat.getInstance(mContext);
mLauncherApps = LauncherAppsCompat.getInstance(mContext);
+ mInstantAppResolver = InstantAppResolver.newInstance(mContext);
mIconDpi = inv.fillResIconDpi;
mIconDb = new IconDB(context, inv.iconBitmapSize);
@@ -120,7 +123,7 @@ public class IconCache {
}
private Drawable getFullResDefaultActivityIcon() {
- return getFullResIcon(Resources.getSystem(), Utilities.isAtLeastO() ?
+ return getFullResIcon(Resources.getSystem(), Utilities.ATLEAST_OREO ?
android.R.drawable.sym_def_app_icon : android.R.mipmap.sym_def_app_icon);
}
@@ -575,7 +578,6 @@ public class IconCache {
// For icon caching, do not go through DB. Just update the in-memory entry.
if (entry == null) {
entry = new CacheEntry();
- mCache.put(cacheKey, entry);
}
if (!TextUtils.isEmpty(title)) {
entry.title = title;
@@ -583,6 +585,9 @@ public class IconCache {
if (icon != null) {
entry.icon = LauncherIcons.createIconBitmap(icon, mContext);
}
+ if (!TextUtils.isEmpty(title) && entry.icon != null) {
+ mCache.put(cacheKey, entry);
+ }
}
private static ComponentKey getPackageKey(String packageName, UserHandle user) {
@@ -619,6 +624,10 @@ public class IconCache {
// only keep the low resolution icon instead of the larger full-sized icon
Bitmap icon = LauncherIcons.createBadgedIconBitmap(
appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion);
+ if (mInstantAppResolver.isInstantApp(appInfo)) {
+ icon = LauncherIcons.badgeWithDrawable(icon,
+ mContext.getDrawable(R.drawable.ic_instant_app_badge), mContext);
+ }
Bitmap lowResIcon = generateLowResIcon(icon);
entry.title = appInfo.loadLabel(mPackageManager);
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);