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

Commit aa7695ad authored by padarshr's avatar padarshr Committed by Chirayu Desai
Browse files

MediaPlayer: Add multi SIM ringtone support



This change will handle multi-sim queries in
MediaPlayer setDataSource.
Thus, it will ensure to play the correct ringtone
corresponding to the SIM.

(cdesai: Move from SettingsProvider to MediaPlayer for 5.1,
see "3b566b84: Move ringtone redirection to MediaPlayer")
CRs-Fixed: 661216
Ticket: CYNGNOS-314
Change-Id: I7b22c233b9c41669c1ad948b83a7aa2c55442af1
Signed-off-by: default avatarChirayu Desai <chirayudesai1@gmail.com>
parent 522e4994
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -945,6 +945,26 @@ public class MediaPlayer implements SubtitleController.Listener
        return null;
    }

    /**
     * Gets the current ringtone, supports MSIM
     *
     * @param context the Context to use when resolving the Uri
     * @param ringtoneType the type of the tone
     * @param uri the Content URI of the data you want
     * {@hide}
     */
    public Uri getCurrentRingtoneUriByType(Context context, int ringtoneType, Uri uri) {
        Uri soundUri = null;
        if (ringtoneType == RingtoneManager.TYPE_RINGTONE) {
            soundUri = RingtoneManager.getActualRingtoneUriBySubId(context,
                    RingtoneManager.getDefaultRingtoneSubIdByUri(uri));
        } else {
            soundUri = RingtoneManager.getActualDefaultRingtoneUri(context,
                    ringtoneType);
        }
        return soundUri;
    }

    /**
     * Sets the data source as a content Uri.
     *
@@ -978,8 +998,7 @@ public class MediaPlayer implements SubtitleController.Listener
        } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)
                && Settings.AUTHORITY.equals(uri.getAuthority())) {
            // Redirect ringtones to go directly to underlying provider
            uri = RingtoneManager.getActualDefaultRingtoneUri(context,
                    RingtoneManager.getDefaultType(uri));
            uri = getCurrentRingtoneUriByType(context, RingtoneManager.getDefaultType(uri), uri);
            if (uri == null) {
                throw new FileNotFoundException("Failed to resolve default ringtone");
            }