Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82bd8a3f authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Expose fallback app title and icon bitmap loading flows.

Test: manual
Bug: 195674813
Change-Id: Iae73360a980fd5ecd7b8fdbbf2451adb2f5fe516
parent 417997ff
Loading
Loading
Loading
Loading
+52 −23
Original line number Diff line number Diff line
@@ -370,6 +370,36 @@ public abstract class BaseIconCache {
                object = infoProvider.get();
                providerFetchedOnce = true;

                loadFallbackIcon(
                        object,
                        entry,
                        cachingLogic,
                        usePackageIcon,
                        /* usePackageTitle= */ true,
                        componentName,
                        user);
            }

            if (TextUtils.isEmpty(entry.title)) {
                if (object == null && !providerFetchedOnce) {
                    object = infoProvider.get();
                    providerFetchedOnce = true;
                }
                if (object != null) {
                    loadFallbackTitle(object, entry, cachingLogic, user);
                }
            }
        }
        return entry;
    }

    /**
     * Fallback method for loading an icon bitmap.
     */
    protected <T> void loadFallbackIcon(
            T object, CacheEntry entry, @NonNull CachingLogic<T> cachingLogic,
            boolean usePackageIcon, boolean usePackageTitle, @NonNull ComponentName componentName,
            @NonNull UserHandle user) {
        if (object != null) {
            entry.bitmap = cachingLogic.loadIcon(mContext, object);
        } else {
@@ -380,8 +410,11 @@ public abstract class BaseIconCache {
                    if (DEBUG) Log.d(TAG, "using package default icon for " +
                            componentName.toShortString());
                    entry.bitmap = packageEntry.bitmap;
                            entry.title = packageEntry.title;
                    entry.contentDescription = packageEntry.contentDescription;

                    if (usePackageTitle) {
                        entry.title = packageEntry.title;
                    }
                }
            }
            if (entry.bitmap == null) {
@@ -392,20 +425,16 @@ public abstract class BaseIconCache {
        }
    }

            if (TextUtils.isEmpty(entry.title)) {
                if (object == null && !providerFetchedOnce) {
                    object = infoProvider.get();
                    providerFetchedOnce = true;
                }
                if (object != null) {
    /**
     * Fallback method for loading an app title.
     */
    protected <T> void loadFallbackTitle(
            T object, CacheEntry entry, @NonNull CachingLogic<T> cachingLogic,
            @NonNull UserHandle user) {
        entry.title = cachingLogic.getLabel(object);
        entry.contentDescription = mPackageManager.getUserBadgedLabel(
                cachingLogic.getDescription(object, entry.title), user);
    }
            }
        }
        return entry;
    }

    public synchronized void clear() {
        assertWorkerThread();