Do not display a ringing call when a call is dialing.

http://b/issue?id=3109483

Change-Id: I01a9a0b29a70d849c1089c642f890095674ece18
diff --git a/src/com/android/phone/CallCard.java b/src/com/android/phone/CallCard.java
index 2fe588c..c909f8d 100755
--- a/src/com/android/phone/CallCard.java
+++ b/src/com/android/phone/CallCard.java
@@ -217,7 +217,13 @@
         Call fgCall = cm.getActiveFgCall();
         Call bgCall = cm.getFirstActiveBgCall();
 
-        if (ringingCall.getState() != Call.State.IDLE) {
+        // If the FG call is dialing/alerting, we should display for that call
+        // and ignore the ringing call. This case happens when the telephony
+        // layer rejects the ringing call while the FG call is dialing/alerting,
+        // but the incoming call *does* briefly exist in the DISCONNECTING or
+        // DISCONNECTED state.
+        if ((ringingCall.getState() != Call.State.IDLE)
+                && !fgCall.getState().isDialing()) {
             // A phone call is ringing, call waiting *or* being rejected
             // (ie. another call may also be active as well.)
             updateRingingCall(cm);
diff --git a/src/com/android/phone/InCallTouchUi.java b/src/com/android/phone/InCallTouchUi.java
index babfcde..73c6426 100644
--- a/src/com/android/phone/InCallTouchUi.java
+++ b/src/com/android/phone/InCallTouchUi.java
@@ -242,7 +242,13 @@
         boolean showInCallControls = false;
 
         final Call ringingCall = cm.getFirstActiveRingingCall();
-        if (ringingCall.getState() != Call.State.IDLE) {
+        // If the FG call is dialing/alerting, we should display for that call
+        // and ignore the ringing call. This case happens when the telephony
+        // layer rejects the ringing call while the FG call is dialing/alerting,
+        // but the incoming call *does* briefly exist in the DISCONNECTING or
+        // DISCONNECTED state.
+        if ((ringingCall.getState() != Call.State.IDLE)
+                && !cm.getActiveFgCallState().isDialing()) {
             // A phone call is ringing *or* call waiting.
             if (mAllowIncomingCallTouchUi) {
                 // Watch out: even if the phone state is RINGING, it's