Simplifying IconCache access code
Providing a way to access icon cache without LauncherAcitivtiyInfo.
This allows fetching LauncherActivityInfo only when required, thus
avoiding system RPC when the icon is already in cache.
Change-Id: I92918c7a0d0d0796e5f7b70d4ecb6787c52c6600
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0dc91e3..58a7495 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1794,8 +1794,7 @@
for (ShortcutInfo info : folder.contents) {
if (info.usingLowResIcon &&
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
- mIconCache.getTitleAndIcon(
- info, info.getPromisedIntent(), info.user, false);
+ mIconCache.getTitleAndIcon(info, false);
}
pos ++;
if (pos >= FolderIcon.NUM_ITEMS_IN_PREVIEW) {
@@ -2520,10 +2519,12 @@
int promiseType, int itemType, CursorIconInfo iconInfo) {
final ShortcutInfo info = new ShortcutInfo();
info.user = Process.myUserHandle();
+ info.promisedIntent = intent;
+
info.iconBitmap = iconInfo.loadIcon(c, info);
// the fallback icon
if (info.iconBitmap == null) {
- mIconCache.getTitleAndIcon(info, intent, info.user, false /* useLowResIcon */);
+ mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
}
if ((promiseType & ShortcutInfo.FLAG_RESTORED_ICON) != 0) {
@@ -2541,7 +2542,6 @@
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.itemType = itemType;
- info.promisedIntent = intent;
info.status = promiseType;
return info;
}
@@ -2592,7 +2592,11 @@
}
final ShortcutInfo info = new ShortcutInfo();
- mIconCache.getTitleAndIcon(info, componentName, lai, user, false, useLowResIcon);
+ info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
+ info.user = user;
+ info.intent = newIntent;
+
+ mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.iconBitmap, user) && c != null) {
Bitmap icon = iconInfo.loadIcon(c);
info.iconBitmap = icon != null ? icon : mIconCache.getDefaultIcon(user);
@@ -2612,8 +2616,6 @@
info.title = componentName.getClassName();
}
- info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
- info.user = user;
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
return info;
}