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

Commit 7432530c authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Adding ability to override the app-info icon loading behavior" into main

parents 0ea36763 55682c5f
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -61,9 +61,6 @@ import java.util.Objects;
 */
public class IconProvider {

    static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
            "config_icon_mask", "string", "android");

    private static final String TAG = "IconProvider";
    private static final boolean DEBUG = false;
    public static final boolean ATLEAST_T = BuildCompat.isAtLeastT();
@@ -179,22 +176,28 @@ public class IconProvider {
                final Resources resources = mContext.getPackageManager()
                        .getResourcesForApplication(appInfo);
                // Try to load the package item icon first
                if (info.icon != 0) {
                if (info != appInfo && info.icon != 0) {
                    try {
                        icon = resources.getDrawableForDensity(info.icon, density);
                    } catch (Resources.NotFoundException exc) { }
                }
                if (icon == null && appInfo.icon != 0) {
                    // Load the fallback app icon
                    try {
                        icon = resources.getDrawableForDensity(appInfo.icon, density);
                    } catch (Resources.NotFoundException exc) { }
                    icon = loadAppInfoIcon(appInfo, resources, density);
                }
            } catch (NameNotFoundException | Resources.NotFoundException exc) { }
        }
        return icon != null ? icon : getFullResDefaultActivityIcon(density);
    }

    @Nullable
    protected Drawable loadAppInfoIcon(ApplicationInfo info, Resources resources, int density) {
        try {
            return resources.getDrawableForDensity(info.icon, density);
        } catch (Resources.NotFoundException exc) { }
        return null;
    }

    @TargetApi(Build.VERSION_CODES.TIRAMISU)
    private Drawable loadCalendarDrawable(int iconDpi, @Nullable ThemeData td) {
        PackageManager pm = mContext.getPackageManager();
+1 −1
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ constructor(
            ComponentKey(ComponentName(packageName, packageName + EMPTY_CLASS_NAME), user)

        // Ensures themed bitmaps in the icon cache are invalidated
        @JvmField val RELEASE_VERSION = if (Flags.forceMonochromeAppIcons()) 4 else 3
        @JvmField val RELEASE_VERSION = if (Flags.forceMonochromeAppIcons()) 6 else 5

        @JvmField val TABLE_NAME = "icons"
        @JvmField val COLUMN_ROWID = "rowid"