Handle failure to pull an external call.

When a call pull fails, the ImsPhoneConnection representing the pull
attempt needs to be swapped out for the original ImsExternalConnection
which represented the call in its external state.

Bug: 29906222
Change-Id: I4707ef993fd57bc8ce3a8e4f287bcb957642208f
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index d931f32..69bdd07 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -364,6 +364,28 @@
         public void onExitedEcmMode() {
             handleExitedEcmMode();
         }
+
+        /**
+         * Called from {@link ImsPhoneCallTracker} when a request to pull an external call has
+         * failed.
+         * @param externalConnection
+         */
+        @Override
+        public void onCallPullFailed(com.android.internal.telephony.Connection externalConnection) {
+            if (externalConnection == null) {
+                return;
+            }
+
+            Log.i(this, "onCallPullFailed - pull failed; swapping back to call: %s",
+                    externalConnection);
+
+            // Swap the ImsPhoneConnection we used to do the pull for the ImsExternalConnection
+            // which originally represented the call.
+            setOriginalConnection(externalConnection);
+
+            // Set our state to active again since we're no longer pulling.
+            setActiveInternal();
+        }
     };
 
     protected com.android.internal.telephony.Connection mOriginalConnection;