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

Commit a6f5869d authored by Tony Wickham's avatar Tony Wickham
Browse files

Ignore null notifications

There seems to be an edge case where we can get a null notification in
onNotificationRemoved(); there's nothing actionable about that, so just
ignore it to prevent NPE. Also add null check to onNotificationPosted()
for good measure.

Bug: 69140873
Change-Id: I3586bf435d05aee38b99dffd3d01315b433e8476
parent 2998e432
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -219,6 +219,10 @@ public class NotificationListener extends NotificationListenerService {
    @Override
    public void onNotificationPosted(final StatusBarNotification sbn) {
        super.onNotificationPosted(sbn);
        if (sbn == null) {
            // There is a bug in platform where we can get a null notification; just ignore it.
            return;
        }
        mWorkerHandler.obtainMessage(MSG_NOTIFICATION_POSTED, new NotificationPostedMsg(sbn))
            .sendToTarget();
        if (sStatusBarNotificationsChangedListener != null) {
@@ -244,6 +248,10 @@ public class NotificationListener extends NotificationListenerService {
    @Override
    public void onNotificationRemoved(final StatusBarNotification sbn) {
        super.onNotificationRemoved(sbn);
        if (sbn == null) {
            // There is a bug in platform where we can get a null notification; just ignore it.
            return;
        }
        Pair<PackageUserKey, NotificationKeyData> packageUserKeyAndNotificationKey
            = new Pair<>(PackageUserKey.fromNotification(sbn),
            NotificationKeyData.fromNotification(sbn));