DO NOT MERGE. Port "respond via SMS message" feature to new Telecomm. (2/4)

Bug: 15275904
Bug: 15196474
Change-Id: I3e2ee62b3e32ad5715457fee1b0e714f88ecea8e
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 434c709..3dd0539 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -29,14 +29,13 @@
 import android.telecomm.CallServiceDescriptor;
 import android.telecomm.CallState;
 import android.telecomm.InCallCall;
-import android.telecomm.CallState;
 
 import com.android.internal.telecomm.IInCallService;
 import com.google.common.collect.ImmutableCollection;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 
 /**
  * Binds to {@link IInCallService} and provides the service to {@link CallsManager} through which it
@@ -92,10 +91,12 @@
             bind();
         } else {
             Log.i(this, "Adding call: %s", call);
-            mCallIdMapper.addCall(call);
-            try {
-                mInCallService.addCall(toInCallCall(call));
-            } catch (RemoteException ignored) {
+            if (mCallIdMapper.getCallId(call) == null) {
+                mCallIdMapper.addCall(call);
+                try {
+                    mInCallService.addCall(toInCallCall(call));
+                } catch (RemoteException ignored) {
+                }
             }
         }
     }
@@ -168,6 +169,11 @@
         updateCall(call);
     }
 
+    @Override
+    public void onCannedSmsResponsesLoaded(Call call) {
+        updateCall(call);
+    }
+
     void bringToForeground(boolean showDialpad) {
         if (mInCallService != null) {
             try {
@@ -308,9 +314,14 @@
             }
         }
 
+        if (call.isRespondViaSmsCapable()) {
+            capabilities |= CallCapabilities.RESPOND_VIA_TEXT;
+        }
+
         return new InCallCall(callId, state, call.getDisconnectCause(), call.getDisconnectMessage(),
-                capabilities, connectTimeMillis, call.getHandle(), call.getGatewayInfo(),
-                descriptor, call.getHandoffCallServiceDescriptor(), parentCallId, childCallIds);
+                call.getCannedSmsResponses(), capabilities, connectTimeMillis, call.getHandle(),
+                call.getGatewayInfo(), descriptor, call.getHandoffCallServiceDescriptor(),
+                parentCallId, childCallIds);
     }
 
 }