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

Commit fb3973a9 authored by Scott Warner's avatar Scott Warner Committed by Luca Stefani
Browse files

RingtoneManager: Don't crash if the ringtone doesn't have a numerical ID

When changing the notification sound for some apps with app-provided sounds,
the notification URI doesn't have a numerical ID.
For example, Outlook's email notification URI has the id 'new_email'

Test: m, outlook doesn't crash anymore, test google calendar
Change-Id: Ibf0c6f2f13e1c76ce02784165b97b92e8f7e432c
parent 79b6ad73
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -509,6 +509,7 @@ public class RingtoneManager {
     * @return The position of the {@link Uri}, or -1 if it cannot be found.
     */
    public int getRingtonePosition(Uri ringtoneUri) {
        try {
            if (ringtoneUri == null) return -1;
            final long ringtoneId = ContentUris.parseId(ringtoneUri);

@@ -519,6 +520,9 @@ public class RingtoneManager {
                    return cursor.getPosition();
                }
            }
        } catch (NumberFormatException e) {
            Log.e(TAG, "NumberFormatException while getting ringtone position, returning -1", e);
        }
        return -1;
    }