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

Commit 31409c0c authored by Benjamin Franz's avatar Benjamin Franz Committed by Android (Google) Code Review
Browse files

Merge "Introduce new API to get an unbadged icon and unbadge permissions." into lmp-mr1-dev

parents ce85d7f4 ec2d48b9
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1660,6 +1660,17 @@ final class ApplicationPackageManager extends PackageManager {
     * @hide
     */
    public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
        Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo);
        if (itemInfo.showUserIcon != UserHandle.USER_NULL) {
            return dr;
        }
        return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId()));
    }

    /**
     * @hide
     */
    public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
        if (itemInfo.showUserIcon != UserHandle.USER_NULL) {
            Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon);
            if (bitmap == null) {
@@ -1674,7 +1685,7 @@ final class ApplicationPackageManager extends PackageManager {
        if (dr == null) {
            dr = itemInfo.loadDefaultIcon(this);
        }
        return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId()));
        return dr;
    }

    private Drawable getBadgedDrawable(Drawable drawable, Drawable badgeDrawable,
+18 −1
Original line number Diff line number Diff line
@@ -155,6 +155,23 @@ public class PackageItemInfo {
        return pm.loadItemIcon(this, getApplicationInfo());
    }

    /**
     * Retrieve the current graphical icon associated with this item without
     * the addition of a work badge if applicable.
     * This will call back on the given PackageManager to load the icon from
     * the application.
     *
     * @param pm A PackageManager from which the icon can be loaded; usually
     * the PackageManager from which you originally retrieved this item.
     *
     * @return Returns a Drawable containing the item's icon.  If the
     * item does not have an icon, the item's default icon is returned
     * such as the default activity icon.
     */
    public Drawable loadUnbadgedIcon(PackageManager pm) {
        return pm.loadUnbadgedItemIcon(this, getApplicationInfo());
    }

    /**
     * Retrieve the current graphical banner associated with this item.  This
     * will call back on the given PackageManager to load the banner from
+5 −0
Original line number Diff line number Diff line
@@ -3911,6 +3911,11 @@ public abstract class PackageManager {
     */
    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);

    /**
     * @hide
     */
    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);

    /** {@hide} */
    public abstract boolean isPackageAvailable(String packageName);

+2 −2
Original line number Diff line number Diff line
@@ -99,12 +99,12 @@ public class AppSecurityPermissions {

        public Drawable loadGroupIcon(PackageManager pm) {
            if (icon != 0) {
                return loadIcon(pm);
                return loadUnbadgedIcon(pm);
            } else {
                ApplicationInfo appInfo;
                try {
                    appInfo = pm.getApplicationInfo(packageName, 0);
                    return appInfo.loadIcon(pm);
                    return appInfo.loadUnbadgedIcon(pm);
                } catch (NameNotFoundException e) {
                }
            }
+7 −0
Original line number Diff line number Diff line
@@ -793,4 +793,11 @@ public class MockPackageManager extends PackageManager {
    public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
        throw new UnsupportedOperationException();
    }

    /**
     * @hide
     */
    public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
        throw new UnsupportedOperationException();
    }
}