From e372f3297edc3d5bc8f9f69754217b63e74fb1df Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Tue, 24 Sep 2019 13:14:08 -0400 Subject: [PATCH] Fix NPE when updating rankings for pending notifs Only assign rankings to pending notifs if our current RankingMap actually has one for that key. Previously we were assigning blank rankings to those notifs, which was causing an NPE later down the road. Test: atest Bug: 141379517 Change-Id: I1e9b3c33adf75a7082dfe17b4915b0f4966da284 --- .../notification/NotificationEntryManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index b6b149dd049a4..90301c59dc68f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -22,6 +22,7 @@ import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.service.notification.NotificationListenerService; +import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.util.Log; @@ -390,7 +391,7 @@ public class NotificationEntryManager implements } mNotificationData.updateRanking(rankingMap); - NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking(); + Ranking ranking = new Ranking(); rankingMap.getRanking(key, ranking); NotificationEntry entry = new NotificationEntry(notification, ranking); @@ -513,10 +514,11 @@ public class NotificationEntryManager implements if (rankingMap == null) { return; } - NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking(); for (NotificationEntry pendingNotification : mPendingNotifications.values()) { - rankingMap.getRanking(pendingNotification.key, ranking); - pendingNotification.setRanking(ranking); + Ranking ranking = new Ranking(); + if (rankingMap.getRanking(pendingNotification.key(), ranking)) { + pendingNotification.setRanking(ranking); + } } }