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

Commit fe333ebe authored by Roshan Pius's avatar Roshan Pius Committed by Android (Google) Code Review
Browse files

Merge "Add delay between DTMF tones to meet carrier spec." into mnc-dr-dev

parents 71ba5719 6bb557b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public final class ImsPhoneCallTracker extends CallTracker {

                    // Normal MT/Unknown call
                    ImsCall imsCall = mImsManager.takeCall(mServiceId, intent, mImsCallListener);
                    ImsPhoneConnection conn = new ImsPhoneConnection(mPhone.getContext(), imsCall,
                    ImsPhoneConnection conn = new ImsPhoneConnection(mPhone, imsCall,
                            ImsPhoneCallTracker.this,
                            (isUnknown? mForegroundCall: mRingingCall), isUnknown);
                    addConnection(conn);
@@ -365,7 +365,7 @@ public final class ImsPhoneCallTracker extends CallTracker {
                }
            }

            mPendingMO = new ImsPhoneConnection(mPhone.getContext(),
            mPendingMO = new ImsPhoneConnection(mPhone,
                    checkForTestEmergencyNumber(dialString), this, mForegroundCall);
        }
        addConnection(mPendingMO);
+30 −5
Original line number Diff line number Diff line
@@ -23,10 +23,12 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.Registrant;
import android.os.SystemClock;
import android.telecom.Log;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
@@ -82,11 +84,15 @@ public class ImsPhoneConnection extends Connection {
    // The cached connect time of the connection when it turns into a conference.
    private long mConferenceConnectTime = 0;

    // The cached delay to be used between DTMF tones fetched from carrier config.
    private int mDtmfToneDelay = 0;

    //***** Event Constants
    private static final int EVENT_DTMF_DONE = 1;
    private static final int EVENT_PAUSE_DONE = 2;
    private static final int EVENT_NEXT_POST_DIAL = 3;
    private static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
    private static final int EVENT_DTMF_DELAY_DONE = 5;

    //***** Constants
    private static final int PAUSE_DELAY_MILLIS = 3 * 1000;
@@ -103,13 +109,19 @@ public class ImsPhoneConnection extends Connection {

            switch (msg.what) {
                case EVENT_NEXT_POST_DIAL:
                case EVENT_DTMF_DONE:
                case EVENT_DTMF_DELAY_DONE:
                case EVENT_PAUSE_DONE:
                    processNextPostDialChar();
                    break;
                case EVENT_WAKE_LOCK_TIMEOUT:
                    releaseWakeLock();
                    break;
                case EVENT_DTMF_DONE:
                    // We may need to add a delay specified by carrier between DTMF tones that are
                    // sent out.
                    mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE),
                            mDtmfToneDelay);
                    break;
            }
        }
    }
@@ -118,9 +130,9 @@ public class ImsPhoneConnection extends Connection {

    /** This is probably an MT call */
    /*package*/
    ImsPhoneConnection(Context context, ImsCall imsCall, ImsPhoneCallTracker ct,
    ImsPhoneConnection(ImsPhone phone, ImsCall imsCall, ImsPhoneCallTracker ct,
           ImsPhoneCall parent, boolean isUnknown) {
        createWakeLock(context);
        createWakeLock(phone.getContext());
        acquireWakeLock();

        mOwner = ct;
@@ -151,13 +163,15 @@ public class ImsPhoneConnection extends Connection {
        mParent = parent;
        mParent.attach(this,
                (mIsIncoming? ImsPhoneCall.State.INCOMING: ImsPhoneCall.State.DIALING));

        fetchDtmfToneDelay(phone);
    }

    /** This is an MO call, created when dialing */
    /*package*/
    ImsPhoneConnection(Context context, String dialString, ImsPhoneCallTracker ct,
    ImsPhoneConnection(ImsPhone phone, String dialString, ImsPhoneCallTracker ct,
            ImsPhoneCall parent) {
        createWakeLock(context);
        createWakeLock(phone.getContext());
        acquireWakeLock();

        mOwner = ct;
@@ -178,6 +192,8 @@ public class ImsPhoneConnection extends Connection {

        mParent = parent;
        parent.attachFake(this, ImsPhoneCall.State.DIALING);

        fetchDtmfToneDelay(phone);
    }

    public void dispose() {
@@ -527,6 +543,15 @@ public class ImsPhoneConnection extends Connection {
        }
    }

    private void fetchDtmfToneDelay(ImsPhone phone) {
        CarrierConfigManager configMgr = (CarrierConfigManager)
                phone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
        PersistableBundle b = configMgr.getConfigForSubId(phone.getSubId());
        if (b != null) {
            mDtmfToneDelay = b.getInt(CarrierConfigManager.KEY_IMS_DTMF_TONE_DELAY_INT);
        }
    }

    @Override
    public int getNumberPresentation() {
        return mNumberPresentation;