From 1d7ef6a59ae175d1577ca707e2682924a60d341d Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 29 May 2014 21:46:33 -0700 Subject: Update showCallScreen to use Telecomm (5/6) Use TelephonyManager#showCallScreen instead of referencing ITelephony directly. This way TelephonyManager can accurately route the calls to Telecomm instead. Bug: 15008165 Change-Id: Ib674e2e48efaa1cc97d1513dc2c2b27fdb343657 --- src/com/android/dialer/DialtactsActivity.java | 20 +++++++++----------- src/com/android/dialer/dialpad/DialpadFragment.java | 12 +++--------- 2 files changed, 12 insertions(+), 20 deletions(-) (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 2d1e2a723..6a0706f8d 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -90,7 +90,6 @@ import com.android.dialer.widget.ActionBarController; import com.android.dialer.widget.SearchEditTextLayout; import com.android.dialer.widget.SearchEditTextLayout.OnBackButtonClickedListener; import com.android.dialerbind.DatabaseHelperManager; -import com.android.internal.telephony.ITelephony; import java.util.ArrayList; import java.util.List; @@ -750,13 +749,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O // button, go straight to the in-call screen. final boolean callKey = Intent.ACTION_CALL_BUTTON.equals(intent.getAction()); - try { - ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); - if (callKey && phone != null && phone.showCallScreen()) { - return true; - } - } catch (RemoteException e) { - Log.e(TAG, "Failed to handle send while in call", e); + if (callKey) { + getTelephonyManager().showCallScreen(); + return true; } return false; @@ -981,9 +976,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } private boolean phoneIsInUse() { - final TelephonyManager tm = (TelephonyManager) getSystemService( - Context.TELEPHONY_SERVICE); - return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE; + // TODO(santoscordon): Replace with a TelecommService method call. + return getTelephonyManager().getCallState() != TelephonyManager.CALL_STATE_IDLE; } public static Intent getAddNumberToContactIntent(CharSequence text) { @@ -1138,6 +1132,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mFloatingActionButtonMarginBottom); } + private TelephonyManager getTelephonyManager() { + return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + } + @Override public boolean isActionBarShowing() { return mActionBarController.isActionBarShowing(); diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 1adfeb84b..3eedcdaef 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -80,7 +80,6 @@ import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.SpecialCharSequenceMgr; import com.android.dialer.util.DialerUtils; -import com.android.internal.telephony.ITelephony; import com.android.phone.common.CallLogAsync; import com.android.phone.common.HapticFeedback; @@ -216,9 +215,9 @@ public class DialpadFragment extends Fragment * press/depress of the "hookswitch" of a landline phone. Aka "empty flash". * * TODO: Using an intent extra to tell the phone to send this flash is a - * temporary measure. To be replaced with an ITelephony call in the future. + * temporary measure. To be replaced with an Telephony/TelecommManager call in the future. * TODO: Keep in sync with the string defined in OutgoingCallBroadcaster.java - * in Phone app until this is replaced with the ITelephony API. + * in Phone app until this is replaced with the Telephony/Telecomm API. */ private static final String EXTRA_SEND_EMPTY_FLASH = "com.android.phone.extra.SEND_EMPTY_FLASH"; @@ -1373,12 +1372,7 @@ public class DialpadFragment extends Fragment * or "return to call" from the dialpad chooser. */ private void returnToInCallScreen(boolean showDialpad) { - try { - ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); - if (phone != null) phone.showCallScreenWithDialpad(showDialpad); - } catch (RemoteException e) { - Log.w(TAG, "phone.showCallScreenWithDialpad() failed", e); - } + getTelephonyManager().showCallScreenWithDialpad(showDialpad); // Finally, finish() ourselves so that we don't stay on the // activity stack. -- cgit v1.2.3