Merge "Overlay swap capability after merge" into lmp-mr1-dev
diff --git a/res/values-mcc310-mnc004/config.xml b/res/values-mcc310-mnc004/config.xml
new file mode 100755
index 0000000..bbe9e7b
--- /dev/null
+++ b/res/values-mcc310-mnc004/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Phone app resources that may need to be customized
+     for different hardware or product builds. -->
+<resources>
+    <!-- Flag indicating if dtmf tone type is enabled -->
+    <bool name="support_swap_after_merge" translatable="false">false</bool>
+</resources>
diff --git a/res/values-mcc311-mnc480/config.xml b/res/values-mcc311-mnc480/config.xml
old mode 100644
new mode 100755
index 7c269e0..df95aa4
--- a/res/values-mcc311-mnc480/config.xml
+++ b/res/values-mcc311-mnc480/config.xml
@@ -19,4 +19,5 @@
 <resources>
     <!-- Flag indicating if dtmf tone type is enabled -->
     <bool name="dtmf_type_enabled">true</bool>
+    <bool name="support_swap_after_merge" translatable="false">false</bool>
 </resources>
diff --git a/res/values/config.xml b/res/values/config.xml
old mode 100644
new mode 100755
index cd82234..881762d
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -149,4 +149,7 @@
 
     <!-- Allows the telephony HFA logic to run even if we're not in setup wizard. -->
     <bool name="config_allow_hfa_outside_of_setup_wizard">true</bool>
+
+    <!-- After a CDMA conference call is merged, the swap button should be displayed. -->
+    <bool name="support_swap_after_merge" translatable="false">true</bool>
 </resources>
diff --git a/src/com/android/services/telephony/CdmaConference.java b/src/com/android/services/telephony/CdmaConference.java
old mode 100644
new mode 100755
index c77557f..5372548
--- a/src/com/android/services/telephony/CdmaConference.java
+++ b/src/com/android/services/telephony/CdmaConference.java
@@ -16,6 +16,8 @@
 
 package com.android.services.telephony;
 
+import android.content.Context;
+import android.content.res.Resources;
 import android.telecom.Conference;
 import android.telecom.Connection;
 import android.telecom.PhoneAccountHandle;
@@ -23,6 +25,8 @@
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
+import com.android.phone.PhoneGlobals;
+import com.android.phone.common.R;
 
 import java.util.List;
 
@@ -82,7 +86,9 @@
         // Can only merge once
         mCapabilities &= ~PhoneCapabilities.MERGE_CONFERENCE;
         // Once merged, swap is enabled.
-        mCapabilities |= PhoneCapabilities.SWAP_CONFERENCE;
+        if (isSwapSupportedAfterMerge()){
+            mCapabilities |= PhoneCapabilities.SWAP_CONFERENCE;
+        }
         updateCapabilities();
         sendFlash();
     }
@@ -149,6 +155,27 @@
         return null;
     }
 
+    /**
+     * Return whether network support swap after merge conference call.
+     *
+     * @return true to support, false not support.
+     */
+    private final boolean isSwapSupportedAfterMerge()
+    {
+        boolean supportSwapAfterMerge = true;
+        Context context = PhoneGlobals.getInstance();
+
+        if (context != null) {
+            Resources r = context.getResources();
+            if (r != null) {
+                supportSwapAfterMerge = r.getBoolean(R.bool.support_swap_after_merge);
+                Log.d(this, "Current network support swap after call merged capability is "
+                        + supportSwapAfterMerge);
+            }
+        }
+        return supportSwapAfterMerge;
+    }
+
     private com.android.internal.telephony.Connection getOriginalConnection(Connection connection) {
         if (connection instanceof CdmaConnection) {
             return ((CdmaConnection) connection).getOriginalConnection();