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

Commit ad8b94d3 authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Revert "Revert "Create creation flag to not show any user badge ..."

Revert submission 25263180-revert-24721954-cherrypick-removeBadgeInBadge-dia2ji7r7td-RZRSBRGYSA

Reason for revert: Fix the test that uses the work USERHANDLE that may cause this security exception https://paste.googleplex.com/5530091189698560


Reverted changes: /q/submissionid:25263180-revert-24721954-cherrypick-removeBadgeInBadge-dia2ji7r7td-RZRSBRGYSA

Change-Id: I9edddf0bf29d0ff4e1d596456751e2e6efd57fc4
parent 374f76ac
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -41,9 +41,11 @@ public class BitmapInfo {

    public static final int FLAG_THEMED = 1 << 0;
    public static final int FLAG_NO_BADGE = 1 << 1;
    public static final int FLAG_SKIP_USER_BADGE = 1 << 2;
    @IntDef(flag = true, value = {
            FLAG_THEMED,
            FLAG_NO_BADGE,
            FLAG_SKIP_USER_BADGE,
    })
    public @interface DrawableCreationFlags {}

@@ -153,20 +155,32 @@ public class BitmapInfo {
        drawable.mDisabledAlpha = GraphicsUtils.getFloat(context, R.attr.disabledIconAlpha, 1f);
        drawable.mCreationFlags = creationFlags;
        if ((creationFlags & FLAG_NO_BADGE) == 0) {
            Drawable badge = getBadgeDrawable(context, (creationFlags & FLAG_THEMED) != 0);
            Drawable badge = getBadgeDrawable(context, (creationFlags & FLAG_THEMED) != 0,
                    (creationFlags & FLAG_SKIP_USER_BADGE) != 0);
            if (badge != null) {
                drawable.setBadge(badge);
            }
        }
    }

    public Drawable getBadgeDrawable(Context context, boolean isThemed) {
        return getBadgeDrawable(context, isThemed, false);
    }

    /**
     * Returns a drawable representing the badge for this info
     */
    @Nullable
    public Drawable getBadgeDrawable(Context context, boolean isThemed) {
    private Drawable getBadgeDrawable(Context context, boolean isThemed, boolean skipUserBadge) {
        if (badgeInfo != null) {
            return badgeInfo.newIcon(context, isThemed ? FLAG_THEMED : 0);
            int creationFlag = isThemed ? FLAG_THEMED : 0;
            if (skipUserBadge) {
                creationFlag |= FLAG_SKIP_USER_BADGE;
            }
            return badgeInfo.newIcon(context, creationFlag);
        }
        if (skipUserBadge) {
            return null;
        } else if ((flags & FLAG_INSTANT) != 0) {
            return context.getDrawable(isThemed
                    ? R.drawable.ic_instant_app_badge_themed