diff options
author | Ihab Awad <ihab@google.com> | 2014-03-19 17:08:34 -0700 |
---|---|---|
committer | Ihab Awad <ihab@google.com> | 2014-03-31 19:56:32 -0700 |
commit | d11c7a03578697637f97e26758ac5bd96c85e967 (patch) | |
tree | 66eddac4e56d33321fd0669f2cdf3ae8227847b7 | |
parent | 965630a9c6ff19c158acd05cb9d2ea285162b7d9 (diff) |
DTMF dialing support in packages/apps/InCallUI
Change-Id: I26084604212645489100aae0fdef3e0abaa5c813
3 files changed, 71 insertions, 37 deletions
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<DialpadPresenter, DialpadPresenter.DialpadUi> implements DialpadPresenter.DialpadUi, View.OnTouchListener, View.OnKeyListener, - View.OnHoverListener, View.OnClickListener { + View.OnHoverListener { private static final float DIALPAD_SLIDE_FRACTION = 1.0f; @@ -314,21 +314,6 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese } @Override - public void onClick(View v) { - final AccessibilityManager accessibilityManager = (AccessibilityManager) - v.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); - // When accessibility is on, simulate press and release to preserve the - // semantic meaning of performClick(). Required for Braille support. - if (accessibilityManager.isEnabled()) { - final int id = v.getId(); - // Checking the press state prevents double activation. - if (!v.isPressed() && mDisplayMap.containsKey(id)) { - getPresenter().processDtmf(mDisplayMap.get(id), true /* timedShortTone */); - } - } - } - - @Override public boolean onHover(View v, MotionEvent event) { // When touch exploration is turned on, lifting a finger while inside // the button's hover target bounds should perform a click action. @@ -551,7 +536,6 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese button.setClickable(true); button.setOnKeyListener(this); button.setOnHoverListener(this); - button.setOnClickListener(this); numberView = (TextView) button.findViewById(R.id.dialpad_key_number); lettersView = (TextView) button.findViewById(R.id.dialpad_key_letters); final String numberString = resources.getString(numberIds[i]); diff --git a/InCallUI/src/com/android/incallui/DialpadPresenter.java b/InCallUI/src/com/android/incallui/DialpadPresenter.java index 8640f8acc..e426a6a18 100644 --- a/InCallUI/src/com/android/incallui/DialpadPresenter.java +++ b/InCallUI/src/com/android/incallui/DialpadPresenter.java @@ -16,14 +16,19 @@ package com.android.incallui; +import android.telecomm.InCallAdapter; import android.telephony.PhoneNumberUtils; +import com.android.services.telephony.common.Call; + /** * Logic for call buttons. */ public class DialpadPresenter extends Presenter<DialpadPresenter.DialpadUi> implements InCallPresenter.InCallStateListener { + private Call mCall; + @Override public void onUiReady(DialpadUi ui) { super.onUiReady(ui); @@ -31,7 +36,8 @@ public class DialpadPresenter extends Presenter<DialpadPresenter.DialpadUi> @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<DialpadPresenter.DialpadUi> * 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<DialpadPresenter.DialpadUi> * 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 @@ -80,6 +80,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); if (null != call) { |