Merge "Support hiding manage IMS conference call button"
am: 592aeeba3c

Change-Id: I1a65a9eec364ad96a0e3b22265fb5db7d3a27bc8
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 06bc06f..49f7afe 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -636,6 +636,11 @@
             return;
         }
 
+        if (parent != null && !parent.isManageImsConferenceCallSupported()) {
+            Log.i(this, "handleConferenceParticipantsUpdate: manage conference is disallowed");
+            return;
+        }
+
         Log.i(this, "handleConferenceParticipantsUpdate: size=%d", participants.size());
 
         // Perform the update in a synchronized manner.  It is possible for the IMS framework to
diff --git a/src/com/android/services/telephony/ImsConferenceController.java b/src/com/android/services/telephony/ImsConferenceController.java
index 501808f..4bae058 100644
--- a/src/com/android/services/telephony/ImsConferenceController.java
+++ b/src/com/android/services/telephony/ImsConferenceController.java
@@ -16,18 +16,17 @@
 
 package com.android.services.telephony;
 
-import com.android.ims.ImsReasonInfo;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneConstants;
-import com.android.phone.PhoneUtils;
-
 import android.telecom.Conference;
+import android.telecom.Conferenceable;
 import android.telecom.Connection;
 import android.telecom.ConnectionService;
 import android.telecom.DisconnectCause;
-import android.telecom.Conferenceable;
 import android.telecom.PhoneAccountHandle;
 
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.phone.PhoneUtils;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -357,6 +356,8 @@
         // from Telecom.  Instead we create a new instance and remove the old one from telecom.
         TelephonyConnection conferenceHostConnection = connection.cloneConnection();
         conferenceHostConnection.setVideoPauseSupported(connection.getVideoPauseSupported());
+        conferenceHostConnection.setManageImsConferenceCallSupported(
+                connection.isManageImsConferenceCallSupported());
 
         PhoneAccountHandle phoneAccountHandle = null;
 
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index da9effc..8963229 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -82,6 +82,7 @@
         private boolean mIsMergeImsCallSupported;
         private boolean mIsVideoConferencingSupported;
         private boolean mIsMergeOfWifiCallsAllowedWhenVoWifiOff;
+        private boolean mIsManageImsConferenceCallSupported;
 
         AccountEntry(Phone phone, boolean isEmergency, boolean isDummy) {
             mPhone = phone;
@@ -239,6 +240,7 @@
             mIsVideoConferencingSupported = isCarrierVideoConferencingSupported();
             mIsMergeOfWifiCallsAllowedWhenVoWifiOff =
                     isCarrierMergeOfWifiCallsAllowedWhenVoWifiOff();
+            mIsManageImsConferenceCallSupported = isCarrierManageImsConferenceCallSupported();
 
             if (isEmergency && mContext.getResources().getBoolean(
                     R.bool.config_emergency_account_emergency_calls_only)) {
@@ -403,6 +405,18 @@
         }
 
         /**
+         * Determines from carrier config whether managing IMS conference calls is supported.
+         *
+         * @return {@code true} if managing IMS conference calls is supported,
+         *         {@code false} otherwise.
+         */
+        private boolean isCarrierManageImsConferenceCallSupported() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b.getBoolean(CarrierConfigManager.KEY_SUPPORT_MANAGE_IMS_CONFERENCE_CALL_BOOL);
+        }
+
+        /**
          * Where a device supports instant lettering and call subjects, retrieves the necessary
          * PhoneAccount extras for those features.
          * @return The {@link PhoneAccount} extras associated with the current subscription.
@@ -484,6 +498,15 @@
         public boolean isMergeOfWifiCallsAllowedWhenVoWifiOff() {
             return mIsMergeOfWifiCallsAllowedWhenVoWifiOff;
         }
+
+        /**
+         * Indicates whether this account supports managing IMS conference calls
+         * @return {@code true} if the account supports managing IMS conference calls,
+         *         {@code false} otherwise.
+         */
+        public boolean isManageImsConferenceCallSupported() {
+            return mIsManageImsConferenceCallSupported;
+        }
     }
 
     private OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
@@ -653,6 +676,24 @@
     }
 
     /**
+     * Determines if the {@link AccountEntry} associated with a {@link PhoneAccountHandle} supports
+     * managing IMS conference calls.
+     *
+     * @param handle The {@link PhoneAccountHandle}.
+     * @return {@code True} if managing IMS conference calls is supported.
+     */
+    boolean isManageImsConferenceCallSupported(PhoneAccountHandle handle) {
+        synchronized (mAccountsLock) {
+            for (AccountEntry entry : mAccounts) {
+                if (entry.getPhoneAccountHandle().equals(handle)) {
+                    return entry.isManageImsConferenceCallSupported();
+                }
+            }
+        }
+        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 d5ff043..26aeaba 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -498,6 +498,12 @@
     private boolean mIsConferenceSupported;
 
     /**
+     * Indicates whether managing conference call is supported after this connection being
+     * a part of a IMS conference.
+     */
+    private boolean mIsManageImsConferenceCallSupported;
+
+    /**
      * Indicates whether the carrier supports video conferencing; captures the current state of the
      * carrier config
      * {@link android.telephony.CarrierConfigManager#KEY_SUPPORT_VIDEO_CONFERENCE_CALL_BOOL}.
@@ -1647,6 +1653,26 @@
     }
 
     /**
+     * Sets whether managing conference call is supported after this connection being a part of a
+     * Ims conference.
+     *
+     * @param isManageImsConferenceCallSupported {@code true} if manage conference calling is
+     *        supported after this connection being a part of a IMS conference,
+     *        {@code false} otherwise.
+     */
+    public void setManageImsConferenceCallSupported(boolean isManageImsConferenceCallSupported) {
+        mIsManageImsConferenceCallSupported = isManageImsConferenceCallSupported;
+    }
+
+    /**
+     * @return {@code true} if manage conference calling is supported after this connection being a
+     * part of a IMS conference.
+     */
+    public boolean isManageImsConferenceCallSupported() {
+        return mIsManageImsConferenceCallSupported;
+    }
+
+    /**
      * Whether the original connection is an IMS connection.
      * @return {@code True} if the original connection is an IMS connection, {@code false}
      *     otherwise.
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index ded2468..f4ee745 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1046,6 +1046,9 @@
             returnConnection.setVideoPauseSupported(
                     TelecomAccountRegistry.getInstance(this).isVideoPauseSupported(
                             phoneAccountHandle));
+            returnConnection.setManageImsConferenceCallSupported(
+                    TelecomAccountRegistry.getInstance(this).isManageImsConferenceCallSupported(
+                            phoneAccountHandle));
         }
         return returnConnection;
     }