Filter external calls when InCallService doesn't support them.

Use TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS metadata to check
whether an InCallService supports external calls.  Will only send
external calls to an InCallService which has correct Metadata to indicate
that it wants to be informed of external calls.

This required some changes to how InCallController keeps track of the
incallservices.  I have added an InCallServiceInfo class which tracks
the component name of an ICS as well as whether it supports external calls.

The change to CallsManager#getFirstCallWithState and getNumCallsWithSate
ensures that when TelecomServiceImpl checks to see if there are ongoing
calls it doesn't consider external calls when checking if there is an
ongoing call, and also when determining if room needs to be made for a
call.

Bug: 27458894
Change-Id: I69652877332be8527fb16a38c692b6f51a92e469
diff --git a/src/com/android/server/telecom/BluetoothPhoneServiceImpl.java b/src/com/android/server/telecom/BluetoothPhoneServiceImpl.java
index 23a10f8..cd3abe0 100644
--- a/src/com/android/server/telecom/BluetoothPhoneServiceImpl.java
+++ b/src/com/android/server/telecom/BluetoothPhoneServiceImpl.java
@@ -291,11 +291,17 @@
     public CallsManagerListener mCallsManagerListener = new CallsManagerListenerBase() {
         @Override
         public void onCallAdded(Call call) {
+            if (call.isExternalCall()) {
+                return;
+            }
             updateHeadsetWithCallState(false /* force */);
         }
 
         @Override
         public void onCallRemoved(Call call) {
+            if (call.isExternalCall()) {
+                return;
+            }
             mClccIndexMap.remove(call);
             updateHeadsetWithCallState(false /* force */);
         }
@@ -318,6 +324,9 @@
 
         @Override
         public void onCallStateChanged(Call call, int oldState, int newState) {
+            if (call.isExternalCall()) {
+                return;
+            }
             // If a call is being put on hold because of a new connecting call, ignore the
             // CONNECTING since the BT state update needs to send out the numHeld = 1 + dialing
             // state atomically.
@@ -343,6 +352,9 @@
 
         @Override
         public void onIsConferencedChanged(Call call) {
+            if (call.isExternalCall()) {
+                return;
+            }
             /*
              * Filter certain onIsConferencedChanged callbacks. Unfortunately this needs to be done
              * because conference change events are not atomic and multiple callbacks get fired