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

Commit a4ae7509 authored by Hall Liu's avatar Hall Liu
Browse files

Don't acquire audio focus if no ringtone will play

When the system default ringtone is set to "None", don't acquire audio
focus so as to not interrupt music.

Change-Id: I758df49c954281c91fdeb4f6952b9ccebd0fe1ff
Fix: 33449128
Test: manual testing
parent de6924cd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -120,6 +120,11 @@ public class Ringer {
            return false;
        }

        // Don't ring/acquire focus if there is no ringtone
        if (mRingtoneFactory.getRingtone(foregroundCall) == null) {
            isRingerAudible = false;
        }

        if (isRingerAudible) {
            mRingingCall = foregroundCall;
            Log.addEvent(foregroundCall, LogUtils.Events.START_RINGER);
+12 −3
Original line number Diff line number Diff line
@@ -67,9 +67,18 @@ public class RingtoneFactory {
        if(ringtone == null) {
            // Contact didn't specify ringtone or custom Ringtone creation failed. Get default
            // ringtone for user or profile.
            ringtone = RingtoneManager.getRingtone(
                    hasDefaultRingtoneForUser(userContext) ? userContext : mContext,
                    Settings.System.DEFAULT_RINGTONE_URI);
            Context contextToUse = hasDefaultRingtoneForUser(userContext) ? userContext : mContext;
            Uri defaultRingtoneUri;
            if (UserManager.get(contextToUse).isUserUnlocked(contextToUse.getUserId())) {
                defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(contextToUse,
                        RingtoneManager.TYPE_RINGTONE);
            } else {
                defaultRingtoneUri = Settings.System.DEFAULT_RINGTONE_URI;
            }
            if (defaultRingtoneUri == null) {
                return null;
            }
            ringtone = RingtoneManager.getRingtone(contextToUse, defaultRingtoneUri);
        }
        if (ringtone != null) {
            ringtone.setStreamType(AudioManager.STREAM_RING);