Log missed call when incoming call is received during outgoing call
setup
Bug: b/171255813
Test: Originate a call, before call is accepted, receive an incoming
call
Ensure incomming call is logged as a missed call

Change-Id: Ifcae2741fdfc86c9ef2ccfe8a32778bf126f0ac8
diff --git a/src/java/com/android/internal/telephony/CallManager.java b/src/java/com/android/internal/telephony/CallManager.java
index 151a4bf..93597ac 100644
--- a/src/java/com/android/internal/telephony/CallManager.java
+++ b/src/java/com/android/internal/telephony/CallManager.java
@@ -27,6 +27,7 @@
 import android.telephony.PhoneStateListener;
 import android.telephony.ServiceState;
 
+import com.android.internal.telephony.imsphone.ImsPhoneConnection;
 import com.android.internal.telephony.sip.SipPhone;
 import com.android.telephony.Rlog;
 
@@ -2087,7 +2088,13 @@
                     if (VDBG) Rlog.d(LOG_TAG, " handleMessage (EVENT_NEW_RINGING_CONNECTION)");
                     Connection c = (Connection) ((AsyncResult) msg.obj).result;
                     int subId = c.getCall().getPhone().getSubId();
-                    if (getActiveFgCallState(subId).isDialing() || hasMoreThanOneRingingCall()) {
+                    boolean incomingRejected = false;
+                    if ((c.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS)
+                            && ((ImsPhoneConnection) c).isIncomingCallAutoRejected()) {
+                        incomingRejected = true;
+                    }
+                    if ((getActiveFgCallState(subId).isDialing() || hasMoreThanOneRingingCall())
+                            && (!incomingRejected)) {
                         try {
                             Rlog.d(LOG_TAG, "silently drop incoming call: " + c.getCall());
                             c.getCall().hangup();