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

Commit 397d80ad authored by Marie Janssen's avatar Marie Janssen Committed by android-build-merger
Browse files

Check exception to prevent crash on invalid URIs

am: eacf8056

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

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

            if (V) Log.v(TAG, "notMgr.cancel called");
        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");
    }
    }
}
}