From d11c7a03578697637f97e26758ac5bd96c85e967 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Wed, 19 Mar 2014 17:08:34 -0700 Subject: DTMF dialing support in packages/apps/InCallUI Change-Id: I26084604212645489100aae0fdef3e0abaa5c813 --- .../src/com/android/incallui/DialpadFragment.java | 18 +------- .../src/com/android/incallui/DialpadPresenter.java | 50 +++++++++++++--------- .../com/android/incallui/InCallServiceImpl.java | 40 +++++++++++++++++ 3 files changed, 71 insertions(+), 37 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/DialpadFragment.java b/InCallUI/src/com/android/incallui/DialpadFragment.java index 236b38c9c..e67fbc594 100644 --- a/InCallUI/src/com/android/incallui/DialpadFragment.java +++ b/InCallUI/src/com/android/incallui/DialpadFragment.java @@ -41,7 +41,7 @@ import java.util.HashMap; */ public class DialpadFragment extends BaseFragment implements DialpadPresenter.DialpadUi, View.OnTouchListener, View.OnKeyListener, - View.OnHoverListener, View.OnClickListener { + View.OnHoverListener { private static final float DIALPAD_SLIDE_FRACTION = 1.0f; @@ -313,21 +313,6 @@ public class DialpadFragment extends BaseFragment implements InCallPresenter.InCallStateListener { + private Call mCall; + @Override public void onUiReady(DialpadUi ui) { super.onUiReady(ui); @@ -31,7 +36,8 @@ public class DialpadPresenter extends Presenter @Override public void onStateChange(InCallPresenter.InCallState state, CallList callList) { - + mCall = callList.getActiveCall(); + Log.d(this, "DialpadPresenter mCall = " + mCall); } /** @@ -39,27 +45,22 @@ public class DialpadPresenter extends Presenter * appropriate DTMF tone, and appending the digit to the EditText * field that displays the DTMF digits sent so far. * - * @see #processDtmf(char, boolean) */ public final void processDtmf(char c) { - processDtmf(c, false); - } - - /** - * Processes the specified digit as a DTMF key, by playing the appropriate - * DTMF tone (or short tone if requested), and appending the digit to the - * EditText field that displays the DTMF digits sent so far. - */ - public final void processDtmf(char c, boolean timedShortTone) { Log.d(this, "Processing dtmf key " + c); // if it is a valid key, then update the display and send the dtmf tone. - if (PhoneNumberUtils.is12Key(c)) { - Log.d(this, "updating display and sending dtmf tone for '" + c + "'"); - - // Append this key to the "digits" widget. - getUi().appendDigitsToField(c); - // Plays the tone through CallCommandService - CallCommandClient.getInstance().playDtmfTone(c, timedShortTone); + if (PhoneNumberUtils.is12Key(c) && mCall != null) { + // Plays the tone through Telecomm + InCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter(); + if (telecommAdapter != null) { + String callId = CallInfoTranslator.getTelecommCallId(mCall); + if (callId != null) { + Log.d(this, "updating display and sending dtmf tone for '" + c + "'"); + // Append this key to the "digits" widget. + getUi().appendDigitsToField(c); + telecommAdapter.playDtmfTone(callId, c); + } + } } else { Log.d(this, "ignoring dtmf request for '" + c + "'"); } @@ -69,8 +70,17 @@ public class DialpadPresenter extends Presenter * Stops the local tone based on the phone type. */ public void stopTone() { - Log.d(this, "stopping remote tone"); - CallCommandClient.getInstance().stopDtmfTone(); + if (mCall != null) { + Log.d(this, "stopping remote tone"); + InCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter(); + if (telecommAdapter != null) { + String callId = CallInfoTranslator.getTelecommCallId(mCall); + if (callId != null) { + Log.d(this, "stopping remote tone: " + callId); + telecommAdapter.stopDtmfTone(callId); + } + } + } } public interface DialpadUi extends Ui { diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java index 7bfeab90e..ca04993e0 100644 --- a/InCallUI/src/com/android/incallui/InCallServiceImpl.java +++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java @@ -79,6 +79,46 @@ public class InCallServiceImpl extends android.telecomm.InCallService { } } + /** {@inheritDoc} */ + @Override protected void setDialing(String callId) { + Call call = CallInfoTranslator.getCall(callId); + if (null != call) { + call.setState(Call.State.DIALING); + CallList.getInstance().onUpdate(call); + } + } + + /** {@inheritDoc} */ + @Override protected void setRinging(String callId) { + Call call = CallInfoTranslator.getCall(callId); + if (null != call) { + call.setState(Call.State.RINGING); + CallList.getInstance().onUpdate(call); + } + } + + /** {@inheritDoc} */ + @Override protected void setPostDial(String callId, String remaining) { + Call call = CallInfoTranslator.getCall(callId); + if (null != call) { + // TODO(ihab): Add post-dial state to user interface + // TODO(ihab: Do the equivalent in the new framework: + // call.setState(Call.State.POST_DIAL); + CallList.getInstance().onUpdate(call); + } + } + + /** {@inheritDoc} */ + @Override protected void setPostDialWait(String callId, String remaining) { + Call call = CallInfoTranslator.getCall(callId); + if (null != call) { + // TODO(ihab): Add post-dial state to user interface + // TODO(ihab): Do the equivalent in the new framework: + // call.setState(Call.State.POST_DIAL_WAIT); + CallList.getInstance().onUpdate(call); + } + } + /** {@inheritDoc} */ @Override protected void setDisconnected(String callId, int disconnectCause) { Call call = CallInfoTranslator.getCall(callId); -- cgit v1.2.3