diff options
| author | Julia Reynolds <juliacr@google.com> | 2018-04-20 13:33:36 -0400 |
|---|---|---|
| committer | Julia Reynolds <juliacr@google.com> | 2018-04-20 14:46:43 -0400 |
| commit | 94a38b35e907fc560d4beec3bfb78360411609a3 (patch) | |
| tree | deadc401aa7111b217c2417176d3f9127667d714 /core/java/android | |
| parent | 33ecd1bca766416bb8e7d5bd4cdf12cc4d3d6445 (diff) | |
GetActiveNotifications should never return null
Test: runtest systemui-notification
Change-Id: I53e7a4a2a9f05318dd97ffb096658a4f8bcebc8a
Fixes: 70396956
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/service/notification/NotificationListenerService.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index 32737c54bea1..a7d70d01b04a 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -807,7 +807,8 @@ public abstract class NotificationListenerService extends Service { * @return An array of active notifications, sorted in natural order. */ public StatusBarNotification[] getActiveNotifications() { - return getActiveNotifications(null, TRIM_FULL); + StatusBarNotification[] activeNotifications = getActiveNotifications(null, TRIM_FULL); + return activeNotifications != null ? activeNotifications : new StatusBarNotification[0]; } /** @@ -842,7 +843,8 @@ public abstract class NotificationListenerService extends Service { */ @SystemApi public StatusBarNotification[] getActiveNotifications(int trim) { - return getActiveNotifications(null, trim); + StatusBarNotification[] activeNotifications = getActiveNotifications(null, trim); + return activeNotifications != null ? activeNotifications : new StatusBarNotification[0]; } /** @@ -858,7 +860,8 @@ public abstract class NotificationListenerService extends Service { * same order as the key list. */ public StatusBarNotification[] getActiveNotifications(String[] keys) { - return getActiveNotifications(keys, TRIM_FULL); + StatusBarNotification[] activeNotifications = getActiveNotifications(keys, TRIM_FULL); + return activeNotifications != null ? activeNotifications : new StatusBarNotification[0]; } /** @@ -890,6 +893,9 @@ public abstract class NotificationListenerService extends Service { private StatusBarNotification[] cleanUpNotificationList( ParceledListSlice<StatusBarNotification> parceledList) { + if (parceledList == null || parceledList.getList() == null) { + return new StatusBarNotification[0]; + } List<StatusBarNotification> list = parceledList.getList(); ArrayList<StatusBarNotification> corruptNotifications = null; int N = list.size(); |
