Merge "Fix unknown call logic for multi-endpoint." into nyc-mr1-dev
am: 7e8845b35d

* commit '7e8845b35dae58371f81331033212e76ebc58612':
  Fix unknown call logic for multi-endpoint.

Change-Id: Ie352bab72cbdc80b18b0eb24243253e7d88dfbd9
diff --git a/src/com/android/services/telephony/PstnIncomingCallNotifier.java b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
index b4733dd..47fac6a 100644
--- a/src/com/android/services/telephony/PstnIncomingCallNotifier.java
+++ b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
@@ -312,6 +312,17 @@
         Connection original = telephonyConnection.getOriginalConnection();
         if (original != null && !original.isIncoming()
                 && Objects.equals(original.getAddress(), unknown.getAddress())) {
+            // If the new unknown connection is an external connection, don't swap one with an
+            // actual connection.  This means a call got pulled away.  We want the actual connection
+            // to disconnect.
+            if (unknown instanceof ImsExternalConnection &&
+                    !(telephonyConnection
+                            .getOriginalConnection() instanceof ImsExternalConnection)) {
+                Log.v(this, "maybeSwapWithUnknownConnection - not swapping regular connection " +
+                        "with external connection.");
+                return false;
+            }
+
             telephonyConnection.setOriginalConnection(unknown);
             return true;
         }