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
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 2d1e2a7..6a0706f 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -90,7 +90,6 @@
 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 @@
         // 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 @@
     }
 
     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 @@
                         mFloatingActionButtonMarginBottom);
     }
 
+    private TelephonyManager getTelephonyManager() {
+        return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+    }
+
     @Override
     public boolean isActionBarShowing() {
         return mActionBarController.isActionBarShowing();