From 185e9c2562568f9b2e0fb70fad6926b30e60b968 Mon Sep 17 00:00:00 2001 From: Kent Persson Date: Wed, 10 Dec 2014 16:40:13 +0100 Subject: [PATCH] Fix NPE in BaseStatusbar in onListenerConnected If NotificationListenerService is not bound the getActiveNotifications function will return null. This will result in a Nullpointer exception in BaseStatusbar onListenerConnected if it is called. A Nullpointer check was added in onListenerConnected to avoid this Nullpointer exception. Change-Id: I0aec040f11101e8f7b5863879b3774dc2bb6ce2b --- .../src/com/android/systemui/statusbar/BaseStatusBar.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 9ff86ebf88aad..35362e0369c09 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -442,6 +442,10 @@ public abstract class BaseStatusBar extends SystemUI implements public void onListenerConnected() { if (DEBUG) Log.d(TAG, "onListenerConnected"); final StatusBarNotification[] notifications = getActiveNotifications(); + if (notifications == null) { + Log.w(TAG, "onListenerConnected unable to get active notifications."); + return; + } final RankingMap currentRanking = getCurrentRanking(); mHandler.post(new Runnable() { @Override