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

Commit 76fab166 authored by Marie Janssen's avatar Marie Janssen Committed by android-build-merger
Browse files

Check exception to prevent crash on invalid URIs

am: 1a311f71

* commit '1a311f71':
  Check exception to prevent crash on invalid URIs

Change-Id: I6c697a50c6078ba89f0f5bd0018ddcf99ef869d2
parents aceaeeaa 1a311f71
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -285,9 +285,17 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
    private void cancelNotification(Context context, Uri uri) {
        NotificationManager notMgr = (NotificationManager)context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (notMgr != null) {
            notMgr.cancel((int)ContentUris.parseId(uri));
            if (V) Log.v(TAG, "notMgr.cancel called");
        if (notMgr == null) return;

        int id = -1;
        try {
          id = (int) ContentUris.parseId(uri);
        } catch (NumberFormatException ex) {
          Log.v(TAG, "Can't parse notification ID from Uri!");
          return;
        }

        notMgr.cancel(id);
        if (V) Log.v(TAG, "notMgr.cancel called");
    }
}