summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchneider Victor-tulias <victortulias@google.com>2022-02-16 19:31:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-02-16 19:31:33 +0000
commitee9a54b4705868744d207d3270afdc466a9214a2 (patch)
treedf784292c3a6d74df00fef12264fbf7907e98edc /src
parent95686cd9be820a5a40bf73cc7ee17a0b2e5fcd8a (diff)
parentc4ed3ab82c8c2387edc89566203f1fb696bb2980 (diff)
downloadLauncher3-ee9a54b4705868744d207d3270afdc466a9214a2.tar.gz
Merge "Fix blank workspce icons on Launcher data refresh."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/icons/IconCache.java120
1 files changed, 90 insertions, 30 deletions
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index f512ced2eb..3129e2af41 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -350,42 +350,102 @@ public class IconCache extends BaseIconCache {
iconRequest.itemInfo.getTargetComponent()));
Trace.beginSection("loadIconSubsectionInBulk");
- try (Cursor c = createBulkQueryCursor(
- filteredList,
- /* user = */ sectionKey.first,
- /* useLowResIcons = */ sectionKey.second)) {
- int componentNameColumnIndex = c.getColumnIndexOrThrow(IconDB.COLUMN_COMPONENT);
- while (c.moveToNext()) {
- ComponentName cn = ComponentName.unflattenFromString(
- c.getString(componentNameColumnIndex));
- List<IconRequestInfo<T>> duplicateIconRequests =
- duplicateIconRequestsMap.get(cn);
-
- if (cn != null) {
- CacheEntry entry = cacheLocked(
- cn,
- /* user = */ sectionKey.first,
- () -> duplicateIconRequests.get(0).launcherActivityInfo,
- mLauncherActivityInfoCachingLogic,
- c,
- /* usePackageIcon= */ false,
- /* useLowResIcons = */ sectionKey.second);
-
- for (IconRequestInfo<T> iconRequest : duplicateIconRequests) {
- applyCacheEntry(entry, iconRequest.itemInfo);
- }
+ loadIconSubsection(sectionKey, filteredList, duplicateIconRequestsMap);
+ Trace.endSection();
+ });
+ Trace.endSection();
+ }
+
+ private <T extends ItemInfoWithIcon> void loadIconSubsection(
+ Pair<UserHandle, Boolean> sectionKey,
+ List<IconRequestInfo<T>> filteredList,
+ Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap) {
+ Trace.beginSection("loadIconSubsectionWithDatabase");
+ try (Cursor c = createBulkQueryCursor(
+ filteredList,
+ /* user = */ sectionKey.first,
+ /* useLowResIcons = */ sectionKey.second)) {
+ // Database title and icon loading
+ int componentNameColumnIndex = c.getColumnIndexOrThrow(IconDB.COLUMN_COMPONENT);
+ while (c.moveToNext()) {
+ ComponentName cn = ComponentName.unflattenFromString(
+ c.getString(componentNameColumnIndex));
+ List<IconRequestInfo<T>> duplicateIconRequests =
+ duplicateIconRequestsMap.get(cn);
+
+ if (cn != null) {
+ CacheEntry entry = cacheLocked(
+ cn,
+ /* user = */ sectionKey.first,
+ () -> duplicateIconRequests.get(0).launcherActivityInfo,
+ mLauncherActivityInfoCachingLogic,
+ c,
+ /* usePackageIcon= */ false,
+ /* useLowResIcons = */ sectionKey.second);
+
+ for (IconRequestInfo<T> iconRequest : duplicateIconRequests) {
+ applyCacheEntry(entry, iconRequest.itemInfo);
}
}
- } catch (SQLiteException e) {
- Log.d(TAG, "Error reading icon cache", e);
- } finally {
- Trace.endSection();
}
- });
+ } catch (SQLiteException e) {
+ Log.d(TAG, "Error reading icon cache", e);
+ } finally {
+ Trace.endSection();
+ }
+
+ Trace.beginSection("loadIconSubsectionWithFallback");
+ // Fallback title and icon loading
+ for (ComponentName cn : duplicateIconRequestsMap.keySet()) {
+ IconRequestInfo<T> iconRequestInfo = duplicateIconRequestsMap.get(cn).get(0);
+ ItemInfoWithIcon itemInfo = iconRequestInfo.itemInfo;
+ BitmapInfo icon = itemInfo.bitmap;
+ boolean loadFallbackTitle = TextUtils.isEmpty(itemInfo.title);
+ boolean loadFallbackIcon = icon == null
+ || isDefaultIcon(icon, itemInfo.user)
+ || icon == BitmapInfo.LOW_RES_INFO;
+
+ if (loadFallbackTitle || loadFallbackIcon) {
+ Log.i(TAG,
+ "Database bulk icon loading failed, using fallback bulk icon loading "
+ + "for: " + cn);
+ CacheEntry entry = new CacheEntry();
+ LauncherActivityInfo lai = iconRequestInfo.launcherActivityInfo;
+
+ // Fill fields that are not updated below so they are not subsequently
+ // deleted.
+ entry.title = itemInfo.title;
+ if (icon != null) {
+ entry.bitmap = icon;
+ }
+ entry.contentDescription = itemInfo.contentDescription;
+
+ if (loadFallbackIcon) {
+ loadFallbackIcon(
+ lai,
+ entry,
+ mLauncherActivityInfoCachingLogic,
+ /* usePackageIcon= */ false,
+ /* usePackageTitle= */ loadFallbackTitle,
+ cn,
+ sectionKey.first);
+ }
+ if (loadFallbackTitle && TextUtils.isEmpty(entry.title)) {
+ loadFallbackTitle(
+ lai,
+ entry,
+ mLauncherActivityInfoCachingLogic,
+ sectionKey.first);
+ }
+
+ for (IconRequestInfo<T> iconRequest : duplicateIconRequestsMap.get(cn)) {
+ applyCacheEntry(entry, iconRequest.itemInfo);
+ }
+ }
+ }
Trace.endSection();
}
-
/**
* Fill in {@param infoInOut} with the corresponding icon and label.
*/