Merge "Add carrier config to hide merge button for IMS conference" am: b0bd3b756b am: 1b42729957 am: 412ddbcedd
am: c1e278150d

Change-Id: Ida0544d24427a033f1dcf8d138e08668d01f0c13
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index d0af44f..b27d583 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -79,6 +79,7 @@
         private boolean mIsVideoPresenceSupported;
         private boolean mIsVideoPauseSupported;
         private boolean mIsMergeCallSupported;
+        private boolean mIsMergeImsCallSupported;
         private boolean mIsVideoConferencingSupported;
         private boolean mIsMergeOfWifiCallsAllowedWhenVoWifiOff;
 
@@ -215,6 +216,7 @@
                 instantLetteringExtras = getPhoneAccountExtras();
             }
             mIsMergeCallSupported = isCarrierMergeCallSupported();
+            mIsMergeImsCallSupported = isCarrierMergeImsCallSupported();
             mIsVideoConferencingSupported = isCarrierVideoConferencingSupported();
             mIsMergeOfWifiCallsAllowedWhenVoWifiOff =
                     isCarrierMergeOfWifiCallsAllowedWhenVoWifiOff();
@@ -333,6 +335,17 @@
         }
 
         /**
+         * Determines from carrier config whether merging IMS calls is supported.
+         *
+         * @return {@code true} if merging IMS calls is supported, {@code false} otherwise.
+         */
+        private boolean isCarrierMergeImsCallSupported() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b.getBoolean(CarrierConfigManager.KEY_SUPPORT_IMS_CONFERENCE_CALL_BOOL);
+        }
+
+        /**
          * Determines from carrier config whether emergency video calls are supported.
          *
          * @return {@code true} if emergency video calls are allowed, {@code false} otherwise.
@@ -429,6 +442,14 @@
         }
 
         /**
+         * Indicates whether this account supports merging IMS calls (i.e. conferencing).
+         * @return {@code true} if the account supports merging IMS calls, {@code false} otherwise.
+         */
+        public boolean isMergeImsCallSupported() {
+            return mIsMergeImsCallSupported;
+        }
+
+        /**
          * Indicates whether this account supports video conferencing.
          * @return {@code true} if the account supports video conferencing, {@code false} otherwise.
          */
@@ -594,6 +615,22 @@
     }
 
     /**
+     * Determines if the {@link AccountEntry} associated with a {@link PhoneAccountHandle} supports
+     * merging IMS calls.
+     *
+     * @param handle The {@link PhoneAccountHandle}.
+     * @return {@code True} if merging IMS calls is supported.
+     */
+    boolean isMergeImsCallSupported(PhoneAccountHandle handle) {
+        for (AccountEntry entry : mAccounts) {
+            if (entry.getPhoneAccountHandle().equals(handle)) {
+                return entry.isMergeImsCallSupported();
+            }
+        }
+        return false;
+    }
+
+    /**
      * @return Reference to the {@code TelecomAccountRegistry}'s subscription manager.
      */
     SubscriptionManager getSubscriptionManager() {
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 5ae1a26..b5dcba6 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -1710,20 +1710,24 @@
                 .getInstance(getPhone().getContext());
         boolean isConferencingSupported = telecomAccountRegistry
                 .isMergeCallSupported(phoneAccountHandle);
+        boolean isImsConferencingSupported = telecomAccountRegistry
+                .isMergeImsCallSupported(phoneAccountHandle);
         mIsCarrierVideoConferencingSupported = telecomAccountRegistry
                 .isVideoConferencingSupported(phoneAccountHandle);
         boolean isMergeOfWifiCallsAllowedWhenVoWifiOff = telecomAccountRegistry
                 .isMergeOfWifiCallsAllowedWhenVoWifiOff(phoneAccountHandle);
 
-        Log.v(this, "refreshConferenceSupported : isConfSupp=%b, isVidConfSupp=%b, " +
-                "isMergeOfWifiAllowed=%b, isWifi=%b, isVoWifiEnabled=%b", isConferencingSupported,
+        Log.v(this, "refreshConferenceSupported : isConfSupp=%b, isImsConfSupp=%b, " +
+                "isVidConfSupp=%b, isMergeOfWifiAllowed=%b, " +
+                "isWifi=%b, isVoWifiEnabled=%b",
+                isConferencingSupported, isImsConferencingSupported,
                 mIsCarrierVideoConferencingSupported, isMergeOfWifiCallsAllowedWhenVoWifiOff,
                 isWifi(), isVoWifiEnabled);
         boolean isConferenceSupported = true;
         if (mTreatAsEmergencyCall) {
             isConferenceSupported = false;
             Log.d(this, "refreshConferenceSupported = false; emergency call");
-        } else if (!isConferencingSupported) {
+        } else if (!isConferencingSupported || isIms && !isImsConferencingSupported) {
             isConferenceSupported = false;
             Log.d(this, "refreshConferenceSupported = false; carrier doesn't support conf.");
         } else if (isVideoCall && !mIsCarrierVideoConferencingSupported) {