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

Commit b2abde5c 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 e91b2247 6fe3701d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public final class GsmCallTracker extends CallTracker {
            throw new CallStateException("cannot dial in current state");
        }

        mPendingMO = new GsmConnection(mPhone.getContext(), checkForTestEmergencyNumber(dialString),
        mPendingMO = new GsmConnection(mPhone, checkForTestEmergencyNumber(dialString),
                this, mForegroundCall);
        mHangupPendingMO = false;

@@ -510,7 +510,7 @@ public final class GsmCallTracker extends CallTracker {
                        return;
                    }
                } else {
                    mConnections[i] = new GsmConnection(mPhone.getContext(), dc, this, i);
                    mConnections[i] = new GsmConnection(mPhone, dc, this, i);

                    Connection hoConnection = getHoConnection(dc);
                    if (hoConnection != null) {
@@ -575,7 +575,7 @@ public final class GsmCallTracker extends CallTracker {
                // we were tracking. Assume dropped call and new call

                mDroppedDuringPoll.add(conn);
                mConnections[i] = new GsmConnection (mPhone.getContext(), dc, this, i);
                mConnections[i] = new GsmConnection (mPhone, dc, this, i);

                if (mConnections[i].getCall() == mRingingCall) {
                    newRinging = mConnections[i];
+30 −5
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ import android.os.AsyncResult;
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.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.Rlog;
import android.telephony.PhoneNumberUtils;
@@ -72,11 +74,15 @@ public class GsmConnection extends Connection {

    private PowerManager.WakeLock mPartialWakeLock;

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

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

    //***** Constants
    static final int PAUSE_DELAY_MILLIS = 3 * 1000;
@@ -93,13 +99,19 @@ public class GsmConnection 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;
            }
        }
    }
@@ -108,8 +120,8 @@ public class GsmConnection extends Connection {

    /** This is probably an MT call that we first saw in a CLCC response */
    /*package*/
    GsmConnection (Context context, DriverCall dc, GsmCallTracker ct, int index) {
        createWakeLock(context);
    GsmConnection (GSMPhone phone, DriverCall dc, GsmCallTracker ct, int index) {
        createWakeLock(phone.getContext());
        acquireWakeLock();

        mOwner = ct;
@@ -128,12 +140,14 @@ public class GsmConnection extends Connection {

        mParent = parentFromDCState (dc.state);
        mParent.attach(this, dc);

        fetchDtmfToneDelay(phone);
    }

    /** This is an MO call, created when dialing */
    /*package*/
    GsmConnection (Context context, String dialString, GsmCallTracker ct, GsmCall parent) {
        createWakeLock(context);
    GsmConnection (GSMPhone phone, String dialString, GsmCallTracker ct, GsmCall parent) {
        createWakeLock(phone.getContext());
        acquireWakeLock();

        mOwner = ct;
@@ -154,6 +168,8 @@ public class GsmConnection extends Connection {

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

        fetchDtmfToneDelay(phone);
    }

    public void dispose() {
@@ -751,6 +767,15 @@ public class GsmConnection extends Connection {
        }
    }

    private void fetchDtmfToneDelay(GSMPhone 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_GSM_DTMF_TONE_DELAY_INT);
        }
    }

    private void log(String msg) {
        Rlog.d(LOG_TAG, "[GSMConn] " + msg);
    }