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

Commit e4651db9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Telecomm: Add support to set ring tone for SIM2"

parents 036b6d0b d1530840
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.provider.Settings;
import android.telephony.TelephonyManager;

import com.android.internal.util.Preconditions;

@@ -47,6 +48,12 @@ class AsyncRingtonePlayer {
    /** The current ringtone. Only used by the ringtone thread. */
    private Ringtone mRingtone;

    private int mPhoneId = 0;

    void setPhoneId(int phoneId) {
        mPhoneId = phoneId;
    }

    /**
     * The context.
     */
@@ -192,8 +199,15 @@ class AsyncRingtonePlayer {

    private Ringtone getRingtone(Uri ringtoneUri) {
        if (ringtoneUri == null) {
            if (TelephonyManager.getDefault().isMultiSimEnabled()) {
                ringtoneUri = RingtoneManager.getActualRingtoneUriBySubId(mContext, mPhoneId);
                if (ringtoneUri == null) {
                    return null;
                }
            } else {
                ringtoneUri = Settings.System.DEFAULT_RINGTONE_URI;
            }
        }

        Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri);
        ringtone.setStreamType(AudioManager.STREAM_RING);
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.SystemVibrator;
import android.os.Vibrator;
import android.provider.Settings;
import android.telecom.CallState;
import android.telephony.SubscriptionManager;

import java.util.LinkedList;
import java.util.List;
@@ -189,6 +190,9 @@ final class Ringer extends CallsManagerListenerBase {
                // call (for the purposes of direct-to-voicemail), the information about custom
                // ringtones should be available by the time this code executes. We can safely
                // request the custom ringtone from the call and expect it to be current.
                int phoneId = SubscriptionManager.getPhoneId(Long.valueOf(
                        foregroundCall.getTargetPhoneAccount().getId()));
                mRingtonePlayer.setPhoneId(phoneId);
                mRingtonePlayer.play(foregroundCall.getRingtone());
            } else {
                Log.v(this, "startRingingOrCallWaiting, skipping because volume is 0");