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

Commit 939d1cd7 authored by mengsun's avatar mengsun Committed by Adnan Begovic
Browse files

Telecomm: Add support to set ring tone for SIM2

Can set different ring tone for SIM1 and SIM2.

TICKET: CYNGNOS-1752
Change-Id: Ie715e2c2d7e3760f7d0fe9ba2a9ecdafd9a42277
parent 8c2bde13
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;

@@ -50,6 +51,12 @@ class AsyncRingtonePlayer {
    private float mIncrementAmount;
    private float mCurrentIncrementVolume;

    private int mPhoneId = 0;

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

    /**
     * The context.
     */
@@ -220,8 +227,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);
        if (ringtone != null) {
+6 −0
Original line number Diff line number Diff line
@@ -27,8 +27,11 @@ import android.os.Bundle;
import android.os.SystemVibrator;
import android.os.Vibrator;
import android.provider.Settings;

import cyanogenmod.providers.CMSettings;

import android.telephony.SubscriptionManager;

import java.util.LinkedList;
import java.util.List;

@@ -225,6 +228,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(
                        Integer.valueOf(foregroundCall.getTargetPhoneAccount().getId()));
                mRingtonePlayer.setPhoneId(phoneId);
                mRingtonePlayer.play(foregroundCall.getRingtone(), startVolume, rampUpTime);
            } else {
                Log.v(this, "startRingingOrCallWaiting, skipping because volume is 0");