am 004cc72e: Merge "Fix projection columns for FDN import from contact." into mnc-dev

* commit '004cc72e4fa5f07d54a3aa3cece417f8dc8511b6':
  Fix projection columns for FDN import from contact.
diff --git a/res/values-gu-rIN/strings.xml b/res/values-gu-rIN/strings.xml
index 86f2712..ec588e1 100644
--- a/res/values-gu-rIN/strings.xml
+++ b/res/values-gu-rIN/strings.xml
@@ -134,7 +134,7 @@
   <string-array name="clir_display_values">
     <item msgid="5560134294467334594">"નેટવર્ક ડિફોલ્ટ"</item>
     <item msgid="7876195870037833661">"નંબર છુપાવો"</item>
-    <item msgid="1108394741608734023">"નંબર બતાવો"</item>
+    <item msgid="1108394741608734023">"નંબર દર્શાવો"</item>
   </string-array>
     <string name="vm_changed" msgid="380744030726254139">"વૉઇસમેઇલ નંબર બદલ્યો."</string>
     <string name="vm_change_failed" msgid="3352934863246208918">"વૉઇસમેઇલ નંબર બદલી શકાયો નથી.\nજો આ સમસ્યા ચાલુ રહે છે, તો તમારા કેરિઅરનો સંપર્ક કરો."</string>
diff --git a/res/values-sq-rAL/strings.xml b/res/values-sq-rAL/strings.xml
index 4931375..a72b176 100644
--- a/res/values-sq-rAL/strings.xml
+++ b/res/values-sq-rAL/strings.xml
@@ -125,7 +125,7 @@
     <string name="reverting_settings" msgid="4752151682666912828">"Po rikthen cilësimet…"</string>
     <string name="response_error" msgid="6674110501330139405">"Përgjigje e papritur nga rrjeti."</string>
     <string name="exception_error" msgid="7027667130619518211">"Gabim në rrjet ose në kartën SIM."</string>
-    <string name="fdn_check_failure" msgid="18200614306525434">"Cilësimi për numrat me telefonim të përzgjedhur të aplikacionit të telefonit tënd u aktivizua. Si rezultat, disa funksione që kanë të bëjnë me telefonimin nuk funksionojnë."</string>
+    <string name="fdn_check_failure" msgid="18200614306525434">"Cilësimet e numrave fiks të aplikacionit të telefonit tënd janë aktivizuar. Si rezultat, disa funksione që lidhen me telefonatën nuk funksionojnë."</string>
     <string name="radio_off_error" msgid="2304459933248513376">"Aktivizo radion para se të shohësh këto cilësime."</string>
     <string name="close_dialog" msgid="2365884406356986917">"Në rregull"</string>
     <string name="enable" msgid="7248657275000173526">"Aktivizo"</string>
diff --git a/res/values-ta-rIN/strings.xml b/res/values-ta-rIN/strings.xml
index 5b2a405..d8c43b5 100644
--- a/res/values-ta-rIN/strings.xml
+++ b/res/values-ta-rIN/strings.xml
@@ -100,19 +100,19 @@
     <string name="sum_cfu_enabled_indicator" msgid="4014187342724130197">"எல்லா அழைப்புகளையும் பகிர்"</string>
     <string name="sum_cfu_enabled" msgid="2450052502198827927">"<xliff:g id="PHONENUMBER">{0}</xliff:g> க்கு எல்லா அழைப்புகளையும் பகிர்"</string>
     <string name="sum_cfu_enabled_no_number" msgid="6591985777096823616">"எண் கிடைக்கவில்லை"</string>
-    <string name="sum_cfu_disabled" msgid="8384177689501334080">"முடக்கத்தில்"</string>
+    <string name="sum_cfu_disabled" msgid="8384177689501334080">"முடக்கு"</string>
     <string name="labelCFB" msgid="6139853033106283172">"பிஸியாக இருக்கும்போது"</string>
-    <string name="messageCFB" msgid="3711089705936187129">"பிஸியாக இருக்கும்போது:"</string>
+    <string name="messageCFB" msgid="3711089705936187129">"பிஸியாக இருக்கும்போது இதில்"</string>
     <string name="sum_cfb_enabled" msgid="5984198104833116690">"<xliff:g id="PHONENUMBER">{0}</xliff:g> க்குப் பகிர்"</string>
-    <string name="sum_cfb_disabled" msgid="4913145177320506827">"முடக்கத்தில்"</string>
+    <string name="sum_cfb_disabled" msgid="4913145177320506827">"முடக்கு"</string>
     <string name="disable_cfb_forbidden" msgid="3506984333877998061">"மொபைல் பிஸியாக இருக்கும்போது, அழைப்பு பகிர்தலை முடக்குவதை ஆபரேட்டர் ஆதரிக்கவில்லை."</string>
     <string name="labelCFNRy" msgid="1736067178393744351">"பதிலளிக்காமல் இருக்கும்போது"</string>
-    <string name="messageCFNRy" msgid="672317899884380374">"பதிலளிக்காதபோது:"</string>
+    <string name="messageCFNRy" msgid="672317899884380374">"பதிலளிக்காதபோது இதில்"</string>
     <string name="sum_cfnry_enabled" msgid="6955775691317662910">"<xliff:g id="PHONENUMBER">{0}</xliff:g> க்குப் பகிர்"</string>
-    <string name="sum_cfnry_disabled" msgid="3884684060443538097">"முடக்கத்தில்"</string>
+    <string name="sum_cfnry_disabled" msgid="3884684060443538097">"முடக்கு"</string>
     <string name="disable_cfnry_forbidden" msgid="4308233959150658058">"பதிலளிக்காமல் இருக்கும்போது, அழைப்பு பகிர்தலை முடக்குவதை ஆபரேட்டர் ஆதரிக்கவில்லை."</string>
     <string name="labelCFNRc" msgid="2614827454402079766">"தொடர்புகொள்ள முடியாமல் இருக்கும்போது"</string>
-    <string name="messageCFNRc" msgid="6380695421020295119">"தொடர்பு கிடைக்காதபோது:"</string>
+    <string name="messageCFNRc" msgid="6380695421020295119">"தொடர்பு கிடைக்காதபோது இதில்"</string>
     <string name="sum_cfnrc_enabled" msgid="7010898346095497421">"<xliff:g id="PHONENUMBER">{0}</xliff:g> க்குப் பகிர்"</string>
     <string name="sum_cfnrc_disabled" msgid="7222141261321276464">"முடக்கப்பட்டது"</string>
     <string name="disable_cfnrc_forbidden" msgid="5646361343094064333">"மொபைல் தொடர்புகொள்ள முடியாத இடத்தில் இருக்கும்போது, அழைப்பு பகிர்தலை முடக்குவதை ஆபரேட்டர் ஆதரிக்கவில்லை."</string>
@@ -132,7 +132,7 @@
     <string name="disable" msgid="4678348128118573672">"முடக்கு"</string>
     <string name="change_num" msgid="239476305819844391">"புதுப்பி"</string>
   <string-array name="clir_display_values">
-    <item msgid="5560134294467334594">"நெட்வொர்க் பொருத்து"</item>
+    <item msgid="5560134294467334594">"நெட்வொர்க் இயல்பு"</item>
     <item msgid="7876195870037833661">"எண்ணை மறை"</item>
     <item msgid="1108394741608734023">"எண்ணைக் காட்டு"</item>
   </string-array>
@@ -370,7 +370,7 @@
     <string name="fdn_failed" msgid="540018079008319747">"FDN செயல்பாடு தோல்வி."</string>
     <string name="simContacts_emptyLoading" msgid="2203331234764498011">"சிம் கார்டில் இருப்பதைப் படிக்கிறது…"</string>
     <string name="simContacts_empty" msgid="5270660846489561932">"சிம் கார்டில் தொடர்புகள் இல்லை."</string>
-    <string name="simContacts_title" msgid="1861472842524839921">"ஏற்ற தொடர்புகளைத் தேர்ந்தெடு"</string>
+    <string name="simContacts_title" msgid="1861472842524839921">"இறக்குமதிக்கு தொடர்புகளைத் தேர்ந்தெடுக்கவும்"</string>
     <string name="simContacts_airplaneMode" msgid="5254946758982621072">"SIM கார்டிலிருந்து தொடர்புகளை இறக்க, விமானப் பயன்முறையை முடக்கவும்."</string>
     <string name="enable_pin" msgid="5422767284133234860">"சிம்மின் பின்னை இயக்கு/முடக்கு"</string>
     <string name="change_pin" msgid="9174186126330785343">"சிம்மின் பின்னை மாற்று"</string>
@@ -379,7 +379,7 @@
     <string name="newPinLabel" msgid="207488227285336897">"புதிய பின்"</string>
     <string name="confirmPinLabel" msgid="257597715098070206">"புதிய பின்னை உறுதிப்படுத்தவும்"</string>
     <string name="badPin" msgid="8955102849303984935">"உள்ளிட்ட பழைய பின் தவறானது. மீண்டும் முயற்சிக்கவும்."</string>
-    <string name="mismatchPin" msgid="5923253370683071889">"உள்ளிட்ட பின்கள் பொருந்தவில்லை. மீண்டும் முயற்சிக்கவும்."</string>
+    <string name="mismatchPin" msgid="5923253370683071889">"உள்ளிட்ட PINகள் பொருந்தவில்லை. மீண்டும் முயற்சிக்கவும்."</string>
     <string name="invalidPin" msgid="5981171102258684792">"4 இலிருந்து 8 எண்கள் வரையுள்ள பின்னை உள்ளிடவும்."</string>
     <string name="disable_sim_pin" msgid="3419351358300716472">"சிம் பின்னை அழி"</string>
     <string name="enable_sim_pin" msgid="4845145659651484248">"சிம் பின்னை அமை"</string>
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 8273e1e..39a7386 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2699,7 +2699,7 @@
      * {@hide}
      * Returns the IMS Registration Status
      */
-    public boolean isWifiCallingEnabled() {
+    public boolean isWifiCallingAvailable() {
         return mPhone.isWifiCallingEnabled();
     }
 
@@ -2707,10 +2707,17 @@
      * {@hide}
      * Returns the IMS Registration Status
      */
-    public boolean isVolteEnabled() {
+    public boolean isVolteAvailable() {
         return mPhone.isVolteEnabled();
     }
 
+    /*
+     * {@hide} Returns the IMS Registration Status
+     */
+    public boolean isVideoTelephonyAvailable() {
+        return mPhone.isVideoEnabled();
+    }
+
     private boolean canReadPhoneState(String callingPackage, String message) {
         try {
             mApp.enforceCallingPermission(
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 3dbf459..02d057f 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -32,6 +32,7 @@
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.imsphone.ImsPhoneConnection;
 import com.android.phone.PhoneUtils;
 import com.android.phone.R;
@@ -604,6 +605,7 @@
 
         participant.removeConnectionListener(mParticipantListener);
         mConferenceParticipantConnections.remove(participant.getUserEntity());
+        mTelephonyConnectionService.removeConnection(participant);
     }
 
     /**
@@ -651,7 +653,12 @@
 
             PhoneAccountHandle phoneAccountHandle =
                     PhoneUtils.makePstnPhoneAccountHandle(mConferenceHost.getPhone());
-            mTelephonyConnectionService.addExistingConnection(phoneAccountHandle, mConferenceHost);
+            if (mConferenceHost.getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
+                GsmConnection c = new GsmConnection(originalConnection);
+                c.updateState();
+                mTelephonyConnectionService.addExistingConnection(phoneAccountHandle, c);
+                mTelephonyConnectionService.addConnectionToConferenceController(c);
+            } // CDMA case not applicable for SRVCC
             mConferenceHost.removeConnectionListener(mConferenceHostListener);
             mConferenceHost.removeTelephonyConnectionListener(mTelephonyConnectionListener);
             mConferenceHost = null;
diff --git a/src/com/android/services/telephony/TelephonyConferenceController.java b/src/com/android/services/telephony/TelephonyConferenceController.java
index 2af10a6..93b94aa 100644
--- a/src/com/android/services/telephony/TelephonyConferenceController.java
+++ b/src/com/android/services/telephony/TelephonyConferenceController.java
@@ -17,6 +17,7 @@
 package com.android.services.telephony;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -29,6 +30,7 @@
 import android.telecom.Connection;
 import android.telecom.DisconnectCause;
 import android.telecom.PhoneAccountHandle;
+import com.android.phone.PhoneUtils;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.gsm.GsmConnection;
@@ -46,6 +48,8 @@
     private final Connection.Listener mConnectionListener = new Connection.Listener() {
         @Override
         public void onStateChanged(Connection c, int state) {
+            Log.v(this, "onStateChange triggered in Conf Controller : connection = "+ c
+                 + " state = " + state);
             recalculate();
         }
 
@@ -65,6 +69,7 @@
     private final List<TelephonyConnection> mTelephonyConnections = new ArrayList<>();
 
     private final TelephonyConnectionService mConnectionService;
+    private boolean mTriggerRecalculate = false;
 
     public TelephonyConferenceController(TelephonyConnectionService connectionService) {
         mConnectionService = connectionService;
@@ -73,6 +78,11 @@
     /** The TelephonyConference connection object. */
     private TelephonyConference mTelephonyConference;
 
+    boolean shouldRecalculate() {
+        Log.d(this, "shouldRecalculate is " + mTriggerRecalculate);
+        return mTriggerRecalculate;
+    }
+
     void add(TelephonyConnection connection) {
         mTelephonyConnections.add(connection);
         connection.addConnectionListener(mConnectionListener);
@@ -82,11 +92,10 @@
     void remove(Connection connection) {
         connection.removeConnectionListener(mConnectionListener);
         mTelephonyConnections.remove(connection);
-
         recalculate();
     }
 
-    private void recalculate() {
+    void recalculate() {
         recalculateConference();
         recalculateConferenceable();
     }
@@ -183,6 +192,21 @@
         Log.d(this, "Recalculate conference calls %s %s.",
                 mTelephonyConference, conferencedConnections);
 
+        // Check if all conferenced connections are in Connection Service
+        boolean allConnInService = true;
+        Collection<Connection> allConnections = mConnectionService.getAllConnections();
+        for (Connection connection : conferencedConnections) {
+            Log.v (this, "Finding connection in Connection Service for " + connection);
+            if (!allConnections.contains(connection)) {
+                allConnInService = false;
+                Log.v(this, "Finding connection in Connection Service Failed");
+                break;
+            }
+        }
+
+        Log.d(this, "Is there a match for all connections in connection service " +
+            allConnInService);
+
         // If this is a GSM conference and the number of connections drops below 2, we will
         // terminate the conference.
         if (numGsmConnections < 2) {
@@ -204,35 +228,47 @@
                         mTelephonyConference.removeConnection(connection);
                     }
                 }
-
-                // Add any new ones
-                for (Connection connection : conferencedConnections) {
-                    if (!existingConnections.contains(connection)) {
-                        mTelephonyConference.addConnection(connection);
+                if (allConnInService) {
+                    mTriggerRecalculate = false;
+                    // Add any new ones
+                    for (Connection connection : conferencedConnections) {
+                        if (!existingConnections.contains(connection)) {
+                            mTelephonyConference.addConnection(connection);
+                        }
                     }
+                } else {
+                    Log.d(this, "Trigger recalculate later");
+                    mTriggerRecalculate = true;
                 }
             } else {
-                mTelephonyConference = new TelephonyConference(null);
-
-                for (Connection connection : conferencedConnections) {
-                    Log.d(this, "Adding a connection to a conference call: %s %s",
-                            mTelephonyConference, connection);
-                    mTelephonyConference.addConnection(connection);
+                if (allConnInService) {
+                    mTriggerRecalculate = false;
+                    mTelephonyConference = new TelephonyConference(null);
+                    for (Connection connection : conferencedConnections) {
+                        Log.d(this, "Adding a connection to a conference call: %s %s",
+                                mTelephonyConference, connection);
+                        mTelephonyConference.addConnection(connection);
+                    }
+                    mConnectionService.addConference(mTelephonyConference);
+                } else {
+                    Log.d(this, "Trigger recalculate later");
+                    mTriggerRecalculate = true;
                 }
-
-                mConnectionService.addConference(mTelephonyConference);
             }
-
-            // Set the conference state to the same state as its child connections.
-            Connection conferencedConnection = mTelephonyConference.getPrimaryConnection();
-            if (conferencedConnection != null) {
-                switch (conferencedConnection.getState()) {
-                    case Connection.STATE_ACTIVE:
-                        mTelephonyConference.setActive();
-                        break;
-                    case Connection.STATE_HOLDING:
-                        mTelephonyConference.setOnHold();
-                        break;
+            if (mTelephonyConference != null) {
+                Connection conferencedConnection = mTelephonyConference.getPrimaryConnection();
+                Log.v(this, "Primary Conferenced connection is " + conferencedConnection);
+                if (conferencedConnection != null) {
+                    switch (conferencedConnection.getState()) {
+                        case Connection.STATE_ACTIVE:
+                            Log.v(this, "Setting conference to active");
+                            mTelephonyConference.setActive();
+                            break;
+                        case Connection.STATE_HOLDING:
+                            Log.v(this, "Setting conference to hold");
+                            mTelephonyConference.setOnHold();
+                            break;
+                    }
                 }
             }
         }
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index cbe7c0a..6c25fc1 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -21,6 +21,7 @@
 import android.graphics.drawable.Icon;
 import android.net.Uri;
 import android.os.AsyncResult;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.telecom.CallAudioState;
@@ -32,11 +33,15 @@
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Connection.PostDialListener;
+import com.android.internal.telephony.gsm.SuppServiceNotification;
+
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.imsphone.ImsPhoneConnection;
 import com.android.phone.R;
 
 import java.lang.Override;
+import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
@@ -53,6 +58,8 @@
     private static final int MSG_DISCONNECT = 4;
     private static final int MSG_MULTIPARTY_STATE_CHANGED = 5;
     private static final int MSG_CONFERENCE_MERGE_FAILED = 6;
+    private static final int MSG_SUPP_SERVICE_NOTIFY = 7;
+    private SuppServiceNotification mSsNotification = null;
 
     private final Handler mHandler = new Handler() {
         @Override
@@ -108,6 +115,24 @@
                 case MSG_CONFERENCE_MERGE_FAILED:
                     notifyConferenceMergeFailed();
                     break;
+                case MSG_SUPP_SERVICE_NOTIFY:
+                    Log.v(TelephonyConnection.this, "MSG_SUPP_SERVICE_NOTIFY on phoneId : "
+                            +getPhone().getPhoneId());
+                    if (msg.obj != null && ((AsyncResult) msg.obj).result != null) {
+                        mSsNotification =
+                                (SuppServiceNotification)((AsyncResult) msg.obj).result;
+                        if (mOriginalConnection != null && mSsNotification.history != null) {
+                            Bundle extras = mOriginalConnection.getExtras();
+                            if (extras != null) {
+                                Log.v(TelephonyConnection.this,
+                                        "Updating call history info in extras.");
+                                extras.putStringArrayList(EXTRA_CALL_HISTORY_INFO,
+                                        new ArrayList(Arrays.asList(mSsNotification.history)));
+                                setExtras(extras);
+                            }
+                        }
+                    }
+                    break;
             }
         }
     };
@@ -236,6 +261,7 @@
 
     private com.android.internal.telephony.Connection mOriginalConnection;
     private Call.State mOriginalConnectionState = Call.State.IDLE;
+    private Bundle mOriginalConnectionExtras = new Bundle();
 
     private boolean mWasImsConnection;
 
@@ -562,6 +588,7 @@
                 mHandler, MSG_HANDOVER_STATE_CHANGED, null);
         getPhone().registerForRingbackTone(mHandler, MSG_RINGBACK_TONE, null);
         getPhone().registerForDisconnect(mHandler, MSG_DISCONNECT, null);
+        getPhone().registerForSuppServiceNotification(mHandler, MSG_SUPP_SERVICE_NOTIFY, null);
         mOriginalConnection.addPostDialListener(mPostDialListener);
         mOriginalConnection.addListener(mOriginalConnectionListener);
 
@@ -593,6 +620,7 @@
                 getPhone().unregisterForRingbackTone(mHandler);
                 getPhone().unregisterForHandoverStateChanged(mHandler);
                 getPhone().unregisterForDisconnect(mHandler);
+                getPhone().unregisterForSuppServiceNotification(mHandler);
             }
             mOriginalConnection.removePostDialListener(mPostDialListener);
             mOriginalConnection.removeListener(mOriginalConnectionListener);
@@ -707,6 +735,55 @@
         return true;
     }
 
+    protected void updateExtras() {
+        Bundle extras = null;
+        if (mOriginalConnection != null) {
+            extras = mOriginalConnection.getExtras();
+            if (extras != null) {
+                // Check if extras have changed and need updating.
+                if (!areBundlesEqual(mOriginalConnectionExtras, extras)) {
+                    if (Log.DEBUG) {
+                        Log.d(TelephonyConnection.this, "Updating extras:");
+                        for (String key : extras.keySet()) {
+                            Object value = extras.get(key);
+                            if (value instanceof String) {
+                                Log.d(this, "updateExtras Key=" + Log.pii(key) +
+                                             " value=" + Log.pii((String)value));
+                            }
+                        }
+                    }
+                    mOriginalConnectionExtras.clear();
+                    mOriginalConnectionExtras.putAll(extras);
+                } else {
+                    Log.d(this, "Extras update not required");
+                }
+            } else {
+                Log.d(this, "updateExtras extras: " + Log.pii(extras));
+            }
+        }
+    }
+
+    private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) {
+        if (extras == null || newExtras == null) {
+            return extras == newExtras;
+        }
+
+        if (extras.size() != newExtras.size()) {
+            return false;
+        }
+
+        for(String key : extras.keySet()) {
+            if (key != null) {
+                final Object value = extras.get(key);
+                final Object newValue = newExtras.get(key);
+                if (!Objects.equals(value, newValue)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
     void updateState() {
         if (mOriginalConnection == null) {
             return;
@@ -747,6 +824,7 @@
         updateConnectionCapabilities();
         updateAddress();
         updateMultiparty();
+        updateExtras();
     }
 
     /**
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 5848135..0f1730b 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -303,6 +303,13 @@
     }
 
     @Override
+    public void triggerConferenceRecalculate() {
+        if (mTelephonyConferenceController.shouldRecalculate()) {
+            mTelephonyConferenceController.recalculate();
+        }
+    }
+
+    @Override
     public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount,
             ConnectionRequest request) {
         Log.i(this, "onCreateUnknownConnection, request: " + request);
@@ -321,9 +328,16 @@
             allConnections.addAll(ringingCall.getConnections());
         }
         final Call foregroundCall = phone.getForegroundCall();
-        if (foregroundCall.hasConnections()) {
+        if ((foregroundCall.getState() != Call.State.DISCONNECTED)
+                && (foregroundCall.hasConnections())) {
             allConnections.addAll(foregroundCall.getConnections());
         }
+        if (phone.getImsPhone() != null) {
+            final Call imsFgCall = phone.getImsPhone().getForegroundCall();
+            if ((imsFgCall.getState() != Call.State.DISCONNECTED) && imsFgCall.hasConnections()) {
+                allConnections.addAll(imsFgCall.getConnections());
+            }
+        }
         final Call backgroundCall = phone.getBackgroundCall();
         if (backgroundCall.hasConnections()) {
             allConnections.addAll(phone.getBackgroundCall().getConnections());
@@ -333,6 +347,7 @@
         for (com.android.internal.telephony.Connection telephonyConnection : allConnections) {
             if (!isOriginalConnectionKnown(telephonyConnection)) {
                 unknownConnection = telephonyConnection;
+                Log.d(this, "onCreateUnknownConnection: conn = " + unknownConnection);
                 break;
             }
         }