From fca98c42d5783b7d0681f0a147ce4afdcfeac87e Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Fri, 22 May 2015 14:07:54 -0700 Subject: [PATCH] fix Uri.parse NPE in notifier Closes #3241 // FREEBIE --- .../securesms/notifications/MessageNotifier.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index a6444ff649..32cf3f63cc 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -76,6 +76,7 @@ import me.leolin.shortcutbadger.ShortcutBadger; */ public class MessageNotifier { + private static final String TAG = MessageNotifier.class.getSimpleName(); public static final int NOTIFICATION_ID = 1338; @@ -300,10 +301,18 @@ public class MessageNotifier { String ringtone = TextSecurePreferences.getNotificationRingtone(context); - if (ringtone == null) + if (ringtone == null) { + Log.w(TAG, "ringtone preference was null."); return; + } + + Uri uri = Uri.parse(ringtone); + + if (uri == null) { + Log.w(TAG, "couldn't parse ringtone uri " + ringtone); + return; + } - Uri uri = Uri.parse(ringtone); MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.setDataSource(context, uri);