Preventing telecomm intent handling from executing on tablets.

Bug: 17000484
Change-Id: Iaea456f65670068515076d4c64bc1c65d0341d55
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 0e231b0..f6a9b87 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -27,6 +27,7 @@
 import android.telecomm.TelecommManager;
 import android.telecomm.TelecommManager;
 import android.telephony.PhoneNumberUtils;
+import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 
 /**
@@ -47,6 +48,7 @@
  */
 public class CallActivity extends Activity {
     private CallsManager mCallsManager = CallsManager.getInstance();
+    private boolean mIsVoiceCapable;
 
     /**
      * {@inheritDoc}
@@ -58,6 +60,8 @@
     protected void onCreate(Bundle bundle) {
         super.onCreate(bundle);
 
+        mIsVoiceCapable = isVoiceCapable();
+
         // TODO: This activity will be displayed until the next screen which could be
         // the in-call UI and error dialog or potentially a call-type selection dialog.
         // Traditionally, this has been a black screen with a spinner. We need to reevaluate if this
@@ -88,6 +92,12 @@
      * @param intent The intent.
      */
     private void processIntent(Intent intent) {
+        // Ensure call intents are not processed on devices that are not capable of calling.
+        if (!mIsVoiceCapable) {
+            setResult(RESULT_CANCELED);
+            return;
+        }
+
         String action = intent.getAction();
 
         // TODO: Check for non-voice capable devices before reading any intents.
@@ -107,6 +117,7 @@
      * @param intent Call intent containing data about the handle to call.
      */
     private void processOutgoingCallIntent(Intent intent) {
+
         String uriString = intent.getData().getSchemeSpecificPart();
         Uri handle = Uri.fromParts(
                 PhoneNumberUtils.isUriNumber(uriString) ? "sip" : "tel", uriString, null);
@@ -165,4 +176,14 @@
         return (defaultPhoneApp != null
                 && TextUtils.equals(defaultPhoneApp.getPackageName(), packageName));
     }
+
+    /**
+     * Returns whether the device is voice-capable (e.g. a phone vs a tablet).
+     *
+     * @return {@code True} if the device is voice-capable.
+     */
+    private boolean isVoiceCapable() {
+        return getApplicationContext().getResources().getBoolean(
+                com.android.internal.R.bool.config_voice_capable);
+    }
 }