diff options
author | Adam Cohen <adamcohen@google.com> | 2017-07-14 12:36:30 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2017-07-14 13:15:06 -0700 |
commit | f423f0a6d440836e968f112e295d85eae8f146ca (patch) | |
tree | f1fdc6ba00779b801c7ab299067d851a17f3654e | |
parent | 28032006970703240f4abd34429608abd2358645 (diff) | |
download | android_packages_apps_Trebuchet-f423f0a6d440836e968f112e295d85eae8f146ca.tar.gz android_packages_apps_Trebuchet-f423f0a6d440836e968f112e295d85eae8f146ca.tar.bz2 android_packages_apps_Trebuchet-f423f0a6d440836e968f112e295d85eae8f146ca.zip |
Catch SecurityException from NoMan to workaround possible race condition
b/63636581
Change-Id: Ia06a5be59b2114bda9b4a55ad945fdd832013110
-rw-r--r-- | src/com/android/launcher3/notification/NotificationListener.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java index 8121fd55f..73d89aa18 100644 --- a/src/com/android/launcher3/notification/NotificationListener.java +++ b/src/com/android/launcher3/notification/NotificationListener.java @@ -28,6 +28,7 @@ import android.service.notification.StatusBarNotification; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.ArraySet; +import android.util.Log; import android.util.Pair; import com.android.launcher3.LauncherModel; import com.android.launcher3.config.FeatureFlags; @@ -47,6 +48,8 @@ import java.util.Set; @TargetApi(Build.VERSION_CODES.O) public class NotificationListener extends NotificationListenerService { + public static final String TAG = "NotificationListener"; + private static final int MSG_NOTIFICATION_POSTED = 1; private static final int MSG_NOTIFICATION_REMOVED = 2; private static final int MSG_NOTIFICATION_FULL_REFRESH = 3; @@ -71,9 +74,19 @@ public class NotificationListener extends NotificationListenerService { mUiHandler.obtainMessage(message.what, message.obj).sendToTarget(); break; case MSG_NOTIFICATION_FULL_REFRESH: - final List<StatusBarNotification> activeNotifications = sIsConnected - ? filterNotifications(getActiveNotifications()) - : new ArrayList<StatusBarNotification>(); + List<StatusBarNotification> activeNotifications; + if (sIsConnected) { + try { + activeNotifications = filterNotifications(getActiveNotifications()); + } catch (SecurityException ex) { + Log.e(TAG, "SecurityException: failed to fetch notifications"); + activeNotifications = new ArrayList<StatusBarNotification>(); + + } + } else { + activeNotifications = new ArrayList<StatusBarNotification>(); + } + mUiHandler.obtainMessage(message.what, activeNotifications).sendToTarget(); break; } |