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

Commit 206e7d74 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Prevent bell icon from disappearing on immediate followup notification.

The Ranking object of a notification update has lastAudiblylertedMs of
-1 if the notification did not buzz because a buzz happened within the
last 5s.  This causes the bell icon to disappear on a conversation
where a person posted twice within 5s. This is resolved by copying the
lastAudiblyAlertedMs from the NotificationEntry's existing Ranking when
setting a new one, if the new Ranking's value is -1.

Bug: 156887617
Test: Update an alerting notification within 5s of update which caused an alert; bell should stay even though buzz is skipped.
Change-Id: Ibb72ab27c88cfa57add781e2746fff0eee5de6be
parent 62b824a3
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1900,6 +1900,17 @@ public abstract class NotificationListenerService extends Service {
            mIsBubble = isBubble;
        }

        /**
         * @hide
         */
        public @NonNull Ranking withAudiblyAlertedInfo(@Nullable Ranking previous) {
            if (previous != null && previous.mLastAudiblyAlertedMs > 0
                    && this.mLastAudiblyAlertedMs <= 0) {
                this.mLastAudiblyAlertedMs = previous.mLastAudiblyAlertedMs;
            }
            return this;
        }

        /**
         * @hide
         */
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ public final class NotificationEntry extends ListEntry {
                    + " doesn't match existing key " + mKey);
        }

        mRanking = ranking;
        mRanking = ranking.withAudiblyAlertedInfo(mRanking);
    }

    /*
+3 −3
Original line number Diff line number Diff line
@@ -106,9 +106,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {

    public void updateNotification(@NonNull String key, boolean alert) {
        super.updateNotification(key, alert);
        AlertEntry alertEntry = getHeadsUpEntry(key);
        if (alert && alertEntry != null) {
            setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(alertEntry.mEntry));
        HeadsUpEntry headsUpEntry = getHeadsUpEntry(key);
        if (alert && headsUpEntry != null) {
            setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUpEntry.mEntry));
        }
    }