Play DTMF tones when sending DTMF tones during post dial wait.
Regression from KK -- when adding additional digits to a number limited
with a wait character (";"), the local DTMF player should make those
sounds audible to the caller.
Bug: 18644688
Change-Id: Ib04658316f725146a65b399d3f477791260c3f5a
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index dc65c9e..cfd4641 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -33,6 +33,7 @@
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
+import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import com.android.internal.util.IndentingPrintWriter;
@@ -136,6 +137,8 @@
*/
private Call mForegroundCall;
+ private Runnable mStopTone;
+
/** Singleton accessor. */
static CallsManager getInstance() {
return sInstance;
@@ -264,6 +267,40 @@
}
@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.
updateCallsManagerState();