From c168ee38084d2df0170bb4780a0c7c7523f2c836 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 21 Nov 2019 15:40:51 -0800 Subject: [PATCH] Fix NPE Treehugger didn't hit this with the original CL (ag/9721403) but I'm hitting it locally & believe it is the root cause of attached bug. Test: atest NotificationManagerTest (doesn't crash) Bug: 144947853 Bug: 144958550 Change-Id: I3a03097b1e81b81a1847ef46422a052df726eb7d --- .../server/notification/NotificationManagerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 3351bb1eb35b1..3f67e7b28f9ad 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2055,10 +2055,10 @@ public class NotificationManagerService extends SystemService { @Override public void updateAutogroupSummary(String key, boolean needsOngoingFlag) { - String pkg = null; + String pkg; synchronized (mNotificationLock) { NotificationRecord r = mNotificationsByKey.get(key); - pkg = r.sbn.getPackageName(); + pkg = r != null && r.sbn != null ? r.sbn.getPackageName() : null; } boolean isAppForeground = pkg != null && mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND;