Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 542bbca3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Catch SecurityException from NoMan to workaround possible race...

Merge "Catch SecurityException from NoMan to workaround possible race condition" into ub-launcher3-dorval-polish
parents 52ff3258 f423f0a6
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -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;
            }