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

Commit 0c324cb1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Various icon cache fixes" into ub-launcher3-master

parents 61d639d7 18204e4e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.UserHandle;
import androidx.annotation.Nullable;

import com.android.launcher3.LauncherAppState;
import com.android.launcher3.icons.ComponentWithLabel;
import com.android.launcher3.icons.ComponentWithLabelAndIcon;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.widget.WidgetListRowEntry;

@@ -59,7 +59,7 @@ public class WidgetsModel {
     * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
     *                    only widgets and shortcuts associated with the package/user are.
     */
    public List<ComponentWithLabel> update(LauncherAppState app,
    public List<ComponentWithLabelAndIcon> update(LauncherAppState app,
            @Nullable PackageUserKey packageUser) {
        return Collections.emptyList();
    }
+11 −0
Original line number Diff line number Diff line
@@ -350,6 +350,17 @@ public class BaseIconFactory implements AutoCloseable {
                iconDpi);
    }

    /**
     * Badges the provided source with the badge info
     */
    public BitmapInfo badgeBitmap(Bitmap source, BitmapInfo badgeInfo) {
        Bitmap icon = BitmapRenderer.createHardwareBitmap(mIconBitmapSize, mIconBitmapSize, (c) -> {
            getShadowGenerator().recreateIcon(source, c);
            badgeWithDrawable(c, new FixedSizeBitmapDrawable(badgeInfo.icon));
        });
        return BitmapInfo.of(icon, badgeInfo.color);
    }

    private int extractColor(Bitmap bitmap) {
        return mDisableColorExtractor ? 0 : mColorExtractor.findDominantColorByHue(bitmap);
    }
+8 −5
Original line number Diff line number Diff line
@@ -281,7 +281,8 @@ public abstract class BaseIconCache {

        ContentValues values = newContentValues(entry.bitmap, entry.title.toString(),
                componentName.getPackageName(), cachingLogic.getKeywords(object, mLocaleList));
        addIconToDB(values, componentName, info, userSerial);
        addIconToDB(values, componentName, info, userSerial,
                cachingLogic.getLastUpdatedTime(object, info));
    }

    /**
@@ -289,10 +290,10 @@ public abstract class BaseIconCache {
     * @param values {@link ContentValues} containing icon & title
     */
    private void addIconToDB(ContentValues values, ComponentName key,
            PackageInfo info, long userSerial) {
            PackageInfo info, long userSerial, long lastUpdateTime) {
        values.put(IconDB.COLUMN_COMPONENT, key.flattenToString());
        values.put(IconDB.COLUMN_USER, userSerial);
        values.put(IconDB.COLUMN_LAST_UPDATED, info.lastUpdateTime);
        values.put(IconDB.COLUMN_LAST_UPDATED, lastUpdateTime);
        values.put(IconDB.COLUMN_VERSION, info.versionCode);
        mIconDb.insertOrReplace(values);
    }
@@ -362,7 +363,8 @@ public abstract class BaseIconCache {
                }
                if (object != null) {
                    entry.title = cachingLogic.getLabel(object);
                    entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user);
                    entry.contentDescription = mPackageManager.getUserBadgedLabel(
                            cachingLogic.getDescription(object, entry.title), user);
                }
            }
        }
@@ -449,7 +451,8 @@ public abstract class BaseIconCache {
                    // package updates.
                    ContentValues values = newContentValues(
                            iconInfo, entry.title.toString(), packageName, null);
                    addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user));
                    addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user),
                            info.lastUpdateTime);

                } catch (NameNotFoundException e) {
                    if (DEBUG) Log.d(TAG, "Application not installed " + packageName);
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ public interface CachingLogic<T> {

    CharSequence getLabel(T object);

    default CharSequence getDescription(T object, CharSequence fallback) {
        return fallback;
    }

    @NonNull
    BitmapInfo loadIcon(Context context, T object);

+14 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseBooleanArray;

@@ -61,7 +62,7 @@ public class IconCacheUpdateHandler {
    private final HashMap<String, PackageInfo> mPkgInfoMap;
    private final BaseIconCache mIconCache;

    private final HashMap<UserHandle, Set<String>> mPackagesToIgnore = new HashMap<>();
    private final ArrayMap<UserHandle, Set<String>> mPackagesToIgnore = new ArrayMap<>();

    private final SparseBooleanArray mItemsToDelete = new SparseBooleanArray();
    private boolean mFilterMode = MODE_SET_INVALID_ITEMS;
@@ -77,9 +78,17 @@ public class IconCacheUpdateHandler {
        createPackageInfoMap();
    }

    public void setPackagesToIgnore(UserHandle userHandle, Set<String> packages) {
    /**
     * Sets a package to ignore for processing
     */
    public void addPackagesToIgnore(UserHandle userHandle, String packageName) {
        Set<String> packages = mPackagesToIgnore.get(userHandle);
        if (packages == null) {
            packages = new HashSet<>();
            mPackagesToIgnore.put(userHandle, packages);
        }
        packages.add(packageName);
    }

    private void createPackageInfoMap() {
        PackageManager pm = mIconCache.mPackageManager;
@@ -181,6 +190,7 @@ public class IconCacheUpdateHandler {
                    }
                    continue;
                }

                if (app == null) {
                    if (mFilterMode == MODE_SET_INVALID_ITEMS) {
                        mIconCache.remove(component, user);
@@ -263,6 +273,7 @@ public class IconCacheUpdateHandler {
                T app = mAppsToUpdate.pop();
                String pkg = mCachingLogic.getComponent(app).getPackageName();
                PackageInfo info = mPkgInfoMap.get(pkg);

                mIconCache.addIconToDBAndMemCache(
                        app, mCachingLogic, info, mUserSerial, true /*replace existing*/);
                mUpdatedPackages.add(pkg);
Loading