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

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

Merge "Play DTMF tones when sending DTMF tones during post dial wait."

parents fed42f8a 09eeb592
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ final class Call implements CreateConnectionResponse {
        void onFailedUnknownCall(Call call);
        void onRingbackRequested(Call call, boolean ringbackRequested);
        void onPostDialWait(Call call, String remaining);
        void onPostDialChar(Call call, char nextChar);
        void onConnectionCapabilitiesChanged(Call call);
        void onCallPropertiesChanged(Call call);
        void onParentChanged(Call call);
@@ -110,6 +111,8 @@ final class Call implements CreateConnectionResponse {
        @Override
        public void onPostDialWait(Call call, String remaining) {}
        @Override
        public void onPostDialChar(Call call, char nextChar) {}
        @Override
        public void onConnectionCapabilitiesChanged(Call call) {}
        @Override
        public void onCallPropertiesChanged(Call call) {}
@@ -1011,6 +1014,12 @@ final class Call implements CreateConnectionResponse {
        }
    }

    void onPostDialChar(char nextChar) {
        for (Listener l : mListeners) {
            l.onPostDialChar(this, nextChar);
        }
    }

    void postDialContinue(boolean proceed) {
        mConnectionService.onPostDialContinue(this, proceed);
    }
+38 −1
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import android.telecom.ParcelableConnection;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.CallStateException;
@@ -53,7 +55,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import android.telecom.VideoProfile;

/**
 * Singleton.
@@ -163,6 +164,8 @@ public final class CallsManager extends Call.ListenerBase {
    private InCallTonePlayer mSupervisoryCallHoldTonePlayer = null;
    private String mSubInConversation = null;

    private Runnable mStopTone;

    /** Singleton accessor. */
    static CallsManager getInstance() {
        return sInstance;
@@ -298,6 +301,40 @@ public final class CallsManager extends Call.ListenerBase {
        mInCallController.onPostDialWait(call, remaining);
    }

    @Override
    public void onPostDialChar(final Call call, char nextChar) {
        if (PhoneNumberUtils.is12Key(nextChar)) {
            // Play tone if it is one of the dialpad digits, canceling out the previously queued
            // up stopTone runnable since playing a new tone automatically stops the previous tone.
            if (mStopTone != null) {
                mHandler.removeCallbacks(mStopTone);
            }

            mDtmfLocalTonePlayer.playTone(call, nextChar);

            mStopTone = new Runnable() {
                @Override
                public void run() {
                    // Set a timeout to stop the tone in case there isn't another tone to follow.
                    mDtmfLocalTonePlayer.stopTone(call);
                }
            };
            mHandler.postDelayed(
                    mStopTone,
                    Timeouts.getDelayBetweenDtmfTonesMillis(mContext.getContentResolver()));
        } else if (nextChar == 0 || nextChar == TelecomManager.DTMF_CHARACTER_WAIT ||
                nextChar == TelecomManager.DTMF_CHARACTER_PAUSE) {
            // Stop the tone if a tone is playing, removing any other stopTone callbacks since
            // the previous tone is being stopped anyway.
            if (mStopTone != null) {
                mHandler.removeCallbacks(mStopTone);
            }
            mDtmfLocalTonePlayer.stopTone(call);
        } else {
            Log.w(this, "onPostDialChar: invalid value %d", nextChar);
        }
    }

    @Override
    public void onParentChanged(Call call) {
        // parent-child relationship affects which call should be foreground, so do an update.
+34 −7
Original line number Diff line number Diff line
@@ -80,13 +80,14 @@ final class ConnectionServiceWrapper extends ServiceBinder<IConnectionService> {
    private static final int MSG_SET_CALLER_DISPLAY_NAME = 18;
    private static final int MSG_SET_VIDEO_STATE = 19;
    private static final int MSG_SET_CONFERENCEABLE_CONNECTIONS = 20;
    private static final int MSG_SET_EXTRAS = 21;
    private static final int MSG_SET_DISCONNECTED_WITH_SUPP_NOTIFICATION = 22;
    private static final int MSG_SET_PHONE_ACCOUNT = 23;
    private static final int MSG_SET_CALL_SUBSTATE = 24;
    private static final int MSG_ADD_EXISTING_CONNECTION = 25;
    private static final int MSG_SET_CALL_PROPERTIES = 26;
    private static final int MSG_RESET_CDMA_CONNECT_TIME = 27;
    private static final int MSG_ADD_EXISTING_CONNECTION = 21;
    private static final int MSG_ON_POST_DIAL_CHAR = 22;
    private static final int MSG_SET_EXTRAS = 23;
    private static final int MSG_SET_DISCONNECTED_WITH_SUPP_NOTIFICATION = 24;
    private static final int MSG_SET_PHONE_ACCOUNT = 25;
    private static final int MSG_SET_CALL_SUBSTATE = 26;
    private static final int MSG_SET_CALL_PROPERTIES = 27;
    private static final int MSG_RESET_CDMA_CONNECT_TIME = 28;

    private final Handler mHandler = new Handler() {
        @Override
@@ -285,6 +286,21 @@ final class ConnectionServiceWrapper extends ServiceBinder<IConnectionService> {
                    }
                    break;
                }
                case MSG_ON_POST_DIAL_CHAR: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        call = mCallIdMapper.getCall(args.arg1);
                        if (call != null) {
                            char nextChar = (char) args.argi1;
                            call.onPostDialChar(nextChar);
                        } else {
                            //Log.w(this, "onPostDialChar, unknown call id: %s", args.arg1);
                        }
                    } finally {
                        args.recycle();
                    }
                    break;
                }
                case MSG_QUERY_REMOTE_CALL_SERVICES: {
                    queryRemoteConnectionServices((RemoteServiceCallback) msg.obj);
                    break;
@@ -572,6 +588,17 @@ final class ConnectionServiceWrapper extends ServiceBinder<IConnectionService> {
            }
        }

        @Override
        public void onPostDialChar(String callId, char nextChar) throws RemoteException {
            logIncoming("onPostDialChar %s %s", callId, nextChar);
            if (mCallIdMapper.isValidCallId(callId)) {
                SomeArgs args = SomeArgs.obtain();
                args.arg1 = callId;
                args.argi1 = nextChar;
                mHandler.obtainMessage(MSG_ON_POST_DIAL_CHAR, args).sendToTarget();
            }
        }

        @Override
        public void queryRemoteConnectionServices(RemoteServiceCallback callback) {
            logIncoming("queryRemoteCSs");
+10 −0
Original line number Diff line number Diff line
@@ -52,4 +52,14 @@ public final class Timeouts {
    public static long getDirectToVoicemailMillis(ContentResolver contentResolver) {
        return get(contentResolver, "direct_to_voicemail_ms", 500L);
    }

    /**
     * Returns the amount of time to play each DTMF tone after post dial continue.
     * This timeout allows the current tone to play for a certain amount of time before either being
     * interrupted by the next tone or terminated.
     */
    public static long getDelayBetweenDtmfTonesMillis(ContentResolver contentResolver) {
        return get(contentResolver, "delay_between_dtmf_tones_ms", 300L);
    }

}