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

Commit 8e22cab8 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes I28adf676,I9b1a5583 into sc-dev

* changes:
  Ensure that HUN ordering is correct for Incoming CallStyle notifications
  Improve notification style comparisons
parents 46e2f597 79ab4d1b
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -2799,7 +2799,7 @@ public class Notification implements Parcelable
            }
        }

        if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) {
        if (isStyle(MessagingStyle.class) && extras != null) {
            final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES);
            if (!ArrayUtils.isEmpty(messages)) {
                for (MessagingStyle.Message message : MessagingStyle.Message
@@ -6906,6 +6906,15 @@ public class Notification implements Parcelable
        return null;
    }

    /**
     * @return whether the style of this notification is the one provided
     * @hide
     */
    public boolean isStyle(@NonNull Class<? extends Style> styleClass) {
        String templateClass = extras.getString(Notification.EXTRA_TEMPLATE);
        return Objects.equals(templateClass, styleClass.getName());
    }

    /**
     * @return true if this notification is colorized *for the purposes of ranking*.  If the
     * {@link #color} is {@link #COLOR_DEFAULT} this will be true, even though the actual
@@ -6974,7 +6983,7 @@ public class Notification implements Parcelable
     * @return true if the notification has image
     */
    public boolean hasImage() {
        if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) {
        if (isStyle(MessagingStyle.class) && extras != null) {
            final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES);
            if (!ArrayUtils.isEmpty(messages)) {
                for (MessagingStyle.Message m : MessagingStyle.Message
+1 −2
Original line number Diff line number Diff line
@@ -86,8 +86,7 @@ public class NotificationMessagingUtil {
    };

    private boolean hasMessagingStyle(StatusBarNotification sbn) {
        Class<? extends Notification.Style> style = sbn.getNotification().getNotificationStyle();
        return Notification.MessagingStyle.class.equals(style);
        return sbn.getNotification().isStyle(Notification.MessagingStyle.class);
    }

    private boolean isCategoryMessage(StatusBarNotification sbn) {
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ public class NotificationHelper {
        if (notification == null) {
            return null;
        }
        if (Notification.MessagingStyle.class.equals(notification.getNotificationStyle())
        if (notification.isStyle(Notification.MessagingStyle.class)
                && notification.extras != null) {
            final Parcelable[] messages = notification.extras.getParcelableArray(EXTRA_MESSAGES);
            if (!ArrayUtils.isEmpty(messages)) {
+1 −2
Original line number Diff line number Diff line
@@ -220,8 +220,7 @@ private fun StatusBarNotification.isSystemNotification() =
        "android" == packageName || "com.android.systemui" == packageName

private fun NotificationEntry.isImportantCall() =
        sbn.notification.extras?.getString(Notification.EXTRA_TEMPLATE) ==
                "android.app.Notification\$CallStyle" && importance > IMPORTANCE_MIN
        sbn.notification.isStyle(Notification.CallStyle::class.java) && importance > IMPORTANCE_MIN

private fun NotificationEntry.isColorizedForegroundService() = sbn.notification.run {
    isForegroundService && isColorized && importance > IMPORTANCE_MIN
+1 −2
Original line number Diff line number Diff line
@@ -105,8 +105,7 @@ public class HighPriorityProvider {
    }

    private boolean isMessagingStyle(NotificationEntry entry) {
        return Notification.MessagingStyle.class.equals(
                entry.getSbn().getNotification().getNotificationStyle());
        return entry.getSbn().getNotification().isStyle(Notification.MessagingStyle.class);
    }

    private boolean isPeopleNotification(NotificationEntry entry) {
Loading