Send empty flash for some CDMA carriers for 3way call

Some carrier need a empty flash before the normal one to connect the 3way call

Bug: 17331584
Change-Id: Ie8f774de909056e398972ea460029d903f059fec
diff --git a/src/java/com/android/internal/telephony/CallTracker.java b/src/java/com/android/internal/telephony/CallTracker.java
index 73f14e9..168b20f 100644
--- a/src/java/com/android/internal/telephony/CallTracker.java
+++ b/src/java/com/android/internal/telephony/CallTracker.java
@@ -62,6 +62,7 @@
     protected static final int EVENT_EXIT_ECM_RESPONSE_CDMA        = 14;
     protected static final int EVENT_CALL_WAITING_INFO_CDMA        = 15;
     protected static final int EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA = 16;
+    protected static final int EVENT_THREE_WAY_DIAL_BLANK_FLASH    = 20;
 
     protected void pollCallsWhenSafe() {
         mNeedsPoll = true;
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
index 1f1124e..2f0873c 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
@@ -88,6 +88,7 @@
 
     private boolean mIsEcmTimerCanceled = false;
 
+    private int m3WayCallFlashDelay = 0;
 //    boolean needsPoll;
 
 
@@ -244,8 +245,15 @@
             // Attach the new connection to foregroundCall
             mPendingMO = new CdmaConnection(mPhone.getContext(),
                                 checkForTestEmergencyNumber(dialString), this, mForegroundCall);
-            mCi.sendCDMAFeatureCode(mPendingMO.getAddress(),
-                obtainMessage(EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA));
+            // Some network need a empty flash before sending the normal one
+            m3WayCallFlashDelay = mPhone.getContext().getResources()
+                    .getInteger(com.android.internal.R.integer.config_cdma_3waycall_flash_delay);
+            if (m3WayCallFlashDelay > 0) {
+                mCi.sendCDMAFeatureCode("", obtainMessage(EVENT_THREE_WAY_DIAL_BLANK_FLASH));
+            } else {
+                mCi.sendCDMAFeatureCode(mPendingMO.getAddress(),
+                        obtainMessage(EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA));
+            }
             return mPendingMO;
         }
         return null;
@@ -1021,6 +1029,24 @@
                 }
             break;
 
+            case EVENT_THREE_WAY_DIAL_BLANK_FLASH:
+                ar = (AsyncResult) msg.obj;
+                if (ar.exception == null) {
+                    postDelayed(
+                            new Runnable() {
+                                public void run() {
+                                    if (mPendingMO != null) {
+                                        mCi.sendCDMAFeatureCode(mPendingMO.getAddress(),
+                                                obtainMessage(EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA));
+                                    }
+                                }
+                            }, m3WayCallFlashDelay);
+                } else {
+                    mPendingMO = null;
+                    Rlog.w(LOG_TAG, "exception happened on Blank Flash for 3-way call");
+                }
+            break;
+
             default:{
                throw new RuntimeException("unexpected event not handled");
             }