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

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

Merge "Temporarily use reflection to get notification badge icon type" into ub-launcher3-dorval

parents aa57e97d a4736df6
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.View;

import com.android.launcher3.Launcher;
@@ -64,7 +65,21 @@ public class NotificationInfo implements View.OnClickListener {
        Notification notification = statusBarNotification.getNotification();
        title = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
        text = notification.extras.getCharSequence(Notification.EXTRA_TEXT);
        mBadgeIcon = notification.getBadgeIcon();

        // TODO(b/36855196): use getBadgeIconType() without reflection
        int badgeIcon = Notification.BADGE_ICON_NONE;
        try {
            badgeIcon = (int) Notification.class.getMethod("getBadgeIconType").invoke(notification);
        } catch (Exception e) {
            Log.w("NotificationInfo", "getBadgeIconType() failed", e);
            // Try the old name, getBadgeIcon(), instead.
            try {
                badgeIcon = (int) Notification.class.getMethod("getBadgeIcon").invoke(notification);
            } catch (Exception e1) {
                Log.e("NotificationInfo", "getBadgeIcon() failed", e);
            }
        }
        mBadgeIcon = badgeIcon;
        // Load the icon. Since it is backed by ashmem, we won't copy the entire bitmap
        // into our process as long as we don't touch it and it exists in systemui.
        Icon icon = mBadgeIcon == Notification.BADGE_ICON_SMALL ? null : notification.getLargeIcon();