Support Remote call services.

Adds daisy-chaining support for connection services.

Change-Id: Ibb382a6ed6c5042c1b71821d6b537e2f1cb3063f
diff --git a/src/com/android/telecomm/OutgoingCallProcessor.java b/src/com/android/telecomm/OutgoingCallProcessor.java
index 625366f..b8aca14 100644
--- a/src/com/android/telecomm/OutgoingCallProcessor.java
+++ b/src/com/android/telecomm/OutgoingCallProcessor.java
@@ -255,6 +255,7 @@
                 // service from unbinding while we are using it.
                 callService.incrementAssociatedCallCount();
 
+                Log.i(this, "Attempting to call from %s", callService.getDescriptor());
                 callService.call(mCall, new AsyncResultCallback<Boolean>() {
                     @Override
                     public void onResult(Boolean wasCallPlaced, int errorCode, String errorMsg) {
@@ -292,12 +293,17 @@
     // If we are possibly attempting to call a local emergency number, ensure that the
     // plain PSTN call service, if it exists, is attempted first.
     private void adjustCallServiceDescriptorsForEmergency()  {
-        if (shouldProcessAsEmergency(mCall.getHandle())) {
-            for (int i = 0; i < mCallServiceDescriptors.size(); i++) {
+        for (int i = 0; i < mCallServiceDescriptors.size(); i++) {
+            if (shouldProcessAsEmergency(mCall.getHandle())) {
                 if (TelephonyUtil.isPstnCallService(mCallServiceDescriptors.get(i))) {
                     mCallServiceDescriptors.add(0, mCallServiceDescriptors.remove(i));
                     return;
                 }
+            } else {
+                if (mCallServiceDescriptors.get(i).getServiceComponent().getPackageName().equals(
+                        "com.android.telecomm.tests")) {
+                    mCallServiceDescriptors.add(0, mCallServiceDescriptors.remove(i));
+                }
             }
         }
     }