[android] do not use file:// Uris for notification sounds

This causes a FileUriExposedException otherwise.

Closes #1485
This commit is contained in:
Torsten Grote
2019-11-05 12:31:25 -03:00
parent 533e01e881
commit 1574bf35fc

View File

@@ -347,8 +347,10 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
if (currentTime - lastSound > SOUND_DELAY) {
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
if (sound && !StringUtils.isNullOrEmpty(ringtoneUri))
b.setSound(Uri.parse(ringtoneUri));
if (sound && !StringUtils.isNullOrEmpty(ringtoneUri)) {
Uri uri = Uri.parse(ringtoneUri);
if (!"file".equals(uri.getScheme())) b.setSound(uri);
}
b.setDefaults(getDefaults());
lastSound = currentTime;
}
@@ -359,7 +361,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
int defaults = DEFAULT_LIGHTS;
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
if (sound && StringUtils.isNullOrEmpty(ringtoneUri))
if (sound && (StringUtils.isNullOrEmpty(ringtoneUri) ||
"file".equals(Uri.parse(ringtoneUri).getScheme())))
defaults |= DEFAULT_SOUND;
if (settings.getBoolean(PREF_NOTIFY_VIBRATION, true))
defaults |= DEFAULT_VIBRATE;