From cba189344d82753ccce0cc5479771c5a78e85c56 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 28 Jun 2017 14:14:44 -0700 Subject: [PATCH] Ensure notification listener is connected before getting notifications There was a potential race condition where we would try to do a full refresh of notifications before the listener was connected. Now we skip the full refresh if we aren't connected, which is fine because we also do a full refresh in onListenerConnected() anyway. Bug: 62107069 Change-Id: I2fe4f49eb8a840230d32034be11fe7765a366e75 --- .../android/launcher3/notification/NotificationListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java index baaa66aeab..8121fd55fb 100644 --- a/src/com/android/launcher3/notification/NotificationListener.java +++ b/src/com/android/launcher3/notification/NotificationListener.java @@ -127,8 +127,9 @@ public class NotificationListener extends NotificationListenerService { } sNotificationsChangedListener = listener; - if (sNotificationListenerInstance != null) { - sNotificationListenerInstance.onNotificationFullRefresh(); + NotificationListener notificationListener = getInstanceIfConnected(); + if (notificationListener != null) { + notificationListener.onNotificationFullRefresh(); } }