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

Commit 95cc14b9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Catch potential NPE in RingtoneFactory." into sc-dev

parents f696a7f2 12c85c7f
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -75,7 +75,12 @@ public class RingtoneFactory {

        if(ringtoneUri != null && userContext != null) {
            // Ringtone URI is explicitly specified. First, try to create a Ringtone with that.
            ringtone = RingtoneManager.getRingtone(userContext, ringtoneUri, volumeShaperConfig);
            try {
                ringtone = RingtoneManager.getRingtone(userContext, ringtoneUri,
                        volumeShaperConfig);
            } catch (NullPointerException npe) {
                Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
            }
        }
        if(ringtone == null) {
            // Contact didn't specify ringtone or custom Ringtone creation failed. Get default
@@ -91,8 +96,12 @@ public class RingtoneFactory {
            if (defaultRingtoneUri == null) {
                return null;
            }
            try {
                ringtone = RingtoneManager.getRingtone(
                        contextToUse, defaultRingtoneUri, volumeShaperConfig);
            } catch (NullPointerException npe) {
                Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
            }
        }
        if (ringtone != null) {
            ringtone.setAudioAttributes(new AudioAttributes.Builder()