Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.ims; |
| 18 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 20 | import android.app.PendingIntent; |
| 21 | import android.content.Context; |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 22 | import android.os.Bundle; |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 23 | import android.os.Handler; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 24 | import android.os.IBinder; |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 25 | import android.os.Looper; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 26 | import android.os.Message; |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 27 | import android.os.Parcel; |
Jonathan Basseri | 2acea6f | 2015-07-01 15:00:38 -0700 | [diff] [blame] | 28 | import android.os.PersistableBundle; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 29 | import android.os.RemoteException; |
Etan Cohen | af55a40 | 2014-09-04 22:34:41 -0700 | [diff] [blame] | 30 | import android.os.SystemProperties; |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 31 | import android.telecom.TelecomManager; |
Junda Liu | e7663c0 | 2015-06-23 11:16:26 -0700 | [diff] [blame] | 32 | import android.telephony.CarrierConfigManager; |
Mohamed Abdalkader | e1453f4 | 2018-01-19 19:48:31 -0800 | [diff] [blame] | 33 | import android.telephony.ims.stub.ImsRegistrationImplBase; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 34 | import android.telephony.Rlog; |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 35 | import android.telephony.SubscriptionManager; |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 36 | import android.telephony.TelephonyManager; |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 37 | import android.telephony.ims.ImsCallProfile; |
| 38 | import android.telephony.ims.ImsReasonInfo; |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 39 | import android.telephony.ims.aidl.IImsConfig; |
| 40 | import android.telephony.ims.aidl.IImsSmsListener; |
| 41 | import android.telephony.ims.feature.CapabilityChangeRequest; |
| 42 | import android.telephony.ims.feature.ImsFeature; |
| 43 | import android.telephony.ims.feature.MmTelFeature; |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 44 | import android.util.Log; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 45 | |
| 46 | import com.android.ims.internal.IImsCallSession; |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 47 | import com.android.ims.internal.IImsEcbm; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 48 | import com.android.ims.internal.IImsMultiEndpoint; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 49 | import com.android.ims.internal.IImsUt; |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 50 | import android.telephony.ims.ImsCallSession; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 51 | import com.android.internal.annotations.VisibleForTesting; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 52 | |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 53 | import java.io.FileDescriptor; |
| 54 | import java.io.PrintWriter; |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 55 | import java.util.ArrayList; |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 56 | import java.util.HashMap; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 57 | import java.util.Set; |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 58 | import java.util.concurrent.ConcurrentLinkedDeque; |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 59 | import java.util.concurrent.CopyOnWriteArraySet; |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 60 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 61 | /** |
| 62 | * Provides APIs for IMS services, such as initiating IMS calls, and provides access to |
| 63 | * the operator's IMS network. This class is the starting point for any IMS actions. |
| 64 | * You can acquire an instance of it with {@link #getInstance getInstance()}.</p> |
| 65 | * <p>The APIs in this class allows you to:</p> |
| 66 | * |
| 67 | * @hide |
| 68 | */ |
| 69 | public class ImsManager { |
Etan Cohen | 19604c0 | 2014-08-11 14:32:57 -0700 | [diff] [blame] | 70 | |
Etan Cohen | af55a40 | 2014-09-04 22:34:41 -0700 | [diff] [blame] | 71 | /* |
| 72 | * Debug flag to override configuration flag |
| 73 | */ |
Etan Cohen | b651fa5 | 2014-10-22 10:51:29 -0700 | [diff] [blame] | 74 | public static final String PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE = "persist.dbg.volte_avail_ovr"; |
| 75 | public static final int PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE_DEFAULT = 0; |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 76 | public static final String PROPERTY_DBG_VT_AVAIL_OVERRIDE = "persist.dbg.vt_avail_ovr"; |
| 77 | public static final int PROPERTY_DBG_VT_AVAIL_OVERRIDE_DEFAULT = 0; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 78 | public static final String PROPERTY_DBG_WFC_AVAIL_OVERRIDE = "persist.dbg.wfc_avail_ovr"; |
| 79 | public static final int PROPERTY_DBG_WFC_AVAIL_OVERRIDE_DEFAULT = 0; |
Meng Wang | 9352c43 | 2016-06-08 14:22:20 -0700 | [diff] [blame] | 80 | public static final String PROPERTY_DBG_ALLOW_IMS_OFF_OVERRIDE = "persist.dbg.allow_ims_off"; |
| 81 | public static final int PROPERTY_DBG_ALLOW_IMS_OFF_OVERRIDE_DEFAULT = 0; |
Etan Cohen | af55a40 | 2014-09-04 22:34:41 -0700 | [diff] [blame] | 82 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 83 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 84 | * The result code to be sent back with the incoming call {@link PendingIntent}. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 85 | * @see #open(MmTelFeature.Listener) |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 86 | */ |
| 87 | public static final int INCOMING_CALL_RESULT_CODE = 101; |
| 88 | |
| 89 | /** |
| 90 | * Key to retrieve the call ID from an incoming call intent. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 91 | * @see #open(MmTelFeature.Listener) |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 92 | */ |
| 93 | public static final String EXTRA_CALL_ID = "android:imsCallID"; |
| 94 | |
| 95 | /** |
| 96 | * Action to broadcast when ImsService is up. |
| 97 | * Internal use only. |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 98 | * @deprecated |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 99 | * @hide |
| 100 | */ |
| 101 | public static final String ACTION_IMS_SERVICE_UP = |
| 102 | "com.android.ims.IMS_SERVICE_UP"; |
| 103 | |
| 104 | /** |
| 105 | * Action to broadcast when ImsService is down. |
| 106 | * Internal use only. |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 107 | * @deprecated |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 108 | * @hide |
| 109 | */ |
| 110 | public static final String ACTION_IMS_SERVICE_DOWN = |
| 111 | "com.android.ims.IMS_SERVICE_DOWN"; |
| 112 | |
| 113 | /** |
Pavel Zhamaitsiak | 0c2f15c | 2015-03-12 15:37:54 -0700 | [diff] [blame] | 114 | * Action to broadcast when ImsService registration fails. |
| 115 | * Internal use only. |
| 116 | * @hide |
| 117 | */ |
| 118 | public static final String ACTION_IMS_REGISTRATION_ERROR = |
| 119 | "com.android.ims.REGISTRATION_ERROR"; |
| 120 | |
| 121 | /** |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 122 | * Part of the ACTION_IMS_SERVICE_UP or _DOWN intents. |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 123 | * A long value; the phone ID corresponding to the IMS service coming up or down. |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 124 | * Internal use only. |
| 125 | * @hide |
| 126 | */ |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 127 | public static final String EXTRA_PHONE_ID = "android:phone_id"; |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 130 | * Action for the incoming call intent for the Phone app. |
| 131 | * Internal use only. |
| 132 | * @hide |
| 133 | */ |
| 134 | public static final String ACTION_IMS_INCOMING_CALL = |
| 135 | "com.android.ims.IMS_INCOMING_CALL"; |
| 136 | |
| 137 | /** |
| 138 | * Part of the ACTION_IMS_INCOMING_CALL intents. |
| 139 | * An integer value; service identifier obtained from {@link ImsManager#open}. |
| 140 | * Internal use only. |
| 141 | * @hide |
| 142 | */ |
| 143 | public static final String EXTRA_SERVICE_ID = "android:imsServiceId"; |
| 144 | |
| 145 | /** |
| 146 | * Part of the ACTION_IMS_INCOMING_CALL intents. |
| 147 | * An boolean value; Flag to indicate that the incoming call is a normal call or call for USSD. |
| 148 | * The value "true" indicates that the incoming call is for USSD. |
| 149 | * Internal use only. |
| 150 | * @hide |
| 151 | */ |
| 152 | public static final String EXTRA_USSD = "android:ussd"; |
| 153 | |
Shriram Ganesh | d3adfad | 2015-05-31 10:06:15 -0700 | [diff] [blame] | 154 | /** |
| 155 | * Part of the ACTION_IMS_INCOMING_CALL intents. |
| 156 | * A boolean value; Flag to indicate whether the call is an unknown |
| 157 | * dialing call. Such calls are originated by sending commands (like |
| 158 | * AT commands) directly to modem without Android involvement. |
| 159 | * Even though they are not incoming calls, they are propagated |
| 160 | * to Phone app using same ACTION_IMS_INCOMING_CALL intent. |
| 161 | * Internal use only. |
| 162 | * @hide |
| 163 | */ |
Anju Mathapati | 9c03379 | 2015-06-16 16:33:16 -0700 | [diff] [blame] | 164 | public static final String EXTRA_IS_UNKNOWN_CALL = "android:isUnknown"; |
Shriram Ganesh | d3adfad | 2015-05-31 10:06:15 -0700 | [diff] [blame] | 165 | |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 166 | private static final int SYSTEM_PROPERTY_NOT_SET = -1; |
| 167 | |
| 168 | // -1 indicates a subscriptionProperty value that is never set. |
| 169 | private static final int SUB_PROPERTY_NOT_INITIALIZED = -1; |
| 170 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 171 | private static final String TAG = "ImsManager"; |
| 172 | private static final boolean DBG = true; |
| 173 | |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 174 | /** |
| 175 | * Helper class for managing a connection to the ImsManager when the ImsService is unavailable |
| 176 | * or switches to another service. |
| 177 | */ |
| 178 | public static class Connector extends Handler { |
| 179 | // Initial condition for ims connection retry. |
| 180 | private static final int IMS_RETRY_STARTING_TIMEOUT_MS = 500; // ms |
| 181 | // Ceiling bitshift amount for service query timeout, calculated as: |
| 182 | // 2^mImsServiceRetryCount * IMS_RETRY_STARTING_TIMEOUT_MS, where |
| 183 | // mImsServiceRetryCount ∊ [0, CEILING_SERVICE_RETRY_COUNT]. |
| 184 | private static final int CEILING_SERVICE_RETRY_COUNT = 6; |
| 185 | |
| 186 | private final Runnable mGetServiceRunnable = () -> { |
| 187 | try { |
| 188 | getImsService(); |
| 189 | } catch (ImsException e) { |
| 190 | retryGetImsService(); |
| 191 | } |
| 192 | }; |
| 193 | |
| 194 | public interface Listener { |
| 195 | /** |
| 196 | * ImsManager is connected to the underlying IMS implementation. |
| 197 | */ |
| 198 | void connectionReady(ImsManager manager) throws ImsException; |
| 199 | |
| 200 | /** |
| 201 | * The underlying IMS implementation is unavailable and can not be used to communicate. |
| 202 | */ |
| 203 | void connectionUnavailable(); |
| 204 | } |
| 205 | |
| 206 | @VisibleForTesting |
| 207 | public interface RetryTimeout { |
| 208 | int get(); |
| 209 | } |
| 210 | |
| 211 | // Callback fires when ImsManager MMTel Feature changes state |
| 212 | private MmTelFeatureConnection.IFeatureUpdate mNotifyStatusChangedCallback = |
| 213 | new MmTelFeatureConnection.IFeatureUpdate() { |
| 214 | @Override |
| 215 | public void notifyStateChanged() { |
| 216 | try { |
| 217 | int status = ImsFeature.STATE_UNAVAILABLE; |
| 218 | synchronized (mLock) { |
| 219 | if (mImsManager != null) { |
| 220 | status = mImsManager.getImsServiceState(); |
| 221 | } |
| 222 | } |
| 223 | log("Status Changed: " + status); |
| 224 | switch (status) { |
| 225 | case ImsFeature.STATE_READY: { |
| 226 | notifyReady(); |
| 227 | break; |
| 228 | } |
| 229 | case ImsFeature.STATE_INITIALIZING: |
| 230 | // fall through |
| 231 | case ImsFeature.STATE_UNAVAILABLE: { |
| 232 | notifyNotReady(); |
| 233 | break; |
| 234 | } |
| 235 | default: { |
| 236 | Log.w(TAG, "Unexpected State!"); |
| 237 | } |
| 238 | } |
| 239 | } catch (ImsException e) { |
| 240 | // Could not get the ImsService, retry! |
| 241 | notifyNotReady(); |
| 242 | retryGetImsService(); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public void notifyUnavailable() { |
| 248 | notifyNotReady(); |
| 249 | retryGetImsService(); |
| 250 | } |
| 251 | }; |
| 252 | |
| 253 | private final Context mContext; |
| 254 | private final int mPhoneId; |
| 255 | private final Listener mListener; |
| 256 | private final Object mLock = new Object(); |
| 257 | |
| 258 | private int mRetryCount = 0; |
| 259 | private ImsManager mImsManager; |
| 260 | |
| 261 | @VisibleForTesting |
| 262 | public RetryTimeout mRetryTimeout = () -> { |
| 263 | synchronized (mLock) { |
| 264 | int timeout = (1 << mRetryCount) * IMS_RETRY_STARTING_TIMEOUT_MS; |
| 265 | if (mRetryCount <= CEILING_SERVICE_RETRY_COUNT) { |
| 266 | mRetryCount++; |
| 267 | } |
| 268 | return timeout; |
| 269 | } |
| 270 | }; |
| 271 | |
| 272 | public Connector(Context context, int phoneId, Listener listener) { |
| 273 | mContext = context; |
| 274 | mPhoneId = phoneId; |
| 275 | mListener = listener; |
| 276 | } |
| 277 | |
| 278 | public Connector(Context context, int phoneId, Listener listener, Looper looper) { |
| 279 | super(looper); |
| 280 | mContext = context; |
| 281 | mPhoneId = phoneId; |
| 282 | mListener= listener; |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Start the creation of a connection to the underlying ImsService implementation. When the |
| 287 | * service is connected, {@link Listener#connectionReady(ImsManager)} will be called with |
| 288 | * an active ImsManager instance. |
| 289 | */ |
| 290 | public void connect() { |
| 291 | mRetryCount = 0; |
| 292 | // Send a message to connect to the Ims Service and open a connection through |
| 293 | // getImsService(). |
| 294 | post(mGetServiceRunnable); |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Disconnect from the ImsService Implementation and clean up. When this is complete, |
| 299 | * {@link Listener#connectionUnavailable()} will be called one last time. |
| 300 | */ |
| 301 | public void disconnect() { |
| 302 | removeCallbacks(mGetServiceRunnable); |
| 303 | synchronized (mLock) { |
| 304 | if (mImsManager != null) { |
| 305 | mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); |
| 306 | } |
| 307 | } |
| 308 | notifyNotReady(); |
| 309 | } |
| 310 | |
| 311 | private void retryGetImsService() { |
| 312 | synchronized (mLock) { |
| 313 | // remove callback so we do not receive updates from old ImsServiceProxy when |
| 314 | // switching between ImsServices. |
| 315 | mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); |
| 316 | //Leave mImsManager as null, then CallStateException will be thrown when dialing |
| 317 | mImsManager = null; |
| 318 | } |
| 319 | // Exponential backoff during retry, limited to 32 seconds. |
| 320 | loge("Connector: Retrying getting ImsService..."); |
| 321 | removeCallbacks(mGetServiceRunnable); |
| 322 | postDelayed(mGetServiceRunnable, mRetryTimeout.get()); |
| 323 | } |
| 324 | |
| 325 | private void getImsService() throws ImsException { |
| 326 | if (DBG) log("Connector: getImsService"); |
| 327 | synchronized (mLock) { |
| 328 | mImsManager = ImsManager.getInstance(mContext, mPhoneId); |
| 329 | // Adding to set, will be safe adding multiple times. If the ImsService is not |
| 330 | // active yet, this method will throw an ImsException. |
| 331 | mImsManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback); |
| 332 | } |
| 333 | // Wait for ImsService.STATE_READY to start listening for calls. |
| 334 | // Call the callback right away for compatibility with older devices that do not use |
| 335 | // states. |
| 336 | mNotifyStatusChangedCallback.notifyStateChanged(); |
| 337 | } |
| 338 | |
| 339 | private void notifyReady() throws ImsException { |
| 340 | ImsManager manager; |
| 341 | synchronized (mLock) { |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 342 | manager = mImsManager; |
| 343 | } |
Brad Ebinger | 0aed76d | 2018-03-05 16:39:02 -0800 | [diff] [blame] | 344 | try { |
| 345 | mListener.connectionReady(manager); |
| 346 | } |
| 347 | catch (ImsException e) { |
| 348 | Log.w(TAG, "Connector: notifyReady exception: " + e.getMessage()); |
| 349 | throw e; |
| 350 | } |
| 351 | // Only reset retry count if connectionReady does not generate an ImsException/ |
| 352 | synchronized (mLock) { |
| 353 | mRetryCount = 0; |
| 354 | } |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | private void notifyNotReady() { |
| 358 | mListener.connectionUnavailable(); |
| 359 | } |
| 360 | } |
| 361 | |
Wink Saville | 1e5a38a | 2014-10-23 10:24:46 -0700 | [diff] [blame] | 362 | private static HashMap<Integer, ImsManager> sImsManagerInstances = |
| 363 | new HashMap<Integer, ImsManager>(); |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 364 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 365 | private Context mContext; |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 366 | private CarrierConfigManager mConfigManager; |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 367 | private int mPhoneId; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 368 | private final boolean mConfigDynamicBind; |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 369 | private @Nullable MmTelFeatureConnection mMmTelFeatureConnection = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 370 | private ImsServiceDeathRecipient mDeathRecipient = new ImsServiceDeathRecipient(); |
| 371 | // Ut interface for the supplementary service configuration |
| 372 | private ImsUt mUt = null; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 373 | // Interface to get/set ims config items |
| 374 | private ImsConfig mConfig = null; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 375 | private boolean mConfigUpdated = false; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 376 | |
Pavel Zhamaitsiak | f4b9032 | 2016-01-26 14:34:09 -0800 | [diff] [blame] | 377 | private ImsConfigListener mImsConfigListener; |
| 378 | |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 379 | // ECBM interface |
| 380 | private ImsEcbm mEcbm = null; |
| 381 | |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 382 | private ImsMultiEndpoint mMultiEndpoint = null; |
| 383 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 384 | private Set<MmTelFeatureConnection.IFeatureUpdate> mStatusCallbacks = |
| 385 | new CopyOnWriteArraySet<>(); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 386 | |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 387 | public static final String TRUE = "true"; |
| 388 | public static final String FALSE = "false"; |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 389 | |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 390 | // mRecentDisconnectReasons stores the last 16 disconnect reasons |
| 391 | private static final int MAX_RECENT_DISCONNECT_REASONS = 16; |
| 392 | private ConcurrentLinkedDeque<ImsReasonInfo> mRecentDisconnectReasons = |
| 393 | new ConcurrentLinkedDeque<>(); |
| 394 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 395 | /** |
| 396 | * Gets a manager instance. |
| 397 | * |
| 398 | * @param context application context for creating the manager object |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 399 | * @param phoneId the phone ID for the IMS Service |
| 400 | * @return the manager instance corresponding to the phoneId |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 401 | */ |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 402 | public static ImsManager getInstance(Context context, int phoneId) { |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 403 | synchronized (sImsManagerInstances) { |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 404 | if (sImsManagerInstances.containsKey(phoneId)) { |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 405 | ImsManager m = sImsManagerInstances.get(phoneId); |
| 406 | // May be null for some tests |
| 407 | if (m != null) { |
| 408 | m.connectIfServiceIsAvailable(); |
| 409 | } |
| 410 | return m; |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 411 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 412 | |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 413 | ImsManager mgr = new ImsManager(context, phoneId); |
| 414 | sImsManagerInstances.put(phoneId, mgr); |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 415 | |
| 416 | return mgr; |
| 417 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Etan Cohen | 45b5f31 | 2014-08-19 15:55:08 -0700 | [diff] [blame] | 420 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 421 | * Returns the user configuration of Enhanced 4G LTE Mode setting. |
| 422 | * |
| 423 | * @deprecated Doesn't support MSIM devices. Use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 424 | * {@link #isEnhanced4gLteModeSettingEnabledByUser()} instead. |
Etan Cohen | 45b5f31 | 2014-08-19 15:55:08 -0700 | [diff] [blame] | 425 | */ |
| 426 | public static boolean isEnhanced4gLteModeSettingEnabledByUser(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 427 | ImsManager mgr = ImsManager.getInstance(context, |
| 428 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 429 | if (mgr != null) { |
| 430 | return mgr.isEnhanced4gLteModeSettingEnabledByUser(); |
Sungmin Choi | 2f1af95 | 2016-02-01 17:15:35 +0900 | [diff] [blame] | 431 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 432 | loge("isEnhanced4gLteModeSettingEnabledByUser: ImsManager null, returning default value."); |
| 433 | return false; |
Etan Cohen | 45b5f31 | 2014-08-19 15:55:08 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | /** |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 437 | * Returns the user configuration of Enhanced 4G LTE Mode setting for slot. If the option is |
| 438 | * not editable ({@link CarrierConfigManager#KEY_EDITABLE_ENHANCED_4G_LTE_BOOL} is false), or |
| 439 | * the setting is not initialized, this method will return default value specified by |
| 440 | * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}. |
| 441 | * |
| 442 | * Note that even if the setting was set, it may no longer be editable. If this is the case we |
| 443 | * return the default value. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 444 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 445 | public boolean isEnhanced4gLteModeSettingEnabledByUser() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 446 | int setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 447 | getSubId(), SubscriptionManager.ENHANCED_4G_MODE_ENABLED, |
| 448 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 449 | boolean onByDefault = getBooleanCarrierConfig( |
| 450 | CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 451 | |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 452 | // If Enhanced 4G LTE Mode is uneditable or not initialized, we use the default value |
| 453 | if (!getBooleanCarrierConfig(CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL) |
| 454 | || setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 455 | return onByDefault; |
| 456 | } else { |
| 457 | return (setting == ImsConfig.FeatureValueConstants.ON); |
| 458 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Change persistent Enhanced 4G LTE Mode setting. |
| 463 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 464 | * @deprecated Doesn't support MSIM devices. Use {@link #setEnhanced4gLteModeSetting(boolean)} |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 465 | * instead. |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 466 | */ |
| 467 | public static void setEnhanced4gLteModeSetting(Context context, boolean enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 468 | ImsManager mgr = ImsManager.getInstance(context, |
| 469 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 470 | if (mgr != null) { |
| 471 | mgr.setEnhanced4gLteModeSetting(enabled); |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 472 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 473 | loge("setEnhanced4gLteModeSetting: ImsManager null, value not set."); |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | /** |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 477 | * Change persistent Enhanced 4G LTE Mode setting. If the option is not editable |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 478 | * ({@link CarrierConfigManager#KEY_EDITABLE_ENHANCED_4G_LTE_BOOL} is false), this method will |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 479 | * set the setting to the default value specified by |
| 480 | * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 481 | * |
| 482 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 483 | public void setEnhanced4gLteModeSetting(boolean enabled) { |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 484 | // If editable=false, we must keep default advanced 4G mode. |
| 485 | if (!getBooleanCarrierConfig(CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL)) { |
| 486 | enabled = getBooleanCarrierConfig( |
| 487 | CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL); |
| 488 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 489 | |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 490 | int prevSetting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 491 | getSubId(), SubscriptionManager.ENHANCED_4G_MODE_ENABLED, |
| 492 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 493 | |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 494 | if (prevSetting != (enabled ? |
| 495 | ImsConfig.FeatureValueConstants.ON : |
| 496 | ImsConfig.FeatureValueConstants.OFF)) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 497 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 498 | SubscriptionManager.ENHANCED_4G_MODE_ENABLED, booleanToPropertyString(enabled)); |
| 499 | if (isNonTtyOrTtyOnVolteEnabled()) { |
| 500 | try { |
| 501 | setAdvanced4GMode(enabled); |
| 502 | } catch (ImsException ie) { |
| 503 | // do nothing |
| 504 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 505 | } |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | /** |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 510 | * Indicates whether the call is non-TTY or if TTY - whether TTY on VoLTE is |
| 511 | * supported. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 512 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 513 | * {@link #isNonTtyOrTtyOnVolteEnabled()} instead. |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 514 | */ |
| 515 | public static boolean isNonTtyOrTtyOnVolteEnabled(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 516 | ImsManager mgr = ImsManager.getInstance(context, |
| 517 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 518 | if (mgr != null) { |
| 519 | return mgr.isNonTtyOrTtyOnVolteEnabled(); |
| 520 | } |
| 521 | loge("isNonTtyOrTtyOnVolteEnabled: ImsManager null, returning default value."); |
| 522 | return false; |
| 523 | } |
| 524 | |
| 525 | /** |
| 526 | * Indicates whether the call is non-TTY or if TTY - whether TTY on VoLTE is |
| 527 | * supported on a per slot basis. |
| 528 | */ |
| 529 | public boolean isNonTtyOrTtyOnVolteEnabled() { |
| 530 | if (getBooleanCarrierConfig( |
fionaxu | 5803ef0 | 2016-03-08 11:48:48 -0800 | [diff] [blame] | 531 | CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) { |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 532 | return true; |
| 533 | } |
| 534 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 535 | TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 536 | if (tm == null) { |
| 537 | Log.w(TAG, "isNonTtyOrTtyOnVolteEnabled: telecom not available"); |
| 538 | return true; |
| 539 | } |
| 540 | return tm.getCurrentTtyMode() == TelecomManager.TTY_MODE_OFF; |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | /** |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 544 | * Returns a platform configuration for VoLTE which may override the user setting. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 545 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 546 | * {@link #isVolteEnabledByPlatform()} instead. |
Etan Cohen | 45b5f31 | 2014-08-19 15:55:08 -0700 | [diff] [blame] | 547 | */ |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 548 | public static boolean isVolteEnabledByPlatform(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 549 | ImsManager mgr = ImsManager.getInstance(context, |
| 550 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 551 | if (mgr != null) { |
| 552 | return mgr.isVolteEnabledByPlatform(); |
Etan Cohen | af55a40 | 2014-09-04 22:34:41 -0700 | [diff] [blame] | 553 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 554 | loge("isVolteEnabledByPlatform: ImsManager null, returning default value."); |
| 555 | return false; |
Etan Cohen | b5388a3 | 2014-11-26 11:57:47 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 558 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 559 | * Returns a platform configuration for VoLTE which may override the user setting on a per Slot |
| 560 | * basis. |
| 561 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 562 | public boolean isVolteEnabledByPlatform() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 563 | // We first read the per slot value. If doesn't exist, we read the general value. If still |
| 564 | // doesn't exist, we use the hardcoded default value. |
| 565 | if (SystemProperties.getInt( |
| 566 | PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE + Integer.toString(mPhoneId), |
| 567 | SYSTEM_PROPERTY_NOT_SET) == 1 || |
| 568 | SystemProperties.getInt(PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE, |
| 569 | SYSTEM_PROPERTY_NOT_SET) == 1) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 570 | return true; |
| 571 | } |
| 572 | |
| 573 | return mContext.getResources().getBoolean( |
| 574 | com.android.internal.R.bool.config_device_volte_available) |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 575 | && getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL) |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 576 | && isGbaValid(); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | /** |
| 580 | * Indicates whether VoLTE is provisioned on device. |
| 581 | * |
| 582 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 583 | * {@link #isVolteProvisionedOnDevice()} instead. |
Etan Cohen | b5388a3 | 2014-11-26 11:57:47 -0800 | [diff] [blame] | 584 | */ |
| 585 | public static boolean isVolteProvisionedOnDevice(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 586 | ImsManager mgr = ImsManager.getInstance(context, |
| 587 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 588 | if (mgr != null) { |
| 589 | return mgr.isVolteProvisionedOnDevice(); |
Etan Cohen | b5388a3 | 2014-11-26 11:57:47 -0800 | [diff] [blame] | 590 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 591 | loge("isVolteProvisionedOnDevice: ImsManager null, returning default value."); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 592 | return true; |
| 593 | } |
| 594 | |
| 595 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 596 | * Indicates whether VoLTE is provisioned on this slot. |
| 597 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 598 | public boolean isVolteProvisionedOnDevice() { |
| 599 | if (getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 600 | CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) { |
| 601 | return isVolteProvisioned(); |
| 602 | } |
| 603 | |
| 604 | return true; |
| 605 | } |
| 606 | |
| 607 | /** |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 608 | * Indicates whether VoWifi is provisioned on device. |
| 609 | * |
| 610 | * When CarrierConfig KEY_CARRIER_VOLTE_OVERRIDE_WFC_PROVISIONING_BOOL is true, and VoLTE is not |
| 611 | * provisioned on device, this method returns false. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 612 | * |
| 613 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 614 | * {@link #isWfcProvisionedOnDevice()} instead. |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 615 | */ |
| 616 | public static boolean isWfcProvisionedOnDevice(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 617 | ImsManager mgr = ImsManager.getInstance(context, |
| 618 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 619 | if (mgr != null) { |
| 620 | return mgr.isWfcProvisionedOnDevice(); |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 621 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 622 | loge("isWfcProvisionedOnDevice: ImsManager null, returning default value."); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 623 | return true; |
| 624 | } |
| 625 | |
| 626 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 627 | * Indicates whether VoWifi is provisioned on slot. |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 628 | * |
| 629 | * When CarrierConfig KEY_CARRIER_VOLTE_OVERRIDE_WFC_PROVISIONING_BOOL is true, and VoLTE is not |
| 630 | * provisioned on device, this method returns false. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 631 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 632 | public boolean isWfcProvisionedOnDevice() { |
| 633 | if (getBooleanCarrierConfig( |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 634 | CarrierConfigManager.KEY_CARRIER_VOLTE_OVERRIDE_WFC_PROVISIONING_BOOL)) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 635 | if (!isVolteProvisionedOnDevice()) { |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 636 | return false; |
| 637 | } |
| 638 | } |
| 639 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 640 | if (getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 641 | CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) { |
Meng Wang | 54fd41a | 2017-04-12 11:44:47 -0700 | [diff] [blame] | 642 | return isWfcProvisioned(); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | return true; |
| 646 | } |
| 647 | |
| 648 | /** |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 649 | * Indicates whether VT is provisioned on device |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 650 | * |
| 651 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 652 | * {@link #isVtProvisionedOnDevice()} instead. |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 653 | */ |
| 654 | public static boolean isVtProvisionedOnDevice(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 655 | ImsManager mgr = ImsManager.getInstance(context, |
| 656 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 657 | if (mgr != null) { |
| 658 | return mgr.isVtProvisionedOnDevice(); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 659 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 660 | loge("isVtProvisionedOnDevice: ImsManager null, returning default value."); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 661 | return true; |
Etan Cohen | b651fa5 | 2014-10-22 10:51:29 -0700 | [diff] [blame] | 662 | } |
| 663 | |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 664 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 665 | * Indicates whether VT is provisioned on slot. |
| 666 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 667 | public boolean isVtProvisionedOnDevice() { |
| 668 | if (getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 669 | CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) { |
| 670 | return isVtProvisioned(); |
| 671 | } |
| 672 | |
| 673 | return true; |
| 674 | } |
| 675 | |
| 676 | /** |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 677 | * Returns a platform configuration for VT which may override the user setting. |
| 678 | * |
| 679 | * Note: VT presumes that VoLTE is enabled (these are configuration settings |
| 680 | * which must be done correctly). |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 681 | * |
| 682 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 683 | * {@link #isVtEnabledByPlatform()} instead. |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 684 | */ |
Etan Cohen | b651fa5 | 2014-10-22 10:51:29 -0700 | [diff] [blame] | 685 | public static boolean isVtEnabledByPlatform(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 686 | ImsManager mgr = ImsManager.getInstance(context, |
| 687 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 688 | if (mgr != null) { |
| 689 | return mgr.isVtEnabledByPlatform(); |
Etan Cohen | ea2b583 | 2014-10-23 18:50:35 -0700 | [diff] [blame] | 690 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 691 | loge("isVtEnabledByPlatform: ImsManager null, returning default value."); |
| 692 | return false; |
Etan Cohen | 45b5f31 | 2014-08-19 15:55:08 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 695 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 696 | * Returns a platform configuration for VT which may override the user setting. |
| 697 | * |
| 698 | * Note: VT presumes that VoLTE is enabled (these are configuration settings |
| 699 | * which must be done correctly). |
| 700 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 701 | public boolean isVtEnabledByPlatform() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 702 | // We first read the per slot value. If doesn't exist, we read the general value. If still |
| 703 | // doesn't exist, we use the hardcoded default value. |
| 704 | if (SystemProperties.getInt(PROPERTY_DBG_VT_AVAIL_OVERRIDE + |
| 705 | Integer.toString(mPhoneId), SYSTEM_PROPERTY_NOT_SET) == 1 || |
| 706 | SystemProperties.getInt( |
| 707 | PROPERTY_DBG_VT_AVAIL_OVERRIDE, SYSTEM_PROPERTY_NOT_SET) == 1) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 708 | return true; |
| 709 | } |
| 710 | |
| 711 | return mContext.getResources().getBoolean( |
| 712 | com.android.internal.R.bool.config_device_vt_available) && |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 713 | getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VT_AVAILABLE_BOOL) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 714 | isGbaValid(); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | /** |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 718 | * Returns the user configuration of VT setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 719 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 720 | * {@link #isVtEnabledByUser()} instead. |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 721 | */ |
| 722 | public static boolean isVtEnabledByUser(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 723 | ImsManager mgr = ImsManager.getInstance(context, |
| 724 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 725 | if (mgr != null) { |
| 726 | return mgr.isVtEnabledByUser(); |
| 727 | } |
| 728 | loge("isVtEnabledByUser: ImsManager null, returning default value."); |
| 729 | return false; |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 733 | * Returns the user configuration of VT setting per slot. If not set, it |
| 734 | * returns true as default value. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 735 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 736 | public boolean isVtEnabledByUser() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 737 | int setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 738 | getSubId(), SubscriptionManager.VT_IMS_ENABLED, |
| 739 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 740 | |
| 741 | // If it's never set, by default we return true. |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 742 | return (setting == SUB_PROPERTY_NOT_INITIALIZED |
| 743 | || setting == ImsConfig.FeatureValueConstants.ON); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | /** |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 747 | * Change persistent VT enabled setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 748 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 749 | * @deprecated Does not support MSIM devices. Please use {@link #setVtSetting(boolean)} instead. |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 750 | */ |
| 751 | public static void setVtSetting(Context context, boolean enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 752 | ImsManager mgr = ImsManager.getInstance(context, |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 753 | SubscriptionManager.getDefaultVoicePhoneId()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 754 | if (mgr != null) { |
| 755 | mgr.setVtSetting(enabled); |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 756 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 757 | loge("setVtSetting: ImsManager null, can not set value."); |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 758 | } |
| 759 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 760 | /** |
| 761 | * Change persistent VT enabled setting for slot. |
| 762 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 763 | public void setVtSetting(boolean enabled) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 764 | SubscriptionManager.setSubscriptionProperty(getSubId(), SubscriptionManager.VT_IMS_ENABLED, |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 765 | booleanToPropertyString(enabled)); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 766 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 767 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 768 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 769 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE, enabled); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 770 | |
| 771 | if (enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 772 | log("setVtSetting(b) : turnOnIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 773 | turnOnIms(); |
Brad Ebinger | 2384f42 | 2018-03-15 16:09:41 -0700 | [diff] [blame] | 774 | } else if (isTurnOffImsAllowedByPlatform() |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 775 | && (!isVolteEnabledByPlatform() |
| 776 | || !isEnhanced4gLteModeSettingEnabledByUser())) { |
| 777 | log("setVtSetting(b) : imsServiceAllowTurnOff -> turnOffIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 778 | turnOffIms(); |
| 779 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 780 | } catch (ImsException | RemoteException e) { |
| 781 | // The ImsService is down. Since the SubscriptionManager already recorded the user's |
| 782 | // preference, it will be resent in updateImsServiceConfig when the ImsPhoneCallTracker |
| 783 | // reconnects. |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 784 | loge("setVtSetting(b): ", e); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 785 | } |
| 786 | } |
| 787 | |
| 788 | /** |
Meng Wang | 9352c43 | 2016-06-08 14:22:20 -0700 | [diff] [blame] | 789 | * Returns whether turning off ims is allowed by platform. |
| 790 | * The platform property may override the carrier config. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 791 | * |
| 792 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 793 | * {@link #isTurnOffImsAllowedByPlatform()} instead. |
Meng Wang | 9352c43 | 2016-06-08 14:22:20 -0700 | [diff] [blame] | 794 | */ |
| 795 | private static boolean isTurnOffImsAllowedByPlatform(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 796 | ImsManager mgr = ImsManager.getInstance(context, |
| 797 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 798 | if (mgr != null) { |
| 799 | return mgr.isTurnOffImsAllowedByPlatform(); |
Meng Wang | 9352c43 | 2016-06-08 14:22:20 -0700 | [diff] [blame] | 800 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 801 | loge("isTurnOffImsAllowedByPlatform: ImsManager null, returning default value."); |
| 802 | return true; |
Meng Wang | 9352c43 | 2016-06-08 14:22:20 -0700 | [diff] [blame] | 803 | } |
| 804 | |
Etan Cohen | a7d32e8 | 2015-05-04 18:02:09 -0700 | [diff] [blame] | 805 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 806 | * Returns whether turning off ims is allowed by platform. |
| 807 | * The platform property may override the carrier config. |
| 808 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 809 | private boolean isTurnOffImsAllowedByPlatform() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 810 | // We first read the per slot value. If doesn't exist, we read the general value. If still |
| 811 | // doesn't exist, we use the hardcoded default value. |
| 812 | if (SystemProperties.getInt(PROPERTY_DBG_ALLOW_IMS_OFF_OVERRIDE + |
| 813 | Integer.toString(mPhoneId), SYSTEM_PROPERTY_NOT_SET) == 1 || |
| 814 | SystemProperties.getInt( |
| 815 | PROPERTY_DBG_ALLOW_IMS_OFF_OVERRIDE, SYSTEM_PROPERTY_NOT_SET) == 1) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 816 | return true; |
| 817 | } |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 818 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 819 | return getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 820 | CarrierConfigManager.KEY_CARRIER_ALLOW_TURNOFF_IMS_BOOL); |
| 821 | } |
| 822 | |
| 823 | /** |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 824 | * Returns the user configuration of WFC setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 825 | * |
| 826 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 827 | * {@link #isWfcEnabledByUser()} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 828 | */ |
| 829 | public static boolean isWfcEnabledByUser(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 830 | ImsManager mgr = ImsManager.getInstance(context, |
| 831 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 832 | if (mgr != null) { |
| 833 | return mgr.isWfcEnabledByUser(); |
| 834 | } |
| 835 | loge("isWfcEnabledByUser: ImsManager null, returning default value."); |
| 836 | return true; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 840 | * Returns the user configuration of WFC setting for slot. If not set, it |
| 841 | * queries CarrierConfig value as default. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 842 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 843 | public boolean isWfcEnabledByUser() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 844 | int setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 845 | getSubId(), SubscriptionManager.WFC_IMS_ENABLED, |
| 846 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 847 | |
| 848 | // SUB_PROPERTY_NOT_INITIALIZED indicates it's never set in sub db. |
| 849 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 850 | return getBooleanCarrierConfig( |
| 851 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL); |
| 852 | } else { |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 853 | return setting == ImsConfig.FeatureValueConstants.ON; |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 854 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | /** |
| 858 | * Change persistent WFC enabled setting. |
| 859 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 860 | * {@link #setWfcSetting} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 861 | */ |
| 862 | public static void setWfcSetting(Context context, boolean enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 863 | ImsManager mgr = ImsManager.getInstance(context, |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 864 | SubscriptionManager.getDefaultVoicePhoneId()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 865 | if (mgr != null) { |
| 866 | mgr.setWfcSetting(enabled); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 867 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 868 | loge("setWfcSetting: ImsManager null, can not set value."); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 872 | * Change persistent WFC enabled setting for slot. |
| 873 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 874 | public void setWfcSetting(boolean enabled) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 875 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 876 | SubscriptionManager.WFC_IMS_ENABLED, booleanToPropertyString(enabled)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 877 | |
Meng Wang | eba31e1 | 2018-04-17 11:27:21 -0700 | [diff] [blame^] | 878 | TelephonyManager tm = (TelephonyManager) |
| 879 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 880 | setWfcNonPersistent(enabled, getWfcMode(tm.isNetworkRoaming(getSubId()))); |
Meng Wang | 51c0907 | 2017-03-27 10:47:45 -0700 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | /** |
| 884 | * Non-persistently change WFC enabled setting and WFC mode for slot |
| 885 | * |
| 886 | * @param wfcMode The WFC preference if WFC is enabled |
| 887 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 888 | public void setWfcNonPersistent(boolean enabled, int wfcMode) { |
Meng Wang | 51c0907 | 2017-03-27 10:47:45 -0700 | [diff] [blame] | 889 | // Force IMS to register over LTE when turning off WFC |
| 890 | int imsWfcModeFeatureValue = |
| 891 | enabled ? wfcMode : ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED; |
| 892 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 893 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 894 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 895 | ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, enabled); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 896 | |
| 897 | if (enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 898 | log("setWfcSetting() : turnOnIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 899 | turnOnIms(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 900 | } else if (isTurnOffImsAllowedByPlatform() |
| 901 | && (!isVolteEnabledByPlatform() |
| 902 | || !isEnhanced4gLteModeSettingEnabledByUser())) { |
| 903 | log("setWfcSetting() : imsServiceAllowTurnOff -> turnOffIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 904 | turnOffIms(); |
| 905 | } |
| 906 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 907 | setWfcModeInternal(imsWfcModeFeatureValue); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 908 | } catch (ImsException | RemoteException e) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 909 | loge("setWfcSetting(): ", e); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | |
| 913 | /** |
| 914 | * Returns the user configuration of WFC preference setting. |
| 915 | * |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 916 | * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean roaming)} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 917 | */ |
| 918 | public static int getWfcMode(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 919 | ImsManager mgr = ImsManager.getInstance(context, |
| 920 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 921 | if (mgr != null) { |
| 922 | return mgr.getWfcMode(); |
| 923 | } |
| 924 | loge("getWfcMode: ImsManager null, returning default value."); |
| 925 | return ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 929 | * Returns the user configuration of WFC preference setting |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 930 | * @deprecated. Use {@link #getWfcMode(boolean roaming)} instead. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 931 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 932 | public int getWfcMode() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 933 | return getWfcMode(false); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | /** |
| 937 | * Change persistent WFC preference setting. |
| 938 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 939 | * @deprecated Doesn't support MSIM devices. Use {@link #setWfcMode(int)} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 940 | */ |
| 941 | public static void setWfcMode(Context context, int wfcMode) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 942 | ImsManager mgr = ImsManager.getInstance(context, |
| 943 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 944 | if (mgr != null) { |
| 945 | mgr.setWfcMode(wfcMode); |
| 946 | } |
| 947 | loge("setWfcMode: ImsManager null, can not set value."); |
Pavel Zhamaitsiak | 9e6eca2 | 2015-03-16 15:30:53 -0700 | [diff] [blame] | 948 | } |
| 949 | |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 950 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 951 | * Change persistent WFC preference setting for slot. |
| 952 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 953 | public void setWfcMode(int wfcMode) { |
| 954 | if (DBG) log("setWfcMode(i) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 955 | |
| 956 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 957 | SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 958 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 959 | setWfcModeInternal(wfcMode); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | /** |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 963 | * Changes the WFC mode to its default value for Carriers with non-editable WFC settings. |
| 964 | */ |
| 965 | private void updateDefaultWfcMode() { |
| 966 | if (DBG) log("updateDefaultWfcMode"); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 967 | if (!getBooleanCarrierConfig(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL)) { |
| 968 | setWfcMode(getIntCarrierConfig( |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 969 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT)); |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | /** |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 974 | * Returns the user configuration of WFC preference setting |
| 975 | * |
| 976 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 977 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 978 | * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean)} instead. |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 979 | */ |
| 980 | public static int getWfcMode(Context context, boolean roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 981 | ImsManager mgr = ImsManager.getInstance(context, |
| 982 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 983 | if (mgr != null) { |
| 984 | return mgr.getWfcMode(roaming); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 985 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 986 | loge("getWfcMode: ImsManager null, returning default value."); |
| 987 | return ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 991 | * Returns the user configuration of WFC preference setting for slot. If not set, it |
| 992 | * queries CarrierConfig value as default. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 993 | * |
| 994 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
| 995 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 996 | public int getWfcMode(boolean roaming) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 997 | int setting = 0; |
| 998 | if (!roaming) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 999 | setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 1000 | getSubId(), SubscriptionManager.WFC_IMS_MODE, |
| 1001 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1002 | |
| 1003 | // SUB_PROPERTY_NOT_INITIALIZED indicates it's never set in sub db. |
| 1004 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1005 | setting = getIntCarrierConfig( |
| 1006 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT); |
| 1007 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1008 | if (DBG) log("getWfcMode - setting=" + setting); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1009 | } else { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1010 | setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 1011 | getSubId(), SubscriptionManager.WFC_IMS_ROAMING_MODE, |
| 1012 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1013 | |
| 1014 | // SUB_PROPERTY_NOT_INITIALIZED indicates it's never set in sub db. |
| 1015 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1016 | setting = getIntCarrierConfig( |
| 1017 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT); |
| 1018 | } |
| 1019 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1020 | if (DBG) log("getWfcMode (roaming) - setting=" + setting); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1021 | } |
| 1022 | return setting; |
| 1023 | } |
| 1024 | |
| 1025 | /** |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1026 | * Change persistent WFC preference setting |
| 1027 | * |
| 1028 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1029 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1030 | * @deprecated Doesn't support MSIM devices. Please use {@link #setWfcMode(int, boolean)} |
| 1031 | * instead. |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1032 | */ |
| 1033 | public static void setWfcMode(Context context, int wfcMode, boolean roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1034 | ImsManager mgr = ImsManager.getInstance(context, |
| 1035 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1036 | if (mgr != null) { |
| 1037 | mgr.setWfcMode(wfcMode, roaming); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1038 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1039 | loge("setWfcMode: ImsManager null, can not set value."); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1040 | } |
| 1041 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1042 | /** |
| 1043 | * Change persistent WFC preference setting |
| 1044 | * |
| 1045 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
| 1046 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1047 | public void setWfcMode(int wfcMode, boolean roaming) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1048 | if (!roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1049 | if (DBG) log("setWfcMode(i,b) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1050 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1051 | SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1052 | } else { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1053 | if (DBG) log("setWfcMode(i,b) (roaming) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1054 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1055 | SubscriptionManager.WFC_IMS_ROAMING_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1056 | } |
| 1057 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1058 | TelephonyManager tm = (TelephonyManager) |
| 1059 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 1060 | if (roaming == tm.isNetworkRoaming(getSubId())) { |
| 1061 | setWfcModeInternal(wfcMode); |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | private int getSubId() { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1066 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1067 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1068 | if (subIds != null && subIds.length >= 1) { |
| 1069 | subId = subIds[0]; |
| 1070 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1071 | return subId; |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1072 | } |
| 1073 | |
Pavel Zhamaitsiak | 9e6eca2 | 2015-03-16 15:30:53 -0700 | [diff] [blame] | 1074 | private static void setWfcModeInternal(Context context, int wfcMode) { |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1075 | final ImsManager imsManager = ImsManager.getInstance(context, |
| 1076 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1077 | if (imsManager != null) { |
| 1078 | final int value = wfcMode; |
Pavel Zhamaitsiak | 47aeacf | 2016-03-30 18:54:55 -0700 | [diff] [blame] | 1079 | Thread thread = new Thread(new Runnable() { |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1080 | public void run() { |
| 1081 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1082 | imsManager.getConfigInterface().setConfig( |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1083 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE, |
| 1084 | value); |
| 1085 | } catch (ImsException e) { |
| 1086 | // do nothing |
| 1087 | } |
| 1088 | } |
| 1089 | }); |
Pavel Zhamaitsiak | 47aeacf | 2016-03-30 18:54:55 -0700 | [diff] [blame] | 1090 | thread.start(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1094 | private void setWfcModeInternal(int wfcMode) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1095 | final int value = wfcMode; |
| 1096 | Thread thread = new Thread(() -> { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1097 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1098 | getConfigInterface().setConfig( |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1099 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE, value); |
| 1100 | } catch (ImsException e) { |
| 1101 | // do nothing |
| 1102 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1103 | }); |
| 1104 | thread.start(); |
| 1105 | } |
| 1106 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1107 | /** |
| 1108 | * Returns the user configuration of WFC roaming setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1109 | * |
| 1110 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1111 | * {@link #isWfcRoamingEnabledByUser()} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1112 | */ |
| 1113 | public static boolean isWfcRoamingEnabledByUser(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1114 | ImsManager mgr = ImsManager.getInstance(context, |
| 1115 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1116 | if (mgr != null) { |
| 1117 | return mgr.isWfcRoamingEnabledByUser(); |
| 1118 | } |
| 1119 | loge("isWfcRoamingEnabledByUser: ImsManager null, returning default value."); |
| 1120 | return false; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1124 | * Returns the user configuration of WFC roaming setting for slot. If not set, it |
| 1125 | * queries CarrierConfig value as default. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1126 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1127 | public boolean isWfcRoamingEnabledByUser() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1128 | int setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 1129 | getSubId(), SubscriptionManager.WFC_IMS_ROAMING_ENABLED, |
| 1130 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1131 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1132 | return getBooleanCarrierConfig( |
| 1133 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL); |
| 1134 | } else { |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 1135 | return setting == ImsConfig.FeatureValueConstants.ON; |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1136 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | /** |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1140 | * Change persistent WFC roaming enabled setting |
| 1141 | */ |
| 1142 | public static void setWfcRoamingSetting(Context context, boolean enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1143 | ImsManager mgr = ImsManager.getInstance(context, |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1144 | SubscriptionManager.getDefaultVoicePhoneId()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1145 | if (mgr != null) { |
| 1146 | mgr.setWfcRoamingSetting(enabled); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1147 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1148 | loge("setWfcRoamingSetting: ImsManager null, value not set."); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1152 | * Change persistent WFC roaming enabled setting |
| 1153 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1154 | public void setWfcRoamingSetting(boolean enabled) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1155 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1156 | SubscriptionManager.WFC_IMS_ROAMING_ENABLED, booleanToPropertyString(enabled) |
| 1157 | ); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1158 | |
| 1159 | setWfcRoamingSettingInternal(enabled); |
| 1160 | } |
| 1161 | |
| 1162 | private void setWfcRoamingSettingInternal(boolean enabled) { |
| 1163 | final int value = enabled |
| 1164 | ? ImsConfig.FeatureValueConstants.ON |
| 1165 | : ImsConfig.FeatureValueConstants.OFF; |
| 1166 | Thread thread = new Thread(() -> { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1167 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1168 | getConfigInterface().setConfig( |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1169 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_ROAMING, value); |
| 1170 | } catch (ImsException e) { |
| 1171 | // do nothing |
| 1172 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1173 | }); |
| 1174 | thread.start(); |
| 1175 | } |
| 1176 | |
| 1177 | /** |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1178 | * Returns a platform configuration for WFC which may override the user |
| 1179 | * setting. Note: WFC presumes that VoLTE is enabled (these are |
| 1180 | * configuration settings which must be done correctly). |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1181 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1182 | * @deprecated Doesn't work for MSIM devices. Use {@link #isWfcEnabledByPlatform()} |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1183 | * instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1184 | */ |
| 1185 | public static boolean isWfcEnabledByPlatform(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1186 | ImsManager mgr = ImsManager.getInstance(context, |
| 1187 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1188 | if (mgr != null) { |
| 1189 | return mgr.isWfcEnabledByPlatform(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1190 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1191 | loge("isWfcEnabledByPlatform: ImsManager null, returning default value."); |
| 1192 | return false; |
Pavel Zhamaitsiak | 57911d1 | 2015-10-20 14:26:34 -0700 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1196 | * Returns a platform configuration for WFC which may override the user |
| 1197 | * setting per slot. Note: WFC presumes that VoLTE is enabled (these are |
| 1198 | * configuration settings which must be done correctly). |
| 1199 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1200 | public boolean isWfcEnabledByPlatform() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1201 | // We first read the per slot value. If doesn't exist, we read the general value. If still |
| 1202 | // doesn't exist, we use the hardcoded default value. |
| 1203 | if (SystemProperties.getInt(PROPERTY_DBG_WFC_AVAIL_OVERRIDE + |
| 1204 | Integer.toString(mPhoneId), SYSTEM_PROPERTY_NOT_SET) == 1 || |
| 1205 | SystemProperties.getInt( |
| 1206 | PROPERTY_DBG_WFC_AVAIL_OVERRIDE, SYSTEM_PROPERTY_NOT_SET) == 1) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1207 | return true; |
| 1208 | } |
| 1209 | |
| 1210 | return mContext.getResources().getBoolean( |
| 1211 | com.android.internal.R.bool.config_device_wfc_ims_available) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1212 | getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1213 | CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1214 | isGbaValid(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1215 | } |
| 1216 | |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1217 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1218 | * If carrier requires that IMS is only available if GBA capable SIM is used, |
| 1219 | * then this function checks GBA bit in EF IST. |
| 1220 | * |
| 1221 | * Format of EF IST is defined in 3GPP TS 31.103 (Section 4.2.7). |
| 1222 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1223 | private boolean isGbaValid() { |
| 1224 | if (getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1225 | CarrierConfigManager.KEY_CARRIER_IMS_GBA_REQUIRED_BOOL)) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1226 | final TelephonyManager telephonyManager = new TelephonyManager(mContext, getSubId()); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1227 | String efIst = telephonyManager.getIsimIst(); |
| 1228 | if (efIst == null) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1229 | loge("isGbaValid - ISF is NULL"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1230 | return true; |
| 1231 | } |
| 1232 | boolean result = efIst != null && efIst.length() > 1 && |
| 1233 | (0x02 & (byte)efIst.charAt(1)) != 0; |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1234 | if (DBG) log("isGbaValid - GBA capable=" + result + ", ISF=" + efIst); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1235 | return result; |
| 1236 | } |
| 1237 | return true; |
| 1238 | } |
| 1239 | |
| 1240 | /** |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1241 | * Will return with config value or throw an ImsException if we receive an error from |
| 1242 | * ImsConfig for that value. |
| 1243 | */ |
| 1244 | private boolean getProvisionedBool(ImsConfig config, int item) throws ImsException { |
| 1245 | int value = config.getProvisionedValue(item); |
| 1246 | if (value == ImsConfig.OperationStatusConstants.UNKNOWN) { |
| 1247 | throw new ImsException("getProvisionedBool failed with error for item: " + item, |
| 1248 | ImsReasonInfo.CODE_LOCAL_INTERNAL_ERROR); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 1249 | } |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1250 | return config.getProvisionedValue(item) == ImsConfig.FeatureValueConstants.ON; |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | /** |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1254 | * Will return with config value or return false if we receive an error from |
| 1255 | * ImsConfig for that value. |
Brad Ebinger | be6cb67 | 2017-08-25 14:55:00 -0700 | [diff] [blame] | 1256 | */ |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1257 | private boolean getProvisionedBoolNoException(int item) { |
| 1258 | try { |
| 1259 | ImsConfig config = getConfigInterface(); |
| 1260 | return getProvisionedBool(config, item); |
| 1261 | } catch (ImsException ex) { |
| 1262 | return false; |
Brad Ebinger | be6cb67 | 2017-08-25 14:55:00 -0700 | [diff] [blame] | 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | /** |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1267 | * Sync carrier config and user settings with ImsConfig. |
| 1268 | * |
| 1269 | * @param context for the manager object |
| 1270 | * @param phoneId phone id |
| 1271 | * @param force update |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1272 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1273 | * @deprecated Doesn't support MSIM devices. Use {@link #updateImsServiceConfig(boolean)} |
| 1274 | * instead. |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1275 | */ |
| 1276 | public static void updateImsServiceConfig(Context context, int phoneId, boolean force) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1277 | ImsManager mgr = ImsManager.getInstance(context, phoneId); |
| 1278 | if (mgr != null) { |
| 1279 | mgr.updateImsServiceConfig(force); |
Pavel Zhamaitsiak | fc20299 | 2016-03-29 18:07:38 -0700 | [diff] [blame] | 1280 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1281 | loge("updateImsServiceConfig: ImsManager null, returning without update."); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1284 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1285 | * Sync carrier config and user settings with ImsConfig. |
| 1286 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1287 | * @param force update |
| 1288 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1289 | public void updateImsServiceConfig(boolean force) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1290 | if (!force) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1291 | TelephonyManager tm = new TelephonyManager(mContext, getSubId()); |
| 1292 | if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) { |
| 1293 | log("updateImsServiceConfig: SIM not ready"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1294 | // Don't disable IMS if SIM is not ready |
| 1295 | return; |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | if (!mConfigUpdated || force) { |
| 1300 | try { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1301 | // TODO: Extend ImsConfig API and set all feature values in single function call. |
| 1302 | |
| 1303 | // Note: currently the order of updates is set to produce different order of |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1304 | // changeEnabledCapabilities() function calls from setAdvanced4GMode(). This is done |
| 1305 | // to differentiate this code path from vendor code perspective. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1306 | boolean isImsUsed = updateVolteFeatureValue(); |
| 1307 | isImsUsed |= updateWfcFeatureAndProvisionedValues(); |
| 1308 | isImsUsed |= updateVideoCallFeatureValue(); |
| 1309 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1310 | if (isImsUsed || !isTurnOffImsAllowedByPlatform()) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1311 | // Turn on IMS if it is used. |
| 1312 | // Also, if turning off is not allowed for current carrier, |
| 1313 | // we need to turn IMS on because it might be turned off before |
| 1314 | // phone switched to current carrier. |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1315 | log("updateImsServiceConfig: turnOnIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1316 | turnOnIms(); |
| 1317 | } else { |
| 1318 | // Turn off IMS if it is not used AND turning off is allowed for carrier. |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1319 | log("updateImsServiceConfig: turnOffIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1320 | turnOffIms(); |
| 1321 | } |
| 1322 | |
| 1323 | mConfigUpdated = true; |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1324 | } catch (ImsException | RemoteException e) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1325 | loge("updateImsServiceConfig: ", e); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1326 | mConfigUpdated = false; |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | /** |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1332 | * Update VoLTE config |
| 1333 | * @return whether feature is On |
| 1334 | * @throws ImsException |
| 1335 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1336 | private boolean updateVolteFeatureValue() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1337 | boolean available = isVolteEnabledByPlatform(); |
| 1338 | boolean enabled = isEnhanced4gLteModeSettingEnabledByUser(); |
| 1339 | boolean isNonTty = isNonTtyOrTtyOnVolteEnabled(); |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1340 | boolean isFeatureOn = available && enabled && isNonTty; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1341 | |
| 1342 | log("updateVolteFeatureValue: available = " + available |
| 1343 | + ", enabled = " + enabled |
| 1344 | + ", nonTTY = " + isNonTty); |
| 1345 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1346 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 1347 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1348 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1349 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1350 | } |
| 1351 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1352 | /** |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1353 | * Update video call over LTE config |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1354 | * @return whether feature is On |
| 1355 | * @throws ImsException |
| 1356 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1357 | private boolean updateVideoCallFeatureValue() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1358 | boolean available = isVtEnabledByPlatform(); |
| 1359 | boolean enabled = isVtEnabledByUser(); |
| 1360 | boolean isNonTty = isNonTtyOrTtyOnVolteEnabled(); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 1361 | boolean isDataEnabled = isDataEnabled(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1362 | boolean ignoreDataEnabledChanged = getBooleanCarrierConfig( |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 1363 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS); |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1364 | |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 1365 | boolean isFeatureOn = available && enabled && isNonTty |
| 1366 | && (ignoreDataEnabledChanged || isDataEnabled); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1367 | |
| 1368 | log("updateVideoCallFeatureValue: available = " + available |
| 1369 | + ", enabled = " + enabled |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1370 | + ", nonTTY = " + isNonTty |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 1371 | + ", data enabled = " + isDataEnabled); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1372 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1373 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 1374 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1375 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1376 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1379 | /** |
| 1380 | * Update WFC config |
| 1381 | * @return whether feature is On |
| 1382 | * @throws ImsException |
| 1383 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1384 | private boolean updateWfcFeatureAndProvisionedValues() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1385 | TelephonyManager tm = new TelephonyManager(mContext, getSubId()); |
| 1386 | boolean isNetworkRoaming = tm.isNetworkRoaming(); |
| 1387 | boolean available = isWfcEnabledByPlatform(); |
| 1388 | boolean enabled = isWfcEnabledByUser(); |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 1389 | updateDefaultWfcMode(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1390 | int mode = getWfcMode(isNetworkRoaming); |
| 1391 | boolean roaming = isWfcRoamingEnabledByUser(); |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1392 | boolean isFeatureOn = available && enabled; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1393 | |
| 1394 | log("updateWfcFeatureAndProvisionedValues: available = " + available |
| 1395 | + ", enabled = " + enabled |
| 1396 | + ", mode = " + mode |
| 1397 | + ", roaming = " + roaming); |
| 1398 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1399 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 1400 | ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, isFeatureOn); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1401 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1402 | if (!isFeatureOn) { |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1403 | mode = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED; |
| 1404 | roaming = false; |
| 1405 | } |
| 1406 | setWfcModeInternal(mContext, mode); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1407 | setWfcRoamingSettingInternal(roaming); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1408 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1409 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1410 | } |
| 1411 | |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1412 | /** |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1413 | * Do NOT use this directly, instead use {@link #getInstance(Context, int)}. |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1414 | */ |
| 1415 | @VisibleForTesting |
| 1416 | public ImsManager(Context context, int phoneId) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1417 | mContext = context; |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 1418 | mPhoneId = phoneId; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1419 | mConfigDynamicBind = mContext.getResources().getBoolean( |
| 1420 | com.android.internal.R.bool.config_dynamic_bind_ims); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1421 | mConfigManager = (CarrierConfigManager) context.getSystemService( |
| 1422 | Context.CARRIER_CONFIG_SERVICE); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1423 | createImsService(); |
| 1424 | } |
| 1425 | |
| 1426 | /** |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1427 | * @return Whether or not ImsManager is configured to Dynamically bind or not to support legacy |
| 1428 | * devices. |
| 1429 | */ |
| 1430 | public boolean isDynamicBinding() { |
| 1431 | return mConfigDynamicBind; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1432 | } |
| 1433 | |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1434 | /* |
Brad Ebinger | 0aed76d | 2018-03-05 16:39:02 -0800 | [diff] [blame] | 1435 | * Returns a flag indicating whether the IMS service is available. If it is not available or |
| 1436 | * busy, it will try to connect before reporting failure. |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1437 | */ |
| 1438 | public boolean isServiceAvailable() { |
Brad Ebinger | 0aed76d | 2018-03-05 16:39:02 -0800 | [diff] [blame] | 1439 | // If we are busy resolving dynamic IMS bindings, we are not available yet. |
| 1440 | TelephonyManager tm = (TelephonyManager) |
| 1441 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 1442 | if (tm.isResolvingImsBinding()) { |
| 1443 | Log.d(TAG, "isServiceAvailable: resolving IMS binding, returning false"); |
| 1444 | return false; |
| 1445 | } |
| 1446 | |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1447 | connectIfServiceIsAvailable(); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1448 | // mImsServiceProxy will always create an ImsServiceProxy. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1449 | return mMmTelFeatureConnection.isBinderAlive(); |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1450 | } |
| 1451 | |
Suresh Koleti | cc3139c | 2017-11-03 18:23:57 +0530 | [diff] [blame] | 1452 | /* |
| 1453 | * Returns a flag indicating whether the IMS service is ready to send requests to lower layers. |
| 1454 | */ |
| 1455 | public boolean isServiceReady() { |
| 1456 | connectIfServiceIsAvailable(); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1457 | return mMmTelFeatureConnection.isBinderReady(); |
Suresh Koleti | cc3139c | 2017-11-03 18:23:57 +0530 | [diff] [blame] | 1458 | } |
| 1459 | |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1460 | /** |
| 1461 | * If the service is available, try to reconnect. |
| 1462 | */ |
| 1463 | public void connectIfServiceIsAvailable() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1464 | if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1465 | createImsService(); |
| 1466 | } |
| 1467 | } |
| 1468 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1469 | public void setConfigListener(ImsConfigListener listener) { |
Pavel Zhamaitsiak | f4b9032 | 2016-01-26 14:34:09 -0800 | [diff] [blame] | 1470 | mImsConfigListener = listener; |
| 1471 | } |
| 1472 | |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1473 | |
| 1474 | /** |
| 1475 | * Adds a callback for status changed events if the binder is already available. If it is not, |
| 1476 | * this method will throw an ImsException. |
| 1477 | */ |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 1478 | @VisibleForTesting |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1479 | public void addNotifyStatusChangedCallbackIfAvailable(MmTelFeatureConnection.IFeatureUpdate c) |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1480 | throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1481 | if (!mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1482 | throw new ImsException("Binder is not active!", |
| 1483 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1484 | } |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1485 | if (c != null) { |
| 1486 | mStatusCallbacks.add(c); |
| 1487 | } |
| 1488 | } |
| 1489 | |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 1490 | void removeNotifyStatusChangedCallback(MmTelFeatureConnection.IFeatureUpdate c) { |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 1491 | if (c != null) { |
| 1492 | mStatusCallbacks.remove(c); |
| 1493 | } else { |
| 1494 | Log.w(TAG, "removeNotifyStatusChangedCallback: callback is null!"); |
| 1495 | } |
| 1496 | } |
| 1497 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1498 | /** |
| 1499 | * Opens the IMS service for making calls and/or receiving generic IMS calls. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1500 | * The caller may make subsequent calls through {@link #makeCall}. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1501 | * The IMS service will register the device to the operator's network with the credentials |
| 1502 | * (from ISIM) periodically in order to receive calls from the operator's network. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1503 | * When the IMS service receives a new call, it will call |
| 1504 | * {@link MmTelFeature.Listener#onIncomingCall} |
| 1505 | * The listener contains a call ID extra {@link #getCallId} and it can be used to take a call. |
| 1506 | * @param listener A {@link MmTelFeature.Listener}, which is the interface the |
| 1507 | * {@link MmTelFeature} uses to notify the framework of updates |
| 1508 | * @throws NullPointerException if {@code listener} is null |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1509 | * @throws ImsException if calling the IMS service results in an error |
| 1510 | * @see #getCallId |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1511 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1512 | public void open(MmTelFeature.Listener listener) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1513 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1514 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1515 | if (listener == null) { |
| 1516 | throw new NullPointerException("listener can't be null"); |
| 1517 | } |
| 1518 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1519 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1520 | mMmTelFeatureConnection.openConnection(listener); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1521 | } catch (RemoteException e) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1522 | throw new ImsException("open()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1523 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
| 1526 | /** |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1527 | * Adds registration listener to the IMS service. |
| 1528 | * |
| 1529 | * @param serviceClass a service class specified in {@link ImsServiceClass} |
| 1530 | * For VoLTE service, it MUST be a {@link ImsServiceClass#MMTEL}. |
| 1531 | * @param listener To listen to IMS registration events; It cannot be null |
| 1532 | * @throws NullPointerException if {@code listener} is null |
| 1533 | * @throws ImsException if calling the IMS service results in an error |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1534 | * |
| 1535 | * @deprecated Use {@link #addRegistrationListener(ImsConnectionStateListener)} instead. |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1536 | */ |
| 1537 | public void addRegistrationListener(int serviceClass, ImsConnectionStateListener listener) |
| 1538 | throws ImsException { |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1539 | addRegistrationListener(listener); |
| 1540 | } |
| 1541 | |
| 1542 | /** |
| 1543 | * Adds registration listener to the IMS service. |
| 1544 | * |
| 1545 | * @param listener To listen to IMS registration events; It cannot be null |
| 1546 | * @throws NullPointerException if {@code listener} is null |
| 1547 | * @throws ImsException if calling the IMS service results in an error |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1548 | * @deprecated use {@link #addRegistrationCallback(ImsRegistrationImplBase.Callback)} and |
| 1549 | * {@link #addCapabilitiesCallback(ImsFeature.CapabilityCallback)} instead. |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1550 | */ |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 1551 | public void addRegistrationListener(ImsConnectionStateListener listener) throws ImsException { |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1552 | if (listener == null) { |
| 1553 | throw new NullPointerException("listener can't be null"); |
| 1554 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1555 | addRegistrationCallback(listener); |
| 1556 | // connect the ImsConnectionStateListener to the new CapabilityCallback. |
| 1557 | addCapabilitiesCallback(new ImsFeature.CapabilityCallback() { |
| 1558 | @Override |
| 1559 | public void onCapabilitiesStatusChanged(ImsFeature.Capabilities config) { |
| 1560 | listener.onFeatureCapabilityChangedAdapter(getRegistrationTech(), config); |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1561 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1562 | }); |
| 1563 | log("Registration Callback registered."); |
| 1564 | } |
| 1565 | |
| 1566 | /** |
| 1567 | * Adds a callback that gets called when IMS registration has changed. |
| 1568 | * @param callback A {@link ImsRegistrationImplBase.Callback} that will notify the caller when |
| 1569 | * IMS registration status has changed. |
| 1570 | * @throws ImsException when the ImsService connection is not available. |
| 1571 | */ |
| 1572 | public void addRegistrationCallback(ImsRegistrationImplBase.Callback callback) |
| 1573 | throws ImsException { |
| 1574 | if (callback == null) { |
| 1575 | throw new NullPointerException("registration callback can't be null"); |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1576 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1577 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1578 | try { |
| 1579 | mMmTelFeatureConnection.addRegistrationCallback(callback); |
| 1580 | log("Registration Callback registered."); |
| 1581 | // Only record if there isn't a RemoteException. |
| 1582 | } catch (RemoteException e) { |
| 1583 | throw new ImsException("addRegistrationCallback(IRIB)", e, |
| 1584 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | /** |
Brad Ebinger | d1b1a3c | 2018-03-08 11:37:35 -0800 | [diff] [blame] | 1589 | * Removes a previously added registration callback that was added via |
| 1590 | * {@link #addRegistrationCallback(ImsRegistrationImplBase.Callback)} . |
| 1591 | * @param callback A {@link ImsRegistrationImplBase.Callback} that was previously added. |
| 1592 | * @throws ImsException when the ImsService connection is not available. |
| 1593 | */ |
| 1594 | public void removeRegistrationListener(ImsRegistrationImplBase.Callback callback) |
| 1595 | throws ImsException { |
| 1596 | if (callback == null) { |
| 1597 | throw new NullPointerException("registration callback can't be null"); |
| 1598 | } |
| 1599 | |
| 1600 | try { |
| 1601 | mMmTelFeatureConnection.removeRegistrationCallback(callback); |
| 1602 | log("Registration callback removed."); |
| 1603 | } catch (RemoteException e) { |
| 1604 | throw new ImsException("removeRegistrationCallback(IRIB)", e, |
| 1605 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | /** |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1610 | * Adds a callback that gets called when MMTel capability status has changed, for example when |
| 1611 | * Voice over IMS or VT over IMS is not available currently. |
| 1612 | * @param callback A {@link ImsFeature.CapabilityCallback} that will notify the caller when |
| 1613 | * MMTel capability status has changed. |
| 1614 | * @throws ImsException when the ImsService connection is not available. |
| 1615 | */ |
| 1616 | public void addCapabilitiesCallback(ImsFeature.CapabilityCallback callback) |
| 1617 | throws ImsException { |
| 1618 | if (callback == null) { |
| 1619 | throw new NullPointerException("capabilities callback can't be null"); |
| 1620 | } |
| 1621 | |
| 1622 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1623 | try { |
| 1624 | mMmTelFeatureConnection.addCapabilityCallback(callback); |
| 1625 | log("Capability Callback registered."); |
| 1626 | // Only record if there isn't a RemoteException. |
| 1627 | } catch (RemoteException e) { |
| 1628 | throw new ImsException("addCapabilitiesCallback(IF)", e, |
| 1629 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | /** |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1634 | * Removes the registration listener from the IMS service. |
| 1635 | * |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1636 | * @param listener Previously registered listener that will be removed. Can not be null. |
| 1637 | * @throws NullPointerException if {@code listener} is null |
| 1638 | * @throws ImsException if calling the IMS service results in an error |
| 1639 | * instead. |
| 1640 | */ |
Brad Ebinger | b5f30c7 | 2017-02-17 14:54:31 -0800 | [diff] [blame] | 1641 | public void removeRegistrationListener(ImsConnectionStateListener listener) |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1642 | throws ImsException { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1643 | if (listener == null) { |
| 1644 | throw new NullPointerException("listener can't be null"); |
| 1645 | } |
| 1646 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1647 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1648 | try { |
| 1649 | mMmTelFeatureConnection.removeRegistrationCallback(listener); |
| 1650 | log("Registration Callback/Listener registered."); |
| 1651 | // Only record if there isn't a RemoteException. |
| 1652 | } catch (RemoteException e) { |
| 1653 | throw new ImsException("addRegistrationCallback()", e, |
| 1654 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1655 | } |
| 1656 | } |
| 1657 | |
| 1658 | public @ImsRegistrationImplBase.ImsRegistrationTech int getRegistrationTech() { |
| 1659 | try { |
| 1660 | return mMmTelFeatureConnection.getRegistrationTech(); |
| 1661 | } catch (RemoteException e) { |
| 1662 | Log.w(TAG, "getRegistrationTech: no connection to ImsService."); |
| 1663 | return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1664 | } |
| 1665 | } |
| 1666 | |
| 1667 | /** |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1668 | * Closes the connection and removes all active callbacks. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1669 | * All the resources that were allocated to the service are also released. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1670 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1671 | public void close() { |
| 1672 | if (mMmTelFeatureConnection != null) { |
| 1673 | mMmTelFeatureConnection.closeConnection(); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1674 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1675 | mUt = null; |
| 1676 | mConfig = null; |
| 1677 | mEcbm = null; |
| 1678 | mMultiEndpoint = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1679 | } |
| 1680 | |
| 1681 | /** |
| 1682 | * Gets the configuration interface to provision / withdraw the supplementary service settings. |
| 1683 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1684 | * @return the Ut interface instance |
| 1685 | * @throws ImsException if getting the Ut interface results in an error |
| 1686 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1687 | public ImsUtInterface getSupplementaryServiceConfiguration() throws ImsException { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1688 | // FIXME: manage the multiple Ut interfaces based on the session id |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1689 | if (mUt != null && mUt.isBinderAlive()) { |
| 1690 | return mUt; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1691 | } |
| 1692 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1693 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1694 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1695 | IImsUt iUt = mMmTelFeatureConnection.getUtInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1696 | |
| 1697 | if (iUt == null) { |
| 1698 | throw new ImsException("getSupplementaryServiceConfiguration()", |
| 1699 | ImsReasonInfo.CODE_UT_NOT_SUPPORTED); |
| 1700 | } |
| 1701 | |
| 1702 | mUt = new ImsUt(iUt); |
| 1703 | } catch (RemoteException e) { |
| 1704 | throw new ImsException("getSupplementaryServiceConfiguration()", e, |
| 1705 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1706 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1707 | return mUt; |
| 1708 | } |
| 1709 | |
| 1710 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1711 | * Creates a {@link ImsCallProfile} from the service capabilities & IMS registration state. |
| 1712 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1713 | * @param serviceType a service type that is specified in {@link ImsCallProfile} |
| 1714 | * {@link ImsCallProfile#SERVICE_TYPE_NONE} |
| 1715 | * {@link ImsCallProfile#SERVICE_TYPE_NORMAL} |
| 1716 | * {@link ImsCallProfile#SERVICE_TYPE_EMERGENCY} |
| 1717 | * @param callType a call type that is specified in {@link ImsCallProfile} |
| 1718 | * {@link ImsCallProfile#CALL_TYPE_VOICE} |
| 1719 | * {@link ImsCallProfile#CALL_TYPE_VT} |
| 1720 | * {@link ImsCallProfile#CALL_TYPE_VT_TX} |
| 1721 | * {@link ImsCallProfile#CALL_TYPE_VT_RX} |
| 1722 | * {@link ImsCallProfile#CALL_TYPE_VT_NODIR} |
| 1723 | * {@link ImsCallProfile#CALL_TYPE_VS} |
| 1724 | * {@link ImsCallProfile#CALL_TYPE_VS_TX} |
| 1725 | * {@link ImsCallProfile#CALL_TYPE_VS_RX} |
| 1726 | * @return a {@link ImsCallProfile} object |
| 1727 | * @throws ImsException if calling the IMS service results in an error |
| 1728 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1729 | public ImsCallProfile createCallProfile(int serviceType, int callType) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1730 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1731 | |
| 1732 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1733 | return mMmTelFeatureConnection.createCallProfile(serviceType, callType); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1734 | } catch (RemoteException e) { |
| 1735 | throw new ImsException("createCallProfile()", e, |
| 1736 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | /** |
| 1741 | * Creates a {@link ImsCall} to make a call. |
| 1742 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1743 | * @param profile a call profile to make the call |
| 1744 | * (it contains service type, call type, media information, etc.) |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1745 | * @param callees participants to invite the conference call |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1746 | * @param listener listen to the call events from {@link ImsCall} |
| 1747 | * @return a {@link ImsCall} object |
| 1748 | * @throws ImsException if calling the IMS service results in an error |
| 1749 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1750 | public ImsCall makeCall(ImsCallProfile profile, String[] callees, |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1751 | ImsCall.Listener listener) throws ImsException { |
| 1752 | if (DBG) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1753 | log("makeCall :: profile=" + profile); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1754 | } |
| 1755 | |
| 1756 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1757 | |
| 1758 | ImsCall call = new ImsCall(mContext, profile); |
| 1759 | |
| 1760 | call.setListener(listener); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1761 | ImsCallSession session = createCallSession(profile); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1762 | |
| 1763 | if ((callees != null) && (callees.length == 1)) { |
| 1764 | call.start(session, callees[0]); |
| 1765 | } else { |
| 1766 | call.start(session, callees); |
| 1767 | } |
| 1768 | |
| 1769 | return call; |
| 1770 | } |
| 1771 | |
| 1772 | /** |
| 1773 | * Creates a {@link ImsCall} to take an incoming call. |
| 1774 | * |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1775 | * @param sessionId a session id which is obtained from {@link ImsManager#open} |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1776 | * @param incomingCallExtras the incoming call broadcast intent |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1777 | * @param listener to listen to the call events from {@link ImsCall} |
| 1778 | * @return a {@link ImsCall} object |
| 1779 | * @throws ImsException if calling the IMS service results in an error |
| 1780 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1781 | public ImsCall takeCall(IImsCallSession session, Bundle incomingCallExtras, |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1782 | ImsCall.Listener listener) throws ImsException { |
| 1783 | if (DBG) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1784 | log("takeCall :: incomingCall=" + incomingCallExtras); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1788 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1789 | if (incomingCallExtras == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1790 | throw new ImsException("Can't retrieve session with null intent", |
| 1791 | ImsReasonInfo.CODE_LOCAL_ILLEGAL_ARGUMENT); |
| 1792 | } |
| 1793 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1794 | String callId = getCallId(incomingCallExtras); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1795 | |
| 1796 | if (callId == null) { |
| 1797 | throw new ImsException("Call ID missing in the incoming call intent", |
| 1798 | ImsReasonInfo.CODE_LOCAL_ILLEGAL_ARGUMENT); |
| 1799 | } |
| 1800 | |
| 1801 | try { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1802 | if (session == null) { |
| 1803 | throw new ImsException("No pending session for the call", |
| 1804 | ImsReasonInfo.CODE_LOCAL_NO_PENDING_CALL); |
| 1805 | } |
| 1806 | |
| 1807 | ImsCall call = new ImsCall(mContext, session.getCallProfile()); |
| 1808 | |
| 1809 | call.attachSession(new ImsCallSession(session)); |
| 1810 | call.setListener(listener); |
| 1811 | |
| 1812 | return call; |
| 1813 | } catch (Throwable t) { |
| 1814 | throw new ImsException("takeCall()", t, ImsReasonInfo.CODE_UNSPECIFIED); |
| 1815 | } |
| 1816 | } |
| 1817 | |
| 1818 | /** |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1819 | * Gets the config interface to get/set service/capability parameters. |
| 1820 | * |
| 1821 | * @return the ImsConfig instance. |
| 1822 | * @throws ImsException if getting the setting interface results in an error. |
| 1823 | */ |
| 1824 | public ImsConfig getConfigInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1825 | if (mConfig != null && mConfig.isBinderAlive()) { |
| 1826 | return mConfig; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1827 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1828 | |
| 1829 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1830 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1831 | IImsConfig config = mMmTelFeatureConnection.getConfigInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1832 | if (config == null) { |
| 1833 | throw new ImsException("getConfigInterface()", |
| 1834 | ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); |
| 1835 | } |
| 1836 | mConfig = new ImsConfig(config, mContext); |
| 1837 | } catch (RemoteException e) { |
| 1838 | throw new ImsException("getConfigInterface()", e, |
| 1839 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1840 | } |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1841 | return mConfig; |
| 1842 | } |
| 1843 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1844 | public void changeMmTelCapability( |
| 1845 | @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, |
| 1846 | @ImsRegistrationImplBase.ImsRegistrationTech int radioTech, |
| 1847 | boolean isEnabled) throws RemoteException { |
| 1848 | CapabilityChangeRequest request = new CapabilityChangeRequest(); |
| 1849 | if (isEnabled) { |
| 1850 | request.addCapabilitiesToEnableForTech(capability, radioTech); |
| 1851 | } else { |
| 1852 | request.addCapabilitiesToDisableForTech(capability, radioTech); |
| 1853 | } |
| 1854 | mMmTelFeatureConnection.changeEnabledCapabilities(request, null); |
| 1855 | if (mImsConfigListener != null) { |
| 1856 | mImsConfigListener.onSetFeatureResponse(capability, |
| 1857 | mMmTelFeatureConnection.getRegistrationTech(), |
| 1858 | isEnabled ? ImsConfig.FeatureValueConstants.ON |
| 1859 | : ImsConfig.FeatureValueConstants.OFF, -1); |
| 1860 | } |
| 1861 | } |
| 1862 | |
Hall Liu | b77d897 | 2018-01-22 19:15:05 -0800 | [diff] [blame] | 1863 | public void setRttEnabled(boolean enabled) { |
| 1864 | try { |
| 1865 | setAdvanced4GMode(enabled || isEnhanced4gLteModeSettingEnabledByUser()); |
| 1866 | final int value = enabled ? ImsConfig.FeatureValueConstants.ON : |
| 1867 | ImsConfig.FeatureValueConstants.OFF; |
| 1868 | Thread thread = new Thread(() -> { |
| 1869 | try { |
| 1870 | Log.i(ImsManager.class.getSimpleName(), "Setting RTT enabled to " + enabled); |
| 1871 | getConfigInterface().setProvisionedValue( |
| 1872 | ImsConfig.ConfigConstants.RTT_SETTING_ENABLED, value); |
| 1873 | } catch (ImsException e) { |
| 1874 | Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT enabled to " |
| 1875 | + enabled + ": " + e); |
| 1876 | } |
| 1877 | }); |
| 1878 | thread.start(); |
| 1879 | } catch (ImsException e) { |
| 1880 | Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT enabled to " + enabled |
| 1881 | + ": " + e); |
| 1882 | } |
| 1883 | } |
| 1884 | |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1885 | /** |
| 1886 | * Set the TTY mode. This is the actual tty mode (varies depending on peripheral status) |
| 1887 | */ |
| 1888 | public void setTtyMode(int ttyMode) throws ImsException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1889 | if (!getBooleanCarrierConfig( |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1890 | CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) { |
| 1891 | setAdvanced4GMode((ttyMode == TelecomManager.TTY_MODE_OFF) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1892 | isEnhanced4gLteModeSettingEnabledByUser()); |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1893 | } |
| 1894 | } |
| 1895 | |
| 1896 | /** |
| 1897 | * Sets the UI TTY mode. This is the preferred TTY mode that the user sets in the call |
| 1898 | * settings screen. |
| 1899 | */ |
Brad Ebinger | b5f30c7 | 2017-02-17 14:54:31 -0800 | [diff] [blame] | 1900 | public void setUiTTYMode(Context context, int uiTtyMode, Message onComplete) |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1901 | throws ImsException { |
| 1902 | |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1903 | checkAndThrowExceptionIfServiceUnavailable(); |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1904 | |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1905 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1906 | mMmTelFeatureConnection.setUiTTYMode(uiTtyMode, onComplete); |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1907 | } catch (RemoteException e) { |
| 1908 | throw new ImsException("setTTYMode()", e, |
| 1909 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1910 | } |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1911 | } |
| 1912 | |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 1913 | private ImsReasonInfo makeACopy(ImsReasonInfo imsReasonInfo) { |
| 1914 | Parcel p = Parcel.obtain(); |
| 1915 | imsReasonInfo.writeToParcel(p, 0); |
| 1916 | p.setDataPosition(0); |
| 1917 | ImsReasonInfo clonedReasonInfo = ImsReasonInfo.CREATOR.createFromParcel(p); |
| 1918 | p.recycle(); |
| 1919 | return clonedReasonInfo; |
| 1920 | } |
| 1921 | |
| 1922 | /** |
| 1923 | * Get Recent IMS Disconnect Reasons. |
| 1924 | * |
| 1925 | * @return ArrayList of ImsReasonInfo objects. MAX size of the arraylist |
| 1926 | * is MAX_RECENT_DISCONNECT_REASONS. The objects are in the |
| 1927 | * chronological order. |
| 1928 | */ |
| 1929 | public ArrayList<ImsReasonInfo> getRecentImsDisconnectReasons() { |
| 1930 | ArrayList<ImsReasonInfo> disconnectReasons = new ArrayList<>(); |
| 1931 | |
| 1932 | for (ImsReasonInfo reason : mRecentDisconnectReasons) { |
| 1933 | disconnectReasons.add(makeACopy(reason)); |
| 1934 | } |
| 1935 | return disconnectReasons; |
| 1936 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1937 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1938 | public int getImsServiceState() throws ImsException { |
| 1939 | return mMmTelFeatureConnection.getFeatureState(); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1940 | } |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 1941 | |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1942 | /** |
Junda Liu | e7663c0 | 2015-06-23 11:16:26 -0700 | [diff] [blame] | 1943 | * Get the boolean config from carrier config manager. |
| 1944 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1945 | * @param key config key defined in CarrierConfigManager |
| 1946 | * @return boolean value of corresponding key. |
| 1947 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1948 | private boolean getBooleanCarrierConfig(String key) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1949 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1950 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1951 | if (subIds != null && subIds.length >= 1) { |
| 1952 | subId = subIds[0]; |
| 1953 | } |
| 1954 | PersistableBundle b = null; |
| 1955 | if (mConfigManager != null) { |
| 1956 | // If an invalid subId is used, this bundle will contain default values. |
| 1957 | b = mConfigManager.getConfigForSubId(subId); |
| 1958 | } |
| 1959 | if (b != null) { |
| 1960 | return b.getBoolean(key); |
| 1961 | } else { |
| 1962 | // Return static default defined in CarrierConfigManager. |
| 1963 | return CarrierConfigManager.getDefaultConfig().getBoolean(key); |
| 1964 | } |
| 1965 | } |
| 1966 | |
| 1967 | /** |
fionaxu | 5803ef0 | 2016-03-08 11:48:48 -0800 | [diff] [blame] | 1968 | * Get the int config from carrier config manager. |
| 1969 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1970 | * @param key config key defined in CarrierConfigManager |
| 1971 | * @return integer value of corresponding key. |
| 1972 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1973 | private int getIntCarrierConfig(String key) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1974 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1975 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1976 | if (subIds != null && subIds.length >= 1) { |
| 1977 | subId = subIds[0]; |
| 1978 | } |
| 1979 | PersistableBundle b = null; |
| 1980 | if (mConfigManager != null) { |
| 1981 | // If an invalid subId is used, this bundle will contain default values. |
| 1982 | b = mConfigManager.getConfigForSubId(subId); |
| 1983 | } |
| 1984 | if (b != null) { |
| 1985 | return b.getInt(key); |
| 1986 | } else { |
| 1987 | // Return static default defined in CarrierConfigManager. |
| 1988 | return CarrierConfigManager.getDefaultConfig().getInt(key); |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1993 | * Gets the call ID from the specified incoming call broadcast intent. |
| 1994 | * |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1995 | * @param incomingCallExtras the incoming call broadcast intent |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1996 | * @return the call ID or null if the intent does not contain it |
| 1997 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1998 | private static String getCallId(Bundle incomingCallExtras) { |
| 1999 | if (incomingCallExtras == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2000 | return null; |
| 2001 | } |
| 2002 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2003 | return incomingCallExtras.getString(EXTRA_CALL_ID); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | /** |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 2007 | * Checks to see if the ImsService Binder is connected. If it is not, we try to create the |
| 2008 | * connection again. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2009 | */ |
| 2010 | private void checkAndThrowExceptionIfServiceUnavailable() |
| 2011 | throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2012 | if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 2013 | createImsService(); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2014 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2015 | if (mMmTelFeatureConnection == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2016 | throw new ImsException("Service is unavailable", |
| 2017 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2018 | } |
| 2019 | } |
| 2020 | } |
| 2021 | |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 2022 | /** |
| 2023 | * Binds the IMS service to make/receive the call. Supports two methods of exposing an |
| 2024 | * ImsService: |
| 2025 | * 1) com.android.ims.ImsService implementation in ServiceManager (deprecated). |
| 2026 | * 2) android.telephony.ims.ImsService implementation through ImsResolver. |
| 2027 | */ |
| 2028 | private void createImsService() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2029 | Rlog.i(TAG, "Creating ImsService"); |
| 2030 | mMmTelFeatureConnection = MmTelFeatureConnection.create(mContext, mPhoneId); |
| 2031 | |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2032 | // Forwarding interface to tell mStatusCallbacks that the Proxy is unavailable. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2033 | mMmTelFeatureConnection.setStatusCallback(new MmTelFeatureConnection.IFeatureUpdate() { |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2034 | @Override |
| 2035 | public void notifyStateChanged() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2036 | mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyStateChanged); |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2037 | } |
| 2038 | |
| 2039 | @Override |
| 2040 | public void notifyUnavailable() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2041 | mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyUnavailable); |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2042 | } |
| 2043 | }); |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 2044 | } |
| 2045 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2046 | /** |
| 2047 | * Creates a {@link ImsCallSession} with the specified call profile. |
| 2048 | * Use other methods, if applicable, instead of interacting with |
| 2049 | * {@link ImsCallSession} directly. |
| 2050 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2051 | * @param profile a call profile to make the call |
| 2052 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2053 | private ImsCallSession createCallSession(ImsCallProfile profile) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2054 | try { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 2055 | // Throws an exception if the ImsService Feature is not ready to accept commands. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2056 | return new ImsCallSession(mMmTelFeatureConnection.createCallSession(profile)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2057 | } catch (RemoteException e) { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 2058 | Rlog.w(TAG, "CreateCallSession: Error, remote exception: " + e.getMessage()); |
| 2059 | throw new ImsException("createCallSession()", e, |
| 2060 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2061 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2062 | } |
| 2063 | } |
| 2064 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2065 | private static void log(String s) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2066 | Rlog.d(TAG, s); |
| 2067 | } |
| 2068 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2069 | private static void loge(String s) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2070 | Rlog.e(TAG, s); |
| 2071 | } |
| 2072 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2073 | private static void loge(String s, Throwable t) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2074 | Rlog.e(TAG, s, t); |
| 2075 | } |
| 2076 | |
| 2077 | /** |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2078 | * Used for turning on IMS.if its off already |
| 2079 | */ |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 2080 | private void turnOnIms() throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2081 | TelephonyManager tm = (TelephonyManager) |
| 2082 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 2083 | tm.enableIms(mPhoneId); |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2084 | } |
| 2085 | |
Omkar Kolangade | 75f3ca3 | 2014-10-24 11:10:52 -0700 | [diff] [blame] | 2086 | private boolean isImsTurnOffAllowed() { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2087 | return isTurnOffImsAllowedByPlatform() |
| 2088 | && (!isWfcEnabledByPlatform() |
| 2089 | || !isWfcEnabledByUser()); |
Omkar Kolangade | 75f3ca3 | 2014-10-24 11:10:52 -0700 | [diff] [blame] | 2090 | } |
| 2091 | |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2092 | private void setLteFeatureValues(boolean turnOn) { |
| 2093 | log("setLteFeatureValues: " + turnOn); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2094 | CapabilityChangeRequest request = new CapabilityChangeRequest(); |
| 2095 | if (turnOn) { |
| 2096 | request.addCapabilitiesToEnableForTech( |
| 2097 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 2098 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2099 | } else { |
| 2100 | request.addCapabilitiesToDisableForTech( |
| 2101 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 2102 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2103 | } |
Pavel Zhamaitsiak | ff29b9d | 2016-04-15 12:16:57 -0700 | [diff] [blame] | 2104 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2105 | if (isVolteEnabledByPlatform()) { |
| 2106 | boolean ignoreDataEnabledChanged = getBooleanCarrierConfig( |
| 2107 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS); |
| 2108 | boolean enableViLte = turnOn && isVtEnabledByUser() && |
| 2109 | (ignoreDataEnabledChanged || isDataEnabled()); |
| 2110 | if (enableViLte) { |
| 2111 | request.addCapabilitiesToEnableForTech( |
| 2112 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 2113 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2114 | } else { |
| 2115 | request.addCapabilitiesToDisableForTech( |
| 2116 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 2117 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
Etan Cohen | b651fa5 | 2014-10-22 10:51:29 -0700 | [diff] [blame] | 2118 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2119 | } |
| 2120 | try { |
| 2121 | mMmTelFeatureConnection.changeEnabledCapabilities(request, null); |
| 2122 | } catch (RemoteException e) { |
| 2123 | Log.e(TAG, "setLteFeatureValues: Exception: " + e.getMessage()); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2124 | } |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2125 | } |
| 2126 | |
| 2127 | private void setAdvanced4GMode(boolean turnOn) throws ImsException { |
| 2128 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2129 | |
| 2130 | // if turnOn: first set feature values then call turnOnIms() |
| 2131 | // if turnOff: only set feature values if IMS turn off is not allowed. If turn off is |
| 2132 | // allowed, first call turnOffIms() then set feature values |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2133 | if (turnOn) { |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2134 | setLteFeatureValues(turnOn); |
| 2135 | log("setAdvanced4GMode: turnOnIms"); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2136 | turnOnIms(); |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2137 | } else { |
| 2138 | if (isImsTurnOffAllowed()) { |
| 2139 | log("setAdvanced4GMode: turnOffIms"); |
| 2140 | turnOffIms(); |
| 2141 | } |
| 2142 | setLteFeatureValues(turnOn); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2143 | } |
| 2144 | } |
| 2145 | |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2146 | /** |
| 2147 | * Used for turning off IMS completely in order to make the device CSFB'ed. |
| 2148 | * Once turned off, all calls will be over CS. |
| 2149 | */ |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 2150 | private void turnOffIms() throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2151 | TelephonyManager tm = (TelephonyManager) |
| 2152 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 2153 | tm.disableIms(mPhoneId); |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2154 | } |
| 2155 | |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 2156 | private void addToRecentDisconnectReasons(ImsReasonInfo reason) { |
| 2157 | if (reason == null) return; |
| 2158 | while (mRecentDisconnectReasons.size() >= MAX_RECENT_DISCONNECT_REASONS) { |
| 2159 | mRecentDisconnectReasons.removeFirst(); |
| 2160 | } |
| 2161 | mRecentDisconnectReasons.addLast(reason); |
| 2162 | } |
| 2163 | |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2164 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2165 | * Death recipient class for monitoring IMS service. |
| 2166 | */ |
| 2167 | private class ImsServiceDeathRecipient implements IBinder.DeathRecipient { |
| 2168 | @Override |
| 2169 | public void binderDied() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2170 | mMmTelFeatureConnection = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2171 | mUt = null; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 2172 | mConfig = null; |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2173 | mEcbm = null; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2174 | mMultiEndpoint = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2175 | } |
| 2176 | } |
| 2177 | |
| 2178 | /** |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2179 | * Gets the ECBM interface to request ECBM exit. |
| 2180 | * |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2181 | * @return the ECBM interface instance |
| 2182 | * @throws ImsException if getting the ECBM interface results in an error |
| 2183 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2184 | public ImsEcbm getEcbmInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2185 | if (mEcbm != null && mEcbm.isBinderAlive()) { |
| 2186 | return mEcbm; |
| 2187 | } |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2188 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2189 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2190 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2191 | IImsEcbm iEcbm = mMmTelFeatureConnection.getEcbmInterface(); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2192 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2193 | if (iEcbm == null) { |
| 2194 | throw new ImsException("getEcbmInterface()", |
| 2195 | ImsReasonInfo.CODE_ECBM_NOT_SUPPORTED); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2196 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2197 | mEcbm = new ImsEcbm(iEcbm); |
| 2198 | } catch (RemoteException e) { |
| 2199 | throw new ImsException("getEcbmInterface()", e, |
| 2200 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2201 | } |
| 2202 | return mEcbm; |
| 2203 | } |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2204 | |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2205 | public void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry, |
| 2206 | byte[] pdu) throws ImsException { |
| 2207 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2208 | mMmTelFeatureConnection.sendSms(token, messageRef, format, smsc, isRetry, pdu); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2209 | } catch (RemoteException e) { |
| 2210 | throw new ImsException("sendSms()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | public void acknowledgeSms(int token, int messageRef, int result) throws ImsException { |
| 2215 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2216 | mMmTelFeatureConnection.acknowledgeSms(token, messageRef, result); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2217 | } catch (RemoteException e) { |
| 2218 | throw new ImsException("acknowledgeSms()", e, |
| 2219 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | public void acknowledgeSmsReport(int token, int messageRef, int result) throws ImsException{ |
| 2224 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2225 | mMmTelFeatureConnection.acknowledgeSmsReport(token, messageRef, result); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2226 | } catch (RemoteException e) { |
| 2227 | throw new ImsException("acknowledgeSmsReport()", e, |
| 2228 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2229 | } |
| 2230 | } |
| 2231 | |
| 2232 | public String getSmsFormat() throws ImsException{ |
| 2233 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2234 | return mMmTelFeatureConnection.getSmsFormat(); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2235 | } catch (RemoteException e) { |
| 2236 | throw new ImsException("getSmsFormat()", e, |
| 2237 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2238 | } |
| 2239 | } |
| 2240 | |
| 2241 | public void setSmsListener(IImsSmsListener listener) throws ImsException { |
| 2242 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2243 | mMmTelFeatureConnection.setSmsListener(listener); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2244 | } catch (RemoteException e) { |
| 2245 | throw new ImsException("setSmsListener()", e, |
| 2246 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2247 | } |
| 2248 | } |
Mohamed Abdalkader | e1453f4 | 2018-01-19 19:48:31 -0800 | [diff] [blame] | 2249 | |
Brad Ebinger | d449b23 | 2018-02-12 14:33:05 -0800 | [diff] [blame] | 2250 | public void onSmsReady() throws ImsException { |
Mohamed Abdalkader | 0e734e1 | 2018-01-23 13:11:00 -0800 | [diff] [blame] | 2251 | try { |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 2252 | mMmTelFeatureConnection.onSmsReady(); |
Mohamed Abdalkader | 0e734e1 | 2018-01-23 13:11:00 -0800 | [diff] [blame] | 2253 | } catch (RemoteException e) { |
| 2254 | throw new ImsException("onSmsReady()", e, |
| 2255 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2256 | } |
| 2257 | } |
| 2258 | |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2259 | /** |
Brad Ebinger | d449b23 | 2018-02-12 14:33:05 -0800 | [diff] [blame] | 2260 | * Determines whether or not a call with the specified numbers should be placed over IMS or over |
| 2261 | * CSFB. |
| 2262 | * @param isEmergency is at least one call an emergency number. |
| 2263 | * @param numbers A {@link String} array containing the numbers in the call being placed. Can |
| 2264 | * be multiple numbers in the case of dialing out a conference. |
| 2265 | * @return The result of the query, one of the following values: |
| 2266 | * - {@link MmTelFeature#PROCESS_CALL_IMS} |
| 2267 | * - {@link MmTelFeature#PROCESS_CALL_CSFB} |
| 2268 | * @throws ImsException if the ImsService is not available. In this case, we should fall back |
| 2269 | * to CSFB anyway. |
| 2270 | */ |
| 2271 | public @MmTelFeature.ProcessCallResult int shouldProcessCall(boolean isEmergency, |
| 2272 | String[] numbers) throws ImsException { |
| 2273 | try { |
| 2274 | return mMmTelFeatureConnection.shouldProcessCall(isEmergency, numbers); |
| 2275 | } catch (RemoteException e) { |
| 2276 | throw new ImsException("shouldProcessCall()", e, |
| 2277 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2278 | } |
| 2279 | } |
| 2280 | |
| 2281 | /** |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2282 | * Gets the Multi-Endpoint interface to subscribe to multi-enpoint notifications.. |
| 2283 | * |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2284 | * @return the multi-endpoint interface instance |
| 2285 | * @throws ImsException if getting the multi-endpoint interface results in an error |
| 2286 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2287 | public ImsMultiEndpoint getMultiEndpointInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2288 | if (mMultiEndpoint != null && mMultiEndpoint.isBinderAlive()) { |
| 2289 | return mMultiEndpoint; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2290 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2291 | |
| 2292 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2293 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2294 | IImsMultiEndpoint iImsMultiEndpoint = mMmTelFeatureConnection.getMultiEndpointInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2295 | |
| 2296 | if (iImsMultiEndpoint == null) { |
| 2297 | throw new ImsException("getMultiEndpointInterface()", |
| 2298 | ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED); |
| 2299 | } |
| 2300 | mMultiEndpoint = new ImsMultiEndpoint(iImsMultiEndpoint); |
| 2301 | } catch (RemoteException e) { |
| 2302 | throw new ImsException("getMultiEndpointInterface()", e, |
| 2303 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2304 | } |
| 2305 | |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2306 | return mMultiEndpoint; |
| 2307 | } |
| 2308 | |
| 2309 | /** |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2310 | * Resets ImsManager settings back to factory defaults. |
| 2311 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2312 | * @deprecated Doesn't support MSIM devices. Use {@link #factoryReset()} instead. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2313 | * |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2314 | * @hide |
| 2315 | */ |
| 2316 | public static void factoryReset(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2317 | ImsManager mgr = ImsManager.getInstance(context, |
| 2318 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 2319 | if (mgr != null) { |
| 2320 | mgr.factoryReset(); |
| 2321 | } |
| 2322 | loge("factoryReset: ImsManager null."); |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2323 | } |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2324 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2325 | /** |
| 2326 | * Resets ImsManager settings back to factory defaults. |
| 2327 | * |
| 2328 | * @hide |
| 2329 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2330 | public void factoryReset() { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2331 | // Set VoLTE to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2332 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 2333 | SubscriptionManager.ENHANCED_4G_MODE_ENABLED, |
| 2334 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2335 | CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2336 | |
| 2337 | // Set VoWiFi to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2338 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2339 | SubscriptionManager.WFC_IMS_ENABLED, |
| 2340 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2341 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2342 | |
| 2343 | // Set VoWiFi mode to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2344 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2345 | SubscriptionManager.WFC_IMS_MODE, |
| 2346 | Integer.toString(getIntCarrierConfig( |
| 2347 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2348 | |
| 2349 | // Set VoWiFi roaming to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2350 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2351 | SubscriptionManager.WFC_IMS_ROAMING_ENABLED, |
| 2352 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2353 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2354 | |
| 2355 | // Set VT to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2356 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2357 | SubscriptionManager.VT_IMS_ENABLED, booleanToPropertyString(true)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2358 | |
| 2359 | // Push settings to ImsConfig |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2360 | updateImsServiceConfig(true); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2361 | } |
| 2362 | |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2363 | private boolean isDataEnabled() { |
Malcolm Chen | b8cd440 | 2018-03-23 18:51:51 -0700 | [diff] [blame] | 2364 | return new TelephonyManager(mContext, getSubId()).isDataCapable(); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2365 | } |
| 2366 | |
| 2367 | private boolean isVolteProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2368 | return getProvisionedBoolNoException( |
| 2369 | ImsConfig.ConfigConstants.VLT_SETTING_ENABLED); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2370 | } |
| 2371 | |
| 2372 | private boolean isWfcProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2373 | return getProvisionedBoolNoException( |
| 2374 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2375 | } |
| 2376 | |
| 2377 | private boolean isVtProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2378 | return getProvisionedBoolNoException( |
| 2379 | ImsConfig.ConfigConstants.LVC_SETTING_ENABLED); |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 2380 | } |
| 2381 | |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2382 | private static String booleanToPropertyString(boolean bool) { |
| 2383 | return bool ? "1" : "0"; |
| 2384 | } |
| 2385 | |
| 2386 | |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2387 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 2388 | pw.println("ImsManager:"); |
| 2389 | pw.println(" mPhoneId = " + mPhoneId); |
| 2390 | pw.println(" mConfigUpdated = " + mConfigUpdated); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2391 | pw.println(" mImsServiceProxy = " + mMmTelFeatureConnection); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2392 | pw.println(" mDataEnabled = " + isDataEnabled()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2393 | pw.println(" ignoreDataEnabledChanged = " + getBooleanCarrierConfig( |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 2394 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2395 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2396 | pw.println(" isGbaValid = " + isGbaValid()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2397 | pw.println(" isImsTurnOffAllowed = " + isImsTurnOffAllowed()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2398 | pw.println(" isNonTtyOrTtyOnVolteEnabled = " + isNonTtyOrTtyOnVolteEnabled()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2399 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2400 | pw.println(" isVolteEnabledByPlatform = " + isVolteEnabledByPlatform()); |
| 2401 | pw.println(" isVolteProvisionedOnDevice = " + isVolteProvisionedOnDevice()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2402 | pw.println(" isEnhanced4gLteModeSettingEnabledByUser = " + |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2403 | isEnhanced4gLteModeSettingEnabledByUser()); |
| 2404 | pw.println(" isVtEnabledByPlatform = " + isVtEnabledByPlatform()); |
| 2405 | pw.println(" isVtEnabledByUser = " + isVtEnabledByUser()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2406 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2407 | pw.println(" isWfcEnabledByPlatform = " + isWfcEnabledByPlatform()); |
| 2408 | pw.println(" isWfcEnabledByUser = " + isWfcEnabledByUser()); |
| 2409 | pw.println(" getWfcMode = " + getWfcMode()); |
| 2410 | pw.println(" isWfcRoamingEnabledByUser = " + isWfcRoamingEnabledByUser()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2411 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2412 | pw.println(" isVtProvisionedOnDevice = " + isVtProvisionedOnDevice()); |
| 2413 | pw.println(" isWfcProvisionedOnDevice = " + isWfcProvisionedOnDevice()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2414 | pw.flush(); |
| 2415 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2416 | } |