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 | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 774 | } else if (isVolteEnabledByPlatform() |
| 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 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 878 | setWfcNonPersistent(enabled, getWfcMode()); |
Meng Wang | 51c0907 | 2017-03-27 10:47:45 -0700 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | /** |
| 882 | * Non-persistently change WFC enabled setting and WFC mode for slot |
| 883 | * |
| 884 | * @param wfcMode The WFC preference if WFC is enabled |
| 885 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 886 | public void setWfcNonPersistent(boolean enabled, int wfcMode) { |
Meng Wang | 51c0907 | 2017-03-27 10:47:45 -0700 | [diff] [blame] | 887 | // Force IMS to register over LTE when turning off WFC |
| 888 | int imsWfcModeFeatureValue = |
| 889 | enabled ? wfcMode : ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED; |
| 890 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 891 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 892 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 893 | ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, enabled); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 894 | |
| 895 | if (enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 896 | log("setWfcSetting() : turnOnIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 897 | turnOnIms(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 898 | } else if (isTurnOffImsAllowedByPlatform() |
| 899 | && (!isVolteEnabledByPlatform() |
| 900 | || !isEnhanced4gLteModeSettingEnabledByUser())) { |
| 901 | log("setWfcSetting() : imsServiceAllowTurnOff -> turnOffIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 902 | turnOffIms(); |
| 903 | } |
| 904 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 905 | setWfcModeInternal(imsWfcModeFeatureValue); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 906 | } catch (ImsException | RemoteException e) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 907 | loge("setWfcSetting(): ", e); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 908 | } |
| 909 | } |
| 910 | |
| 911 | /** |
| 912 | * Returns the user configuration of WFC preference setting. |
| 913 | * |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 914 | * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean roaming)} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 915 | */ |
| 916 | public static int getWfcMode(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 917 | ImsManager mgr = ImsManager.getInstance(context, |
| 918 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 919 | if (mgr != null) { |
| 920 | return mgr.getWfcMode(); |
| 921 | } |
| 922 | loge("getWfcMode: ImsManager null, returning default value."); |
| 923 | return ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 927 | * Returns the user configuration of WFC preference setting |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 928 | * @deprecated. Use {@link #getWfcMode(boolean roaming)} instead. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 929 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 930 | public int getWfcMode() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 931 | return getWfcMode(false); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | /** |
| 935 | * Change persistent WFC preference setting. |
| 936 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 937 | * @deprecated Doesn't support MSIM devices. Use {@link #setWfcMode(int)} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 938 | */ |
| 939 | public static void setWfcMode(Context context, int wfcMode) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 940 | ImsManager mgr = ImsManager.getInstance(context, |
| 941 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 942 | if (mgr != null) { |
| 943 | mgr.setWfcMode(wfcMode); |
| 944 | } |
| 945 | loge("setWfcMode: ImsManager null, can not set value."); |
Pavel Zhamaitsiak | 9e6eca2 | 2015-03-16 15:30:53 -0700 | [diff] [blame] | 946 | } |
| 947 | |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 948 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 949 | * Change persistent WFC preference setting for slot. |
| 950 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 951 | public void setWfcMode(int wfcMode) { |
| 952 | if (DBG) log("setWfcMode(i) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 953 | |
| 954 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 955 | SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 956 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 957 | setWfcModeInternal(wfcMode); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | /** |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 961 | * Changes the WFC mode to its default value for Carriers with non-editable WFC settings. |
| 962 | */ |
| 963 | private void updateDefaultWfcMode() { |
| 964 | if (DBG) log("updateDefaultWfcMode"); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 965 | if (!getBooleanCarrierConfig(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL)) { |
| 966 | setWfcMode(getIntCarrierConfig( |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 967 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT)); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | /** |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 972 | * Returns the user configuration of WFC preference setting |
| 973 | * |
| 974 | * @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] | 975 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 976 | * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean)} instead. |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 977 | */ |
| 978 | public static int getWfcMode(Context context, boolean roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 979 | ImsManager mgr = ImsManager.getInstance(context, |
| 980 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 981 | if (mgr != null) { |
| 982 | return mgr.getWfcMode(roaming); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 983 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 984 | loge("getWfcMode: ImsManager null, returning default value."); |
| 985 | return ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 989 | * Returns the user configuration of WFC preference setting for slot. If not set, it |
| 990 | * queries CarrierConfig value as default. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 991 | * |
| 992 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
| 993 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 994 | public int getWfcMode(boolean roaming) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 995 | int setting = 0; |
| 996 | if (!roaming) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 997 | setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 998 | getSubId(), SubscriptionManager.WFC_IMS_MODE, |
| 999 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1000 | |
| 1001 | // SUB_PROPERTY_NOT_INITIALIZED indicates it's never set in sub db. |
| 1002 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1003 | setting = getIntCarrierConfig( |
| 1004 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT); |
| 1005 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1006 | if (DBG) log("getWfcMode - setting=" + setting); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1007 | } else { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1008 | setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 1009 | getSubId(), SubscriptionManager.WFC_IMS_ROAMING_MODE, |
| 1010 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1011 | |
| 1012 | // SUB_PROPERTY_NOT_INITIALIZED indicates it's never set in sub db. |
| 1013 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1014 | setting = getIntCarrierConfig( |
| 1015 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT); |
| 1016 | } |
| 1017 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1018 | if (DBG) log("getWfcMode (roaming) - setting=" + setting); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1019 | } |
| 1020 | return setting; |
| 1021 | } |
| 1022 | |
| 1023 | /** |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1024 | * Change persistent WFC preference setting |
| 1025 | * |
| 1026 | * @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] | 1027 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1028 | * @deprecated Doesn't support MSIM devices. Please use {@link #setWfcMode(int, boolean)} |
| 1029 | * instead. |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1030 | */ |
| 1031 | public static void setWfcMode(Context context, int wfcMode, boolean roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1032 | ImsManager mgr = ImsManager.getInstance(context, |
| 1033 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1034 | if (mgr != null) { |
| 1035 | mgr.setWfcMode(wfcMode, roaming); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1036 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1037 | loge("setWfcMode: ImsManager null, can not set value."); |
Meng Wang | 3747701 | 2016-09-20 09:59:56 -0700 | [diff] [blame] | 1038 | } |
| 1039 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1040 | /** |
| 1041 | * Change persistent WFC preference setting |
| 1042 | * |
| 1043 | * @param roaming {@code false} for home network setting, {@code true} for roaming setting |
| 1044 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1045 | public void setWfcMode(int wfcMode, boolean roaming) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1046 | if (!roaming) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1047 | if (DBG) log("setWfcMode(i,b) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1048 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1049 | SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1050 | } else { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1051 | if (DBG) log("setWfcMode(i,b) (roaming) - setting=" + wfcMode); |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1052 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1053 | SubscriptionManager.WFC_IMS_ROAMING_MODE, Integer.toString(wfcMode)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1054 | } |
| 1055 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1056 | TelephonyManager tm = (TelephonyManager) |
| 1057 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 1058 | if (roaming == tm.isNetworkRoaming(getSubId())) { |
| 1059 | setWfcModeInternal(wfcMode); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | private int getSubId() { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1064 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1065 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1066 | if (subIds != null && subIds.length >= 1) { |
| 1067 | subId = subIds[0]; |
| 1068 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1069 | return subId; |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1070 | } |
| 1071 | |
Pavel Zhamaitsiak | 9e6eca2 | 2015-03-16 15:30:53 -0700 | [diff] [blame] | 1072 | private static void setWfcModeInternal(Context context, int wfcMode) { |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1073 | final ImsManager imsManager = ImsManager.getInstance(context, |
| 1074 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1075 | if (imsManager != null) { |
| 1076 | final int value = wfcMode; |
Pavel Zhamaitsiak | 47aeacf | 2016-03-30 18:54:55 -0700 | [diff] [blame] | 1077 | Thread thread = new Thread(new Runnable() { |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1078 | public void run() { |
| 1079 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1080 | imsManager.getConfigInterface().setConfig( |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1081 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE, |
| 1082 | value); |
| 1083 | } catch (ImsException e) { |
| 1084 | // do nothing |
| 1085 | } |
| 1086 | } |
| 1087 | }); |
Pavel Zhamaitsiak | 47aeacf | 2016-03-30 18:54:55 -0700 | [diff] [blame] | 1088 | thread.start(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1089 | } |
| 1090 | } |
| 1091 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1092 | private void setWfcModeInternal(int wfcMode) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1093 | final int value = wfcMode; |
| 1094 | Thread thread = new Thread(() -> { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1095 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1096 | getConfigInterface().setConfig( |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1097 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE, value); |
| 1098 | } catch (ImsException e) { |
| 1099 | // do nothing |
| 1100 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1101 | }); |
| 1102 | thread.start(); |
| 1103 | } |
| 1104 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1105 | /** |
| 1106 | * Returns the user configuration of WFC roaming setting |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1107 | * |
| 1108 | * @deprecated Does not support MSIM devices. Please use |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1109 | * {@link #isWfcRoamingEnabledByUser()} instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1110 | */ |
| 1111 | public static boolean isWfcRoamingEnabledByUser(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1112 | ImsManager mgr = ImsManager.getInstance(context, |
| 1113 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1114 | if (mgr != null) { |
| 1115 | return mgr.isWfcRoamingEnabledByUser(); |
| 1116 | } |
| 1117 | loge("isWfcRoamingEnabledByUser: ImsManager null, returning default value."); |
| 1118 | return false; |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | /** |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1122 | * Returns the user configuration of WFC roaming setting for slot. If not set, it |
| 1123 | * queries CarrierConfig value as default. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1124 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1125 | public boolean isWfcRoamingEnabledByUser() { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1126 | int setting = SubscriptionManager.getIntegerSubscriptionProperty( |
| 1127 | getSubId(), SubscriptionManager.WFC_IMS_ROAMING_ENABLED, |
| 1128 | SUB_PROPERTY_NOT_INITIALIZED, mContext); |
| 1129 | if (setting == SUB_PROPERTY_NOT_INITIALIZED) { |
| 1130 | return getBooleanCarrierConfig( |
| 1131 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL); |
| 1132 | } else { |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 1133 | return setting == ImsConfig.FeatureValueConstants.ON; |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1134 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | /** |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1138 | * Change persistent WFC roaming enabled setting |
| 1139 | */ |
| 1140 | public static void setWfcRoamingSetting(Context context, boolean enabled) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1141 | ImsManager mgr = ImsManager.getInstance(context, |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1142 | SubscriptionManager.getDefaultVoicePhoneId()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1143 | if (mgr != null) { |
| 1144 | mgr.setWfcRoamingSetting(enabled); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1145 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1146 | loge("setWfcRoamingSetting: ImsManager null, value not set."); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1150 | * Change persistent WFC roaming enabled setting |
| 1151 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1152 | public void setWfcRoamingSetting(boolean enabled) { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1153 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 1154 | SubscriptionManager.WFC_IMS_ROAMING_ENABLED, booleanToPropertyString(enabled) |
| 1155 | ); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1156 | |
| 1157 | setWfcRoamingSettingInternal(enabled); |
| 1158 | } |
| 1159 | |
| 1160 | private void setWfcRoamingSettingInternal(boolean enabled) { |
| 1161 | final int value = enabled |
| 1162 | ? ImsConfig.FeatureValueConstants.ON |
| 1163 | : ImsConfig.FeatureValueConstants.OFF; |
| 1164 | Thread thread = new Thread(() -> { |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1165 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1166 | getConfigInterface().setConfig( |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 1167 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_ROAMING, value); |
| 1168 | } catch (ImsException e) { |
| 1169 | // do nothing |
| 1170 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1171 | }); |
| 1172 | thread.start(); |
| 1173 | } |
| 1174 | |
| 1175 | /** |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1176 | * Returns a platform configuration for WFC which may override the user |
| 1177 | * setting. Note: WFC presumes that VoLTE is enabled (these are |
| 1178 | * configuration settings which must be done correctly). |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1179 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1180 | * @deprecated Doesn't work for MSIM devices. Use {@link #isWfcEnabledByPlatform()} |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1181 | * instead. |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1182 | */ |
| 1183 | public static boolean isWfcEnabledByPlatform(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1184 | ImsManager mgr = ImsManager.getInstance(context, |
| 1185 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 1186 | if (mgr != null) { |
| 1187 | return mgr.isWfcEnabledByPlatform(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1188 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1189 | loge("isWfcEnabledByPlatform: ImsManager null, returning default value."); |
| 1190 | return false; |
Pavel Zhamaitsiak | 57911d1 | 2015-10-20 14:26:34 -0700 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1194 | * Returns a platform configuration for WFC which may override the user |
| 1195 | * setting per slot. Note: WFC presumes that VoLTE is enabled (these are |
| 1196 | * configuration settings which must be done correctly). |
| 1197 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1198 | public boolean isWfcEnabledByPlatform() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1199 | // We first read the per slot value. If doesn't exist, we read the general value. If still |
| 1200 | // doesn't exist, we use the hardcoded default value. |
| 1201 | if (SystemProperties.getInt(PROPERTY_DBG_WFC_AVAIL_OVERRIDE + |
| 1202 | Integer.toString(mPhoneId), SYSTEM_PROPERTY_NOT_SET) == 1 || |
| 1203 | SystemProperties.getInt( |
| 1204 | PROPERTY_DBG_WFC_AVAIL_OVERRIDE, SYSTEM_PROPERTY_NOT_SET) == 1) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1205 | return true; |
| 1206 | } |
| 1207 | |
| 1208 | return mContext.getResources().getBoolean( |
| 1209 | com.android.internal.R.bool.config_device_wfc_ims_available) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1210 | getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1211 | CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1212 | isGbaValid(); |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 1213 | } |
| 1214 | |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1215 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1216 | * If carrier requires that IMS is only available if GBA capable SIM is used, |
| 1217 | * then this function checks GBA bit in EF IST. |
| 1218 | * |
| 1219 | * Format of EF IST is defined in 3GPP TS 31.103 (Section 4.2.7). |
| 1220 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1221 | private boolean isGbaValid() { |
| 1222 | if (getBooleanCarrierConfig( |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1223 | CarrierConfigManager.KEY_CARRIER_IMS_GBA_REQUIRED_BOOL)) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1224 | final TelephonyManager telephonyManager = new TelephonyManager(mContext, getSubId()); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1225 | String efIst = telephonyManager.getIsimIst(); |
| 1226 | if (efIst == null) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1227 | loge("isGbaValid - ISF is NULL"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1228 | return true; |
| 1229 | } |
| 1230 | boolean result = efIst != null && efIst.length() > 1 && |
| 1231 | (0x02 & (byte)efIst.charAt(1)) != 0; |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1232 | if (DBG) log("isGbaValid - GBA capable=" + result + ", ISF=" + efIst); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1233 | return result; |
| 1234 | } |
| 1235 | return true; |
| 1236 | } |
| 1237 | |
| 1238 | /** |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1239 | * Will return with config value or throw an ImsException if we receive an error from |
| 1240 | * ImsConfig for that value. |
| 1241 | */ |
| 1242 | private boolean getProvisionedBool(ImsConfig config, int item) throws ImsException { |
| 1243 | int value = config.getProvisionedValue(item); |
| 1244 | if (value == ImsConfig.OperationStatusConstants.UNKNOWN) { |
| 1245 | throw new ImsException("getProvisionedBool failed with error for item: " + item, |
| 1246 | ImsReasonInfo.CODE_LOCAL_INTERNAL_ERROR); |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 1247 | } |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1248 | return config.getProvisionedValue(item) == ImsConfig.FeatureValueConstants.ON; |
Pavel Zhamaitsiak | 002b204 | 2016-06-03 16:05:31 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | /** |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1252 | * Will return with config value or return false if we receive an error from |
| 1253 | * ImsConfig for that value. |
Brad Ebinger | be6cb67 | 2017-08-25 14:55:00 -0700 | [diff] [blame] | 1254 | */ |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 1255 | private boolean getProvisionedBoolNoException(int item) { |
| 1256 | try { |
| 1257 | ImsConfig config = getConfigInterface(); |
| 1258 | return getProvisionedBool(config, item); |
| 1259 | } catch (ImsException ex) { |
| 1260 | return false; |
Brad Ebinger | be6cb67 | 2017-08-25 14:55:00 -0700 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | /** |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1265 | * Sync carrier config and user settings with ImsConfig. |
| 1266 | * |
| 1267 | * @param context for the manager object |
| 1268 | * @param phoneId phone id |
| 1269 | * @param force update |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1270 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1271 | * @deprecated Doesn't support MSIM devices. Use {@link #updateImsServiceConfig(boolean)} |
| 1272 | * instead. |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1273 | */ |
| 1274 | public static void updateImsServiceConfig(Context context, int phoneId, boolean force) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1275 | ImsManager mgr = ImsManager.getInstance(context, phoneId); |
| 1276 | if (mgr != null) { |
| 1277 | mgr.updateImsServiceConfig(force); |
Pavel Zhamaitsiak | fc20299 | 2016-03-29 18:07:38 -0700 | [diff] [blame] | 1278 | } |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1279 | loge("updateImsServiceConfig: ImsManager null, returning without update."); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1280 | } |
| 1281 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1282 | /** |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1283 | * Sync carrier config and user settings with ImsConfig. |
| 1284 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1285 | * @param force update |
| 1286 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1287 | public void updateImsServiceConfig(boolean force) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1288 | if (!force) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1289 | TelephonyManager tm = new TelephonyManager(mContext, getSubId()); |
| 1290 | if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) { |
| 1291 | log("updateImsServiceConfig: SIM not ready"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1292 | // Don't disable IMS if SIM is not ready |
| 1293 | return; |
| 1294 | } |
| 1295 | } |
| 1296 | |
| 1297 | if (!mConfigUpdated || force) { |
| 1298 | try { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1299 | // TODO: Extend ImsConfig API and set all feature values in single function call. |
| 1300 | |
| 1301 | // 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] | 1302 | // changeEnabledCapabilities() function calls from setAdvanced4GMode(). This is done |
| 1303 | // to differentiate this code path from vendor code perspective. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1304 | boolean isImsUsed = updateVolteFeatureValue(); |
| 1305 | isImsUsed |= updateWfcFeatureAndProvisionedValues(); |
| 1306 | isImsUsed |= updateVideoCallFeatureValue(); |
| 1307 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1308 | if (isImsUsed || !isTurnOffImsAllowedByPlatform()) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1309 | // Turn on IMS if it is used. |
| 1310 | // Also, if turning off is not allowed for current carrier, |
| 1311 | // we need to turn IMS on because it might be turned off before |
| 1312 | // phone switched to current carrier. |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1313 | log("updateImsServiceConfig: turnOnIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1314 | turnOnIms(); |
| 1315 | } else { |
| 1316 | // 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] | 1317 | log("updateImsServiceConfig: turnOffIms"); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1318 | turnOffIms(); |
| 1319 | } |
| 1320 | |
| 1321 | mConfigUpdated = true; |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1322 | } catch (ImsException | RemoteException e) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1323 | loge("updateImsServiceConfig: ", e); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1324 | mConfigUpdated = false; |
| 1325 | } |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | /** |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1330 | * Update VoLTE config |
| 1331 | * @return whether feature is On |
| 1332 | * @throws ImsException |
| 1333 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1334 | private boolean updateVolteFeatureValue() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1335 | boolean available = isVolteEnabledByPlatform(); |
| 1336 | boolean enabled = isEnhanced4gLteModeSettingEnabledByUser(); |
| 1337 | boolean isNonTty = isNonTtyOrTtyOnVolteEnabled(); |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1338 | boolean isFeatureOn = available && enabled && isNonTty; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1339 | |
| 1340 | log("updateVolteFeatureValue: available = " + available |
| 1341 | + ", enabled = " + enabled |
| 1342 | + ", nonTTY = " + isNonTty); |
| 1343 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1344 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 1345 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1346 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1347 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1348 | } |
| 1349 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1350 | /** |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1351 | * Update video call over LTE config |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1352 | * @return whether feature is On |
| 1353 | * @throws ImsException |
| 1354 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1355 | private boolean updateVideoCallFeatureValue() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1356 | boolean available = isVtEnabledByPlatform(); |
| 1357 | boolean enabled = isVtEnabledByUser(); |
| 1358 | boolean isNonTty = isNonTtyOrTtyOnVolteEnabled(); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 1359 | boolean isDataEnabled = isDataEnabled(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1360 | boolean ignoreDataEnabledChanged = getBooleanCarrierConfig( |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 1361 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS); |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1362 | |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 1363 | boolean isFeatureOn = available && enabled && isNonTty |
| 1364 | && (ignoreDataEnabledChanged || isDataEnabled); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1365 | |
| 1366 | log("updateVideoCallFeatureValue: available = " + available |
| 1367 | + ", enabled = " + enabled |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 1368 | + ", nonTTY = " + isNonTty |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 1369 | + ", data enabled = " + isDataEnabled); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1370 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1371 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 1372 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1373 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1374 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1375 | } |
| 1376 | |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1377 | /** |
| 1378 | * Update WFC config |
| 1379 | * @return whether feature is On |
| 1380 | * @throws ImsException |
| 1381 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1382 | private boolean updateWfcFeatureAndProvisionedValues() throws RemoteException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1383 | TelephonyManager tm = new TelephonyManager(mContext, getSubId()); |
| 1384 | boolean isNetworkRoaming = tm.isNetworkRoaming(); |
| 1385 | boolean available = isWfcEnabledByPlatform(); |
| 1386 | boolean enabled = isWfcEnabledByUser(); |
Suresh Koleti | 7649108 | 2017-04-21 18:39:50 +0530 | [diff] [blame] | 1387 | updateDefaultWfcMode(); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1388 | int mode = getWfcMode(isNetworkRoaming); |
| 1389 | boolean roaming = isWfcRoamingEnabledByUser(); |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1390 | boolean isFeatureOn = available && enabled; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1391 | |
| 1392 | log("updateWfcFeatureAndProvisionedValues: available = " + available |
| 1393 | + ", enabled = " + enabled |
| 1394 | + ", mode = " + mode |
| 1395 | + ", roaming = " + roaming); |
| 1396 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1397 | changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 1398 | ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, isFeatureOn); |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1399 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1400 | if (!isFeatureOn) { |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1401 | mode = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED; |
| 1402 | roaming = false; |
| 1403 | } |
| 1404 | setWfcModeInternal(mContext, mode); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1405 | setWfcRoamingSettingInternal(roaming); |
Pavel Zhamaitsiak | dc16e45 | 2015-09-08 17:12:06 -0700 | [diff] [blame] | 1406 | |
Pavel Zhamaitsiak | 9510b1c | 2015-12-18 11:30:49 -0800 | [diff] [blame] | 1407 | return isFeatureOn; |
Pavel Zhamaitsiak | 8ca52ff | 2015-09-04 17:08:35 -0700 | [diff] [blame] | 1408 | } |
| 1409 | |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1410 | /** |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1411 | * Do NOT use this directly, instead use {@link #getInstance(Context, int)}. |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1412 | */ |
| 1413 | @VisibleForTesting |
| 1414 | public ImsManager(Context context, int phoneId) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1415 | mContext = context; |
Etan Cohen | abbd788 | 2014-09-26 22:35:35 -0700 | [diff] [blame] | 1416 | mPhoneId = phoneId; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1417 | mConfigDynamicBind = mContext.getResources().getBoolean( |
| 1418 | com.android.internal.R.bool.config_dynamic_bind_ims); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1419 | mConfigManager = (CarrierConfigManager) context.getSystemService( |
| 1420 | Context.CARRIER_CONFIG_SERVICE); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1421 | createImsService(); |
| 1422 | } |
| 1423 | |
| 1424 | /** |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1425 | * @return Whether or not ImsManager is configured to Dynamically bind or not to support legacy |
| 1426 | * devices. |
| 1427 | */ |
| 1428 | public boolean isDynamicBinding() { |
| 1429 | return mConfigDynamicBind; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1430 | } |
| 1431 | |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1432 | /* |
Brad Ebinger | 0aed76d | 2018-03-05 16:39:02 -0800 | [diff] [blame^] | 1433 | * Returns a flag indicating whether the IMS service is available. If it is not available or |
| 1434 | * busy, it will try to connect before reporting failure. |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1435 | */ |
| 1436 | public boolean isServiceAvailable() { |
Brad Ebinger | 0aed76d | 2018-03-05 16:39:02 -0800 | [diff] [blame^] | 1437 | // If we are busy resolving dynamic IMS bindings, we are not available yet. |
| 1438 | TelephonyManager tm = (TelephonyManager) |
| 1439 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 1440 | if (tm.isResolvingImsBinding()) { |
| 1441 | Log.d(TAG, "isServiceAvailable: resolving IMS binding, returning false"); |
| 1442 | return false; |
| 1443 | } |
| 1444 | |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1445 | connectIfServiceIsAvailable(); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1446 | // mImsServiceProxy will always create an ImsServiceProxy. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1447 | return mMmTelFeatureConnection.isBinderAlive(); |
Etan Cohen | f431112 | 2015-02-26 17:47:13 -0800 | [diff] [blame] | 1448 | } |
| 1449 | |
Suresh Koleti | cc3139c | 2017-11-03 18:23:57 +0530 | [diff] [blame] | 1450 | /* |
| 1451 | * Returns a flag indicating whether the IMS service is ready to send requests to lower layers. |
| 1452 | */ |
| 1453 | public boolean isServiceReady() { |
| 1454 | connectIfServiceIsAvailable(); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1455 | return mMmTelFeatureConnection.isBinderReady(); |
Suresh Koleti | cc3139c | 2017-11-03 18:23:57 +0530 | [diff] [blame] | 1456 | } |
| 1457 | |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1458 | /** |
| 1459 | * If the service is available, try to reconnect. |
| 1460 | */ |
| 1461 | public void connectIfServiceIsAvailable() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1462 | if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | ff09792 | 2017-06-19 15:43:08 -0700 | [diff] [blame] | 1463 | createImsService(); |
| 1464 | } |
| 1465 | } |
| 1466 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1467 | public void setConfigListener(ImsConfigListener listener) { |
Pavel Zhamaitsiak | f4b9032 | 2016-01-26 14:34:09 -0800 | [diff] [blame] | 1468 | mImsConfigListener = listener; |
| 1469 | } |
| 1470 | |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1471 | |
| 1472 | /** |
| 1473 | * Adds a callback for status changed events if the binder is already available. If it is not, |
| 1474 | * this method will throw an ImsException. |
| 1475 | */ |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 1476 | @VisibleForTesting |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1477 | public void addNotifyStatusChangedCallbackIfAvailable(MmTelFeatureConnection.IFeatureUpdate c) |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1478 | throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1479 | if (!mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1480 | throw new ImsException("Binder is not active!", |
| 1481 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1482 | } |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1483 | if (c != null) { |
| 1484 | mStatusCallbacks.add(c); |
| 1485 | } |
| 1486 | } |
| 1487 | |
Brad Ebinger | 6ddf28e | 2018-02-21 16:07:23 -0800 | [diff] [blame] | 1488 | void removeNotifyStatusChangedCallback(MmTelFeatureConnection.IFeatureUpdate c) { |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 1489 | if (c != null) { |
| 1490 | mStatusCallbacks.remove(c); |
| 1491 | } else { |
| 1492 | Log.w(TAG, "removeNotifyStatusChangedCallback: callback is null!"); |
| 1493 | } |
| 1494 | } |
| 1495 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1496 | /** |
| 1497 | * 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] | 1498 | * The caller may make subsequent calls through {@link #makeCall}. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1499 | * The IMS service will register the device to the operator's network with the credentials |
| 1500 | * (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] | 1501 | * When the IMS service receives a new call, it will call |
| 1502 | * {@link MmTelFeature.Listener#onIncomingCall} |
| 1503 | * The listener contains a call ID extra {@link #getCallId} and it can be used to take a call. |
| 1504 | * @param listener A {@link MmTelFeature.Listener}, which is the interface the |
| 1505 | * {@link MmTelFeature} uses to notify the framework of updates |
| 1506 | * @throws NullPointerException if {@code listener} is null |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1507 | * @throws ImsException if calling the IMS service results in an error |
| 1508 | * @see #getCallId |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1509 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1510 | public void open(MmTelFeature.Listener listener) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1511 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1512 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1513 | if (listener == null) { |
| 1514 | throw new NullPointerException("listener can't be null"); |
| 1515 | } |
| 1516 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1517 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1518 | mMmTelFeatureConnection.openConnection(listener); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1519 | } catch (RemoteException e) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1520 | throw new ImsException("open()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1521 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | /** |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1525 | * Adds registration listener to the IMS service. |
| 1526 | * |
| 1527 | * @param serviceClass a service class specified in {@link ImsServiceClass} |
| 1528 | * For VoLTE service, it MUST be a {@link ImsServiceClass#MMTEL}. |
| 1529 | * @param listener To listen to IMS registration events; It cannot be null |
| 1530 | * @throws NullPointerException if {@code listener} is null |
| 1531 | * @throws ImsException if calling the IMS service results in an error |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1532 | * |
| 1533 | * @deprecated Use {@link #addRegistrationListener(ImsConnectionStateListener)} instead. |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1534 | */ |
| 1535 | public void addRegistrationListener(int serviceClass, ImsConnectionStateListener listener) |
| 1536 | throws ImsException { |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1537 | addRegistrationListener(listener); |
| 1538 | } |
| 1539 | |
| 1540 | /** |
| 1541 | * Adds registration listener to the IMS service. |
| 1542 | * |
| 1543 | * @param listener To listen to IMS registration events; It cannot be null |
| 1544 | * @throws NullPointerException if {@code listener} is null |
| 1545 | * @throws ImsException if calling the IMS service results in an error |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1546 | * @deprecated use {@link #addRegistrationCallback(ImsRegistrationImplBase.Callback)} and |
| 1547 | * {@link #addCapabilitiesCallback(ImsFeature.CapabilityCallback)} instead. |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1548 | */ |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 1549 | public void addRegistrationListener(ImsConnectionStateListener listener) throws ImsException { |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1550 | if (listener == null) { |
| 1551 | throw new NullPointerException("listener can't be null"); |
| 1552 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1553 | addRegistrationCallback(listener); |
| 1554 | // connect the ImsConnectionStateListener to the new CapabilityCallback. |
| 1555 | addCapabilitiesCallback(new ImsFeature.CapabilityCallback() { |
| 1556 | @Override |
| 1557 | public void onCapabilitiesStatusChanged(ImsFeature.Capabilities config) { |
| 1558 | listener.onFeatureCapabilityChangedAdapter(getRegistrationTech(), config); |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1559 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1560 | }); |
| 1561 | log("Registration Callback registered."); |
| 1562 | } |
| 1563 | |
| 1564 | /** |
| 1565 | * Adds a callback that gets called when IMS registration has changed. |
| 1566 | * @param callback A {@link ImsRegistrationImplBase.Callback} that will notify the caller when |
| 1567 | * IMS registration status has changed. |
| 1568 | * @throws ImsException when the ImsService connection is not available. |
| 1569 | */ |
| 1570 | public void addRegistrationCallback(ImsRegistrationImplBase.Callback callback) |
| 1571 | throws ImsException { |
| 1572 | if (callback == null) { |
| 1573 | throw new NullPointerException("registration callback can't be null"); |
Brad Ebinger | 9a0280c | 2017-06-01 15:58:48 -0700 | [diff] [blame] | 1574 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1575 | |
| 1576 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1577 | try { |
| 1578 | mMmTelFeatureConnection.addRegistrationCallback(callback); |
| 1579 | log("Registration Callback registered."); |
| 1580 | // Only record if there isn't a RemoteException. |
| 1581 | } catch (RemoteException e) { |
| 1582 | throw new ImsException("addRegistrationCallback(IRIB)", e, |
| 1583 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1584 | } |
| 1585 | } |
| 1586 | |
| 1587 | /** |
| 1588 | * Adds a callback that gets called when MMTel capability status has changed, for example when |
| 1589 | * Voice over IMS or VT over IMS is not available currently. |
| 1590 | * @param callback A {@link ImsFeature.CapabilityCallback} that will notify the caller when |
| 1591 | * MMTel capability status has changed. |
| 1592 | * @throws ImsException when the ImsService connection is not available. |
| 1593 | */ |
| 1594 | public void addCapabilitiesCallback(ImsFeature.CapabilityCallback callback) |
| 1595 | throws ImsException { |
| 1596 | if (callback == null) { |
| 1597 | throw new NullPointerException("capabilities callback can't be null"); |
| 1598 | } |
| 1599 | |
| 1600 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1601 | try { |
| 1602 | mMmTelFeatureConnection.addCapabilityCallback(callback); |
| 1603 | log("Capability Callback registered."); |
| 1604 | // Only record if there isn't a RemoteException. |
| 1605 | } catch (RemoteException e) { |
| 1606 | throw new ImsException("addCapabilitiesCallback(IF)", e, |
| 1607 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Pavel Zhamaitsiak | ce41017 | 2016-04-15 10:55:56 -0700 | [diff] [blame] | 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | /** |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1612 | * Removes the registration listener from the IMS service. |
| 1613 | * |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1614 | * @param listener Previously registered listener that will be removed. Can not be null. |
| 1615 | * @throws NullPointerException if {@code listener} is null |
| 1616 | * @throws ImsException if calling the IMS service results in an error |
| 1617 | * instead. |
| 1618 | */ |
Brad Ebinger | b5f30c7 | 2017-02-17 14:54:31 -0800 | [diff] [blame] | 1619 | public void removeRegistrationListener(ImsConnectionStateListener listener) |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1620 | throws ImsException { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1621 | if (listener == null) { |
| 1622 | throw new NullPointerException("listener can't be null"); |
| 1623 | } |
| 1624 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1625 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1626 | try { |
| 1627 | mMmTelFeatureConnection.removeRegistrationCallback(listener); |
| 1628 | log("Registration Callback/Listener registered."); |
| 1629 | // Only record if there isn't a RemoteException. |
| 1630 | } catch (RemoteException e) { |
| 1631 | throw new ImsException("addRegistrationCallback()", e, |
| 1632 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | public @ImsRegistrationImplBase.ImsRegistrationTech int getRegistrationTech() { |
| 1637 | try { |
| 1638 | return mMmTelFeatureConnection.getRegistrationTech(); |
| 1639 | } catch (RemoteException e) { |
| 1640 | Log.w(TAG, "getRegistrationTech: no connection to ImsService."); |
| 1641 | return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | /** |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1646 | * Closes the connection and removes all active callbacks. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1647 | * All the resources that were allocated to the service are also released. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1648 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1649 | public void close() { |
| 1650 | if (mMmTelFeatureConnection != null) { |
| 1651 | mMmTelFeatureConnection.closeConnection(); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1652 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1653 | mUt = null; |
| 1654 | mConfig = null; |
| 1655 | mEcbm = null; |
| 1656 | mMultiEndpoint = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1657 | } |
| 1658 | |
| 1659 | /** |
| 1660 | * Gets the configuration interface to provision / withdraw the supplementary service settings. |
| 1661 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1662 | * @return the Ut interface instance |
| 1663 | * @throws ImsException if getting the Ut interface results in an error |
| 1664 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1665 | public ImsUtInterface getSupplementaryServiceConfiguration() throws ImsException { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1666 | // FIXME: manage the multiple Ut interfaces based on the session id |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1667 | if (mUt != null && mUt.isBinderAlive()) { |
| 1668 | return mUt; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1671 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1672 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1673 | IImsUt iUt = mMmTelFeatureConnection.getUtInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1674 | |
| 1675 | if (iUt == null) { |
| 1676 | throw new ImsException("getSupplementaryServiceConfiguration()", |
| 1677 | ImsReasonInfo.CODE_UT_NOT_SUPPORTED); |
| 1678 | } |
| 1679 | |
| 1680 | mUt = new ImsUt(iUt); |
| 1681 | } catch (RemoteException e) { |
| 1682 | throw new ImsException("getSupplementaryServiceConfiguration()", e, |
| 1683 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1684 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1685 | return mUt; |
| 1686 | } |
| 1687 | |
| 1688 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1689 | * Creates a {@link ImsCallProfile} from the service capabilities & IMS registration state. |
| 1690 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1691 | * @param serviceType a service type that is specified in {@link ImsCallProfile} |
| 1692 | * {@link ImsCallProfile#SERVICE_TYPE_NONE} |
| 1693 | * {@link ImsCallProfile#SERVICE_TYPE_NORMAL} |
| 1694 | * {@link ImsCallProfile#SERVICE_TYPE_EMERGENCY} |
| 1695 | * @param callType a call type that is specified in {@link ImsCallProfile} |
| 1696 | * {@link ImsCallProfile#CALL_TYPE_VOICE} |
| 1697 | * {@link ImsCallProfile#CALL_TYPE_VT} |
| 1698 | * {@link ImsCallProfile#CALL_TYPE_VT_TX} |
| 1699 | * {@link ImsCallProfile#CALL_TYPE_VT_RX} |
| 1700 | * {@link ImsCallProfile#CALL_TYPE_VT_NODIR} |
| 1701 | * {@link ImsCallProfile#CALL_TYPE_VS} |
| 1702 | * {@link ImsCallProfile#CALL_TYPE_VS_TX} |
| 1703 | * {@link ImsCallProfile#CALL_TYPE_VS_RX} |
| 1704 | * @return a {@link ImsCallProfile} object |
| 1705 | * @throws ImsException if calling the IMS service results in an error |
| 1706 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1707 | public ImsCallProfile createCallProfile(int serviceType, int callType) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1708 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1709 | |
| 1710 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1711 | return mMmTelFeatureConnection.createCallProfile(serviceType, callType); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1712 | } catch (RemoteException e) { |
| 1713 | throw new ImsException("createCallProfile()", e, |
| 1714 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | /** |
| 1719 | * Creates a {@link ImsCall} to make a call. |
| 1720 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1721 | * @param profile a call profile to make the call |
| 1722 | * (it contains service type, call type, media information, etc.) |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1723 | * @param callees participants to invite the conference call |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1724 | * @param listener listen to the call events from {@link ImsCall} |
| 1725 | * @return a {@link ImsCall} object |
| 1726 | * @throws ImsException if calling the IMS service results in an error |
| 1727 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1728 | public ImsCall makeCall(ImsCallProfile profile, String[] callees, |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1729 | ImsCall.Listener listener) throws ImsException { |
| 1730 | if (DBG) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1731 | log("makeCall :: profile=" + profile); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1735 | |
| 1736 | ImsCall call = new ImsCall(mContext, profile); |
| 1737 | |
| 1738 | call.setListener(listener); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1739 | ImsCallSession session = createCallSession(profile); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1740 | |
| 1741 | if ((callees != null) && (callees.length == 1)) { |
| 1742 | call.start(session, callees[0]); |
| 1743 | } else { |
| 1744 | call.start(session, callees); |
| 1745 | } |
| 1746 | |
| 1747 | return call; |
| 1748 | } |
| 1749 | |
| 1750 | /** |
| 1751 | * Creates a {@link ImsCall} to take an incoming call. |
| 1752 | * |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1753 | * @param sessionId a session id which is obtained from {@link ImsManager#open} |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1754 | * @param incomingCallExtras the incoming call broadcast intent |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1755 | * @param listener to listen to the call events from {@link ImsCall} |
| 1756 | * @return a {@link ImsCall} object |
| 1757 | * @throws ImsException if calling the IMS service results in an error |
| 1758 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1759 | public ImsCall takeCall(IImsCallSession session, Bundle incomingCallExtras, |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1760 | ImsCall.Listener listener) throws ImsException { |
| 1761 | if (DBG) { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1762 | log("takeCall :: incomingCall=" + incomingCallExtras); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1766 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1767 | if (incomingCallExtras == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1768 | throw new ImsException("Can't retrieve session with null intent", |
| 1769 | ImsReasonInfo.CODE_LOCAL_ILLEGAL_ARGUMENT); |
| 1770 | } |
| 1771 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1772 | String callId = getCallId(incomingCallExtras); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1773 | |
| 1774 | if (callId == null) { |
| 1775 | throw new ImsException("Call ID missing in the incoming call intent", |
| 1776 | ImsReasonInfo.CODE_LOCAL_ILLEGAL_ARGUMENT); |
| 1777 | } |
| 1778 | |
| 1779 | try { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1780 | if (session == null) { |
| 1781 | throw new ImsException("No pending session for the call", |
| 1782 | ImsReasonInfo.CODE_LOCAL_NO_PENDING_CALL); |
| 1783 | } |
| 1784 | |
| 1785 | ImsCall call = new ImsCall(mContext, session.getCallProfile()); |
| 1786 | |
| 1787 | call.attachSession(new ImsCallSession(session)); |
| 1788 | call.setListener(listener); |
| 1789 | |
| 1790 | return call; |
| 1791 | } catch (Throwable t) { |
| 1792 | throw new ImsException("takeCall()", t, ImsReasonInfo.CODE_UNSPECIFIED); |
| 1793 | } |
| 1794 | } |
| 1795 | |
| 1796 | /** |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1797 | * Gets the config interface to get/set service/capability parameters. |
| 1798 | * |
| 1799 | * @return the ImsConfig instance. |
| 1800 | * @throws ImsException if getting the setting interface results in an error. |
| 1801 | */ |
| 1802 | public ImsConfig getConfigInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1803 | if (mConfig != null && mConfig.isBinderAlive()) { |
| 1804 | return mConfig; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1805 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1806 | |
| 1807 | checkAndThrowExceptionIfServiceUnavailable(); |
| 1808 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1809 | IImsConfig config = mMmTelFeatureConnection.getConfigInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 1810 | if (config == null) { |
| 1811 | throw new ImsException("getConfigInterface()", |
| 1812 | ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); |
| 1813 | } |
| 1814 | mConfig = new ImsConfig(config, mContext); |
| 1815 | } catch (RemoteException e) { |
| 1816 | throw new ImsException("getConfigInterface()", e, |
| 1817 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1818 | } |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1819 | return mConfig; |
| 1820 | } |
| 1821 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1822 | public void changeMmTelCapability( |
| 1823 | @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, |
| 1824 | @ImsRegistrationImplBase.ImsRegistrationTech int radioTech, |
| 1825 | boolean isEnabled) throws RemoteException { |
| 1826 | CapabilityChangeRequest request = new CapabilityChangeRequest(); |
| 1827 | if (isEnabled) { |
| 1828 | request.addCapabilitiesToEnableForTech(capability, radioTech); |
| 1829 | } else { |
| 1830 | request.addCapabilitiesToDisableForTech(capability, radioTech); |
| 1831 | } |
| 1832 | mMmTelFeatureConnection.changeEnabledCapabilities(request, null); |
| 1833 | if (mImsConfigListener != null) { |
| 1834 | mImsConfigListener.onSetFeatureResponse(capability, |
| 1835 | mMmTelFeatureConnection.getRegistrationTech(), |
| 1836 | isEnabled ? ImsConfig.FeatureValueConstants.ON |
| 1837 | : ImsConfig.FeatureValueConstants.OFF, -1); |
| 1838 | } |
| 1839 | } |
| 1840 | |
Hall Liu | b77d897 | 2018-01-22 19:15:05 -0800 | [diff] [blame] | 1841 | public void setRttEnabled(boolean enabled) { |
| 1842 | try { |
| 1843 | setAdvanced4GMode(enabled || isEnhanced4gLteModeSettingEnabledByUser()); |
| 1844 | final int value = enabled ? ImsConfig.FeatureValueConstants.ON : |
| 1845 | ImsConfig.FeatureValueConstants.OFF; |
| 1846 | Thread thread = new Thread(() -> { |
| 1847 | try { |
| 1848 | Log.i(ImsManager.class.getSimpleName(), "Setting RTT enabled to " + enabled); |
| 1849 | getConfigInterface().setProvisionedValue( |
| 1850 | ImsConfig.ConfigConstants.RTT_SETTING_ENABLED, value); |
| 1851 | } catch (ImsException e) { |
| 1852 | Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT enabled to " |
| 1853 | + enabled + ": " + e); |
| 1854 | } |
| 1855 | }); |
| 1856 | thread.start(); |
| 1857 | } catch (ImsException e) { |
| 1858 | Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT enabled to " + enabled |
| 1859 | + ": " + e); |
| 1860 | } |
| 1861 | } |
| 1862 | |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1863 | /** |
| 1864 | * Set the TTY mode. This is the actual tty mode (varies depending on peripheral status) |
| 1865 | */ |
| 1866 | public void setTtyMode(int ttyMode) throws ImsException { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1867 | if (!getBooleanCarrierConfig( |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1868 | CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) { |
| 1869 | setAdvanced4GMode((ttyMode == TelecomManager.TTY_MODE_OFF) && |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1870 | isEnhanced4gLteModeSettingEnabledByUser()); |
Hall Liu | e511a20 | 2017-08-17 15:49:58 -0700 | [diff] [blame] | 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | /** |
| 1875 | * Sets the UI TTY mode. This is the preferred TTY mode that the user sets in the call |
| 1876 | * settings screen. |
| 1877 | */ |
Brad Ebinger | b5f30c7 | 2017-02-17 14:54:31 -0800 | [diff] [blame] | 1878 | public void setUiTTYMode(Context context, int uiTtyMode, Message onComplete) |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1879 | throws ImsException { |
| 1880 | |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1881 | checkAndThrowExceptionIfServiceUnavailable(); |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1882 | |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1883 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1884 | mMmTelFeatureConnection.setUiTTYMode(uiTtyMode, onComplete); |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 1885 | } catch (RemoteException e) { |
| 1886 | throw new ImsException("setTTYMode()", e, |
| 1887 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1888 | } |
Shriram Ganesh | c403b7b | 2014-08-14 14:18:57 +0530 | [diff] [blame] | 1889 | } |
| 1890 | |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 1891 | private ImsReasonInfo makeACopy(ImsReasonInfo imsReasonInfo) { |
| 1892 | Parcel p = Parcel.obtain(); |
| 1893 | imsReasonInfo.writeToParcel(p, 0); |
| 1894 | p.setDataPosition(0); |
| 1895 | ImsReasonInfo clonedReasonInfo = ImsReasonInfo.CREATOR.createFromParcel(p); |
| 1896 | p.recycle(); |
| 1897 | return clonedReasonInfo; |
| 1898 | } |
| 1899 | |
| 1900 | /** |
| 1901 | * Get Recent IMS Disconnect Reasons. |
| 1902 | * |
| 1903 | * @return ArrayList of ImsReasonInfo objects. MAX size of the arraylist |
| 1904 | * is MAX_RECENT_DISCONNECT_REASONS. The objects are in the |
| 1905 | * chronological order. |
| 1906 | */ |
| 1907 | public ArrayList<ImsReasonInfo> getRecentImsDisconnectReasons() { |
| 1908 | ArrayList<ImsReasonInfo> disconnectReasons = new ArrayList<>(); |
| 1909 | |
| 1910 | for (ImsReasonInfo reason : mRecentDisconnectReasons) { |
| 1911 | disconnectReasons.add(makeACopy(reason)); |
| 1912 | } |
| 1913 | return disconnectReasons; |
| 1914 | } |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1915 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1916 | public int getImsServiceState() throws ImsException { |
| 1917 | return mMmTelFeatureConnection.getFeatureState(); |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1918 | } |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 1919 | |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 1920 | /** |
Junda Liu | e7663c0 | 2015-06-23 11:16:26 -0700 | [diff] [blame] | 1921 | * Get the boolean config from carrier config manager. |
| 1922 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1923 | * @param key config key defined in CarrierConfigManager |
| 1924 | * @return boolean value of corresponding key. |
| 1925 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1926 | private boolean getBooleanCarrierConfig(String key) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1927 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1928 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1929 | if (subIds != null && subIds.length >= 1) { |
| 1930 | subId = subIds[0]; |
| 1931 | } |
| 1932 | PersistableBundle b = null; |
| 1933 | if (mConfigManager != null) { |
| 1934 | // If an invalid subId is used, this bundle will contain default values. |
| 1935 | b = mConfigManager.getConfigForSubId(subId); |
| 1936 | } |
| 1937 | if (b != null) { |
| 1938 | return b.getBoolean(key); |
| 1939 | } else { |
| 1940 | // Return static default defined in CarrierConfigManager. |
| 1941 | return CarrierConfigManager.getDefaultConfig().getBoolean(key); |
| 1942 | } |
| 1943 | } |
| 1944 | |
| 1945 | /** |
fionaxu | 5803ef0 | 2016-03-08 11:48:48 -0800 | [diff] [blame] | 1946 | * Get the int config from carrier config manager. |
| 1947 | * |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1948 | * @param key config key defined in CarrierConfigManager |
| 1949 | * @return integer value of corresponding key. |
| 1950 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 1951 | private int getIntCarrierConfig(String key) { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 1952 | int[] subIds = SubscriptionManager.getSubId(mPhoneId); |
| 1953 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 1954 | if (subIds != null && subIds.length >= 1) { |
| 1955 | subId = subIds[0]; |
| 1956 | } |
| 1957 | PersistableBundle b = null; |
| 1958 | if (mConfigManager != null) { |
| 1959 | // If an invalid subId is used, this bundle will contain default values. |
| 1960 | b = mConfigManager.getConfigForSubId(subId); |
| 1961 | } |
| 1962 | if (b != null) { |
| 1963 | return b.getInt(key); |
| 1964 | } else { |
| 1965 | // Return static default defined in CarrierConfigManager. |
| 1966 | return CarrierConfigManager.getDefaultConfig().getInt(key); |
| 1967 | } |
| 1968 | } |
| 1969 | |
| 1970 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1971 | * Gets the call ID from the specified incoming call broadcast intent. |
| 1972 | * |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1973 | * @param incomingCallExtras the incoming call broadcast intent |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1974 | * @return the call ID or null if the intent does not contain it |
| 1975 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1976 | private static String getCallId(Bundle incomingCallExtras) { |
| 1977 | if (incomingCallExtras == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1978 | return null; |
| 1979 | } |
| 1980 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1981 | return incomingCallExtras.getString(EXTRA_CALL_ID); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1982 | } |
| 1983 | |
| 1984 | /** |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 1985 | * Checks to see if the ImsService Binder is connected. If it is not, we try to create the |
| 1986 | * connection again. |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1987 | */ |
| 1988 | private void checkAndThrowExceptionIfServiceUnavailable() |
| 1989 | throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1990 | if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) { |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 1991 | createImsService(); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1992 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 1993 | if (mMmTelFeatureConnection == null) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 1994 | throw new ImsException("Service is unavailable", |
| 1995 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 1996 | } |
| 1997 | } |
| 1998 | } |
| 1999 | |
Brad Ebinger | 16780ff | 2017-01-26 11:18:21 -0800 | [diff] [blame] | 2000 | /** |
| 2001 | * Binds the IMS service to make/receive the call. Supports two methods of exposing an |
| 2002 | * ImsService: |
| 2003 | * 1) com.android.ims.ImsService implementation in ServiceManager (deprecated). |
| 2004 | * 2) android.telephony.ims.ImsService implementation through ImsResolver. |
| 2005 | */ |
| 2006 | private void createImsService() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2007 | Rlog.i(TAG, "Creating ImsService"); |
| 2008 | mMmTelFeatureConnection = MmTelFeatureConnection.create(mContext, mPhoneId); |
| 2009 | |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2010 | // Forwarding interface to tell mStatusCallbacks that the Proxy is unavailable. |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2011 | mMmTelFeatureConnection.setStatusCallback(new MmTelFeatureConnection.IFeatureUpdate() { |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2012 | @Override |
| 2013 | public void notifyStateChanged() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2014 | mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyStateChanged); |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2015 | } |
| 2016 | |
| 2017 | @Override |
| 2018 | public void notifyUnavailable() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2019 | mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyUnavailable); |
Brad Ebinger | 44fd8af | 2017-12-14 14:24:02 -0800 | [diff] [blame] | 2020 | } |
| 2021 | }); |
Etan Cohen | d772746 | 2014-07-12 14:54:10 -0700 | [diff] [blame] | 2022 | } |
| 2023 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2024 | /** |
| 2025 | * Creates a {@link ImsCallSession} with the specified call profile. |
| 2026 | * Use other methods, if applicable, instead of interacting with |
| 2027 | * {@link ImsCallSession} directly. |
| 2028 | * |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2029 | * @param profile a call profile to make the call |
| 2030 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2031 | private ImsCallSession createCallSession(ImsCallProfile profile) throws ImsException { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2032 | try { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 2033 | // 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] | 2034 | return new ImsCallSession(mMmTelFeatureConnection.createCallSession(profile)); |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2035 | } catch (RemoteException e) { |
Brad Ebinger | b10b61e | 2017-04-18 11:45:26 -0700 | [diff] [blame] | 2036 | Rlog.w(TAG, "CreateCallSession: Error, remote exception: " + e.getMessage()); |
| 2037 | throw new ImsException("createCallSession()", e, |
| 2038 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2039 | |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2043 | private static void log(String s) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2044 | Rlog.d(TAG, s); |
| 2045 | } |
| 2046 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2047 | private static void loge(String s) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2048 | Rlog.e(TAG, s); |
| 2049 | } |
| 2050 | |
Etan Cohen | a00c919 | 2014-12-23 15:02:29 -0800 | [diff] [blame] | 2051 | private static void loge(String s, Throwable t) { |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2052 | Rlog.e(TAG, s, t); |
| 2053 | } |
| 2054 | |
| 2055 | /** |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2056 | * Used for turning on IMS.if its off already |
| 2057 | */ |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 2058 | private void turnOnIms() throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2059 | TelephonyManager tm = (TelephonyManager) |
| 2060 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 2061 | tm.enableIms(mPhoneId); |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2062 | } |
| 2063 | |
Omkar Kolangade | 75f3ca3 | 2014-10-24 11:10:52 -0700 | [diff] [blame] | 2064 | private boolean isImsTurnOffAllowed() { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2065 | return isTurnOffImsAllowedByPlatform() |
| 2066 | && (!isWfcEnabledByPlatform() |
| 2067 | || !isWfcEnabledByUser()); |
Omkar Kolangade | 75f3ca3 | 2014-10-24 11:10:52 -0700 | [diff] [blame] | 2068 | } |
| 2069 | |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2070 | private void setLteFeatureValues(boolean turnOn) { |
| 2071 | log("setLteFeatureValues: " + turnOn); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2072 | CapabilityChangeRequest request = new CapabilityChangeRequest(); |
| 2073 | if (turnOn) { |
| 2074 | request.addCapabilitiesToEnableForTech( |
| 2075 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 2076 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2077 | } else { |
| 2078 | request.addCapabilitiesToDisableForTech( |
| 2079 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE, |
| 2080 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2081 | } |
Pavel Zhamaitsiak | ff29b9d | 2016-04-15 12:16:57 -0700 | [diff] [blame] | 2082 | |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2083 | if (isVolteEnabledByPlatform()) { |
| 2084 | boolean ignoreDataEnabledChanged = getBooleanCarrierConfig( |
| 2085 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS); |
| 2086 | boolean enableViLte = turnOn && isVtEnabledByUser() && |
| 2087 | (ignoreDataEnabledChanged || isDataEnabled()); |
| 2088 | if (enableViLte) { |
| 2089 | request.addCapabilitiesToEnableForTech( |
| 2090 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 2091 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
| 2092 | } else { |
| 2093 | request.addCapabilitiesToDisableForTech( |
| 2094 | MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO, |
| 2095 | ImsRegistrationImplBase.REGISTRATION_TECH_LTE); |
Etan Cohen | b651fa5 | 2014-10-22 10:51:29 -0700 | [diff] [blame] | 2096 | } |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2097 | } |
| 2098 | try { |
| 2099 | mMmTelFeatureConnection.changeEnabledCapabilities(request, null); |
| 2100 | } catch (RemoteException e) { |
| 2101 | Log.e(TAG, "setLteFeatureValues: Exception: " + e.getMessage()); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2102 | } |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2103 | } |
| 2104 | |
| 2105 | private void setAdvanced4GMode(boolean turnOn) throws ImsException { |
| 2106 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2107 | |
| 2108 | // if turnOn: first set feature values then call turnOnIms() |
| 2109 | // if turnOff: only set feature values if IMS turn off is not allowed. If turn off is |
| 2110 | // allowed, first call turnOffIms() then set feature values |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2111 | if (turnOn) { |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2112 | setLteFeatureValues(turnOn); |
| 2113 | log("setAdvanced4GMode: turnOnIms"); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2114 | turnOnIms(); |
Amit Mahajan | 9cba36d | 2016-08-11 10:17:23 -0700 | [diff] [blame] | 2115 | } else { |
| 2116 | if (isImsTurnOffAllowed()) { |
| 2117 | log("setAdvanced4GMode: turnOffIms"); |
| 2118 | turnOffIms(); |
| 2119 | } |
| 2120 | setLteFeatureValues(turnOn); |
Etan Cohen | cfc784d | 2014-08-07 18:40:31 -0700 | [diff] [blame] | 2121 | } |
| 2122 | } |
| 2123 | |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2124 | /** |
| 2125 | * Used for turning off IMS completely in order to make the device CSFB'ed. |
| 2126 | * Once turned off, all calls will be over CS. |
| 2127 | */ |
Etan Cohen | 82f7812 | 2014-12-15 10:10:14 -0800 | [diff] [blame] | 2128 | private void turnOffIms() throws ImsException { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2129 | TelephonyManager tm = (TelephonyManager) |
| 2130 | mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 2131 | tm.disableIms(mPhoneId); |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2132 | } |
| 2133 | |
Naveen Kalla | 525c3a2 | 2017-02-06 14:46:42 -0800 | [diff] [blame] | 2134 | private void addToRecentDisconnectReasons(ImsReasonInfo reason) { |
| 2135 | if (reason == null) return; |
| 2136 | while (mRecentDisconnectReasons.size() >= MAX_RECENT_DISCONNECT_REASONS) { |
| 2137 | mRecentDisconnectReasons.removeFirst(); |
| 2138 | } |
| 2139 | mRecentDisconnectReasons.addLast(reason); |
| 2140 | } |
| 2141 | |
ram | 7da5a11 | 2014-07-16 20:59:27 +0530 | [diff] [blame] | 2142 | /** |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2143 | * Death recipient class for monitoring IMS service. |
| 2144 | */ |
| 2145 | private class ImsServiceDeathRecipient implements IBinder.DeathRecipient { |
| 2146 | @Override |
| 2147 | public void binderDied() { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2148 | mMmTelFeatureConnection = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2149 | mUt = null; |
Libin.Tang@motorola.com | 076c55d | 2014-06-23 19:46:36 -0500 | [diff] [blame] | 2150 | mConfig = null; |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2151 | mEcbm = null; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2152 | mMultiEndpoint = null; |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2153 | } |
| 2154 | } |
| 2155 | |
| 2156 | /** |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2157 | * Gets the ECBM interface to request ECBM exit. |
| 2158 | * |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2159 | * @return the ECBM interface instance |
| 2160 | * @throws ImsException if getting the ECBM interface results in an error |
| 2161 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2162 | public ImsEcbm getEcbmInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2163 | if (mEcbm != null && mEcbm.isBinderAlive()) { |
| 2164 | return mEcbm; |
| 2165 | } |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2166 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2167 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2168 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2169 | IImsEcbm iEcbm = mMmTelFeatureConnection.getEcbmInterface(); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2170 | |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2171 | if (iEcbm == null) { |
| 2172 | throw new ImsException("getEcbmInterface()", |
| 2173 | ImsReasonInfo.CODE_ECBM_NOT_SUPPORTED); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2174 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2175 | mEcbm = new ImsEcbm(iEcbm); |
| 2176 | } catch (RemoteException e) { |
| 2177 | throw new ImsException("getEcbmInterface()", e, |
| 2178 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
Uma Maheswari Ramalingam | 4f2161d | 2014-07-31 16:01:47 -0700 | [diff] [blame] | 2179 | } |
| 2180 | return mEcbm; |
| 2181 | } |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2182 | |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2183 | public void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry, |
| 2184 | byte[] pdu) throws ImsException { |
| 2185 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2186 | mMmTelFeatureConnection.sendSms(token, messageRef, format, smsc, isRetry, pdu); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2187 | } catch (RemoteException e) { |
| 2188 | throw new ImsException("sendSms()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2189 | } |
| 2190 | } |
| 2191 | |
| 2192 | public void acknowledgeSms(int token, int messageRef, int result) throws ImsException { |
| 2193 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2194 | mMmTelFeatureConnection.acknowledgeSms(token, messageRef, result); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2195 | } catch (RemoteException e) { |
| 2196 | throw new ImsException("acknowledgeSms()", e, |
| 2197 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2198 | } |
| 2199 | } |
| 2200 | |
| 2201 | public void acknowledgeSmsReport(int token, int messageRef, int result) throws ImsException{ |
| 2202 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2203 | mMmTelFeatureConnection.acknowledgeSmsReport(token, messageRef, result); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2204 | } catch (RemoteException e) { |
| 2205 | throw new ImsException("acknowledgeSmsReport()", e, |
| 2206 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2207 | } |
| 2208 | } |
| 2209 | |
| 2210 | public String getSmsFormat() throws ImsException{ |
| 2211 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2212 | return mMmTelFeatureConnection.getSmsFormat(); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2213 | } catch (RemoteException e) { |
| 2214 | throw new ImsException("getSmsFormat()", e, |
| 2215 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2216 | } |
| 2217 | } |
| 2218 | |
| 2219 | public void setSmsListener(IImsSmsListener listener) throws ImsException { |
| 2220 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2221 | mMmTelFeatureConnection.setSmsListener(listener); |
Mohamed Abdalkader | 4d68a98 | 2018-01-10 13:29:26 -0800 | [diff] [blame] | 2222 | } catch (RemoteException e) { |
| 2223 | throw new ImsException("setSmsListener()", e, |
| 2224 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2225 | } |
| 2226 | } |
Mohamed Abdalkader | e1453f4 | 2018-01-19 19:48:31 -0800 | [diff] [blame] | 2227 | |
Brad Ebinger | d449b23 | 2018-02-12 14:33:05 -0800 | [diff] [blame] | 2228 | public void onSmsReady() throws ImsException { |
Mohamed Abdalkader | 0e734e1 | 2018-01-23 13:11:00 -0800 | [diff] [blame] | 2229 | try { |
Brad Ebinger | 190ed93 | 2018-01-23 13:41:32 -0800 | [diff] [blame] | 2230 | mMmTelFeatureConnection.onSmsReady(); |
Mohamed Abdalkader | 0e734e1 | 2018-01-23 13:11:00 -0800 | [diff] [blame] | 2231 | } catch (RemoteException e) { |
| 2232 | throw new ImsException("onSmsReady()", e, |
| 2233 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2234 | } |
| 2235 | } |
| 2236 | |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2237 | /** |
Brad Ebinger | d449b23 | 2018-02-12 14:33:05 -0800 | [diff] [blame] | 2238 | * Determines whether or not a call with the specified numbers should be placed over IMS or over |
| 2239 | * CSFB. |
| 2240 | * @param isEmergency is at least one call an emergency number. |
| 2241 | * @param numbers A {@link String} array containing the numbers in the call being placed. Can |
| 2242 | * be multiple numbers in the case of dialing out a conference. |
| 2243 | * @return The result of the query, one of the following values: |
| 2244 | * - {@link MmTelFeature#PROCESS_CALL_IMS} |
| 2245 | * - {@link MmTelFeature#PROCESS_CALL_CSFB} |
| 2246 | * @throws ImsException if the ImsService is not available. In this case, we should fall back |
| 2247 | * to CSFB anyway. |
| 2248 | */ |
| 2249 | public @MmTelFeature.ProcessCallResult int shouldProcessCall(boolean isEmergency, |
| 2250 | String[] numbers) throws ImsException { |
| 2251 | try { |
| 2252 | return mMmTelFeatureConnection.shouldProcessCall(isEmergency, numbers); |
| 2253 | } catch (RemoteException e) { |
| 2254 | throw new ImsException("shouldProcessCall()", e, |
| 2255 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2256 | } |
| 2257 | } |
| 2258 | |
| 2259 | /** |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2260 | * Gets the Multi-Endpoint interface to subscribe to multi-enpoint notifications.. |
| 2261 | * |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2262 | * @return the multi-endpoint interface instance |
| 2263 | * @throws ImsException if getting the multi-endpoint interface results in an error |
| 2264 | */ |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2265 | public ImsMultiEndpoint getMultiEndpointInterface() throws ImsException { |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2266 | if (mMultiEndpoint != null && mMultiEndpoint.isBinderAlive()) { |
| 2267 | return mMultiEndpoint; |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2268 | } |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2269 | |
| 2270 | checkAndThrowExceptionIfServiceUnavailable(); |
| 2271 | try { |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2272 | IImsMultiEndpoint iImsMultiEndpoint = mMmTelFeatureConnection.getMultiEndpointInterface(); |
Brad Ebinger | 138b4a6 | 2017-06-20 16:29:50 -0700 | [diff] [blame] | 2273 | |
| 2274 | if (iImsMultiEndpoint == null) { |
| 2275 | throw new ImsException("getMultiEndpointInterface()", |
| 2276 | ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED); |
| 2277 | } |
| 2278 | mMultiEndpoint = new ImsMultiEndpoint(iImsMultiEndpoint); |
| 2279 | } catch (RemoteException e) { |
| 2280 | throw new ImsException("getMultiEndpointInterface()", e, |
| 2281 | ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); |
| 2282 | } |
| 2283 | |
Tyler Gunn | 4d128b6 | 2016-04-13 15:44:38 -0700 | [diff] [blame] | 2284 | return mMultiEndpoint; |
| 2285 | } |
| 2286 | |
| 2287 | /** |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2288 | * Resets ImsManager settings back to factory defaults. |
| 2289 | * |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2290 | * @deprecated Doesn't support MSIM devices. Use {@link #factoryReset()} instead. |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2291 | * |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2292 | * @hide |
| 2293 | */ |
| 2294 | public static void factoryReset(Context context) { |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2295 | ImsManager mgr = ImsManager.getInstance(context, |
| 2296 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 2297 | if (mgr != null) { |
| 2298 | mgr.factoryReset(); |
| 2299 | } |
| 2300 | loge("factoryReset: ImsManager null."); |
Pavel Zhamaitsiak | 8c065f5 | 2015-11-10 14:36:44 -0800 | [diff] [blame] | 2301 | } |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2302 | |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2303 | /** |
| 2304 | * Resets ImsManager settings back to factory defaults. |
| 2305 | * |
| 2306 | * @hide |
| 2307 | */ |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2308 | public void factoryReset() { |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2309 | // Set VoLTE to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2310 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
manabu, shimoda | 96aee54 | 2017-10-06 15:39:36 +0900 | [diff] [blame] | 2311 | SubscriptionManager.ENHANCED_4G_MODE_ENABLED, |
| 2312 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2313 | CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2314 | |
| 2315 | // Set VoWiFi to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2316 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2317 | SubscriptionManager.WFC_IMS_ENABLED, |
| 2318 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2319 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2320 | |
| 2321 | // Set VoWiFi mode to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2322 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2323 | SubscriptionManager.WFC_IMS_MODE, |
| 2324 | Integer.toString(getIntCarrierConfig( |
| 2325 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2326 | |
| 2327 | // Set VoWiFi roaming to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2328 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2329 | SubscriptionManager.WFC_IMS_ROAMING_ENABLED, |
| 2330 | booleanToPropertyString(getBooleanCarrierConfig( |
| 2331 | CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL))); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2332 | |
| 2333 | // Set VT to default |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2334 | SubscriptionManager.setSubscriptionProperty(getSubId(), |
| 2335 | SubscriptionManager.VT_IMS_ENABLED, booleanToPropertyString(true)); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2336 | |
| 2337 | // Push settings to ImsConfig |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2338 | updateImsServiceConfig(true); |
Brad Ebinger | 16417b4 | 2017-03-07 13:48:50 -0800 | [diff] [blame] | 2339 | } |
| 2340 | |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2341 | private boolean isDataEnabled() { |
Malcolm Chen | d0ef12c | 2017-12-20 11:38:25 -0800 | [diff] [blame] | 2342 | return new TelephonyManager(mContext, getSubId()).isMobileDataEnabled(); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2343 | } |
| 2344 | |
| 2345 | private boolean isVolteProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2346 | return getProvisionedBoolNoException( |
| 2347 | ImsConfig.ConfigConstants.VLT_SETTING_ENABLED); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2348 | } |
| 2349 | |
| 2350 | private boolean isWfcProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2351 | return getProvisionedBoolNoException( |
| 2352 | ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | private boolean isVtProvisioned() { |
Malcolm Chen | 18837ff | 2017-10-25 17:05:41 -0700 | [diff] [blame] | 2356 | return getProvisionedBoolNoException( |
| 2357 | ImsConfig.ConfigConstants.LVC_SETTING_ENABLED); |
Jack Yu | 643ffe4 | 2016-07-08 14:25:46 -0700 | [diff] [blame] | 2358 | } |
| 2359 | |
Malcolm Chen | 212ca65 | 2017-09-28 17:28:45 -0700 | [diff] [blame] | 2360 | private static String booleanToPropertyString(boolean bool) { |
| 2361 | return bool ? "1" : "0"; |
| 2362 | } |
| 2363 | |
| 2364 | |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2365 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 2366 | pw.println("ImsManager:"); |
| 2367 | pw.println(" mPhoneId = " + mPhoneId); |
| 2368 | pw.println(" mConfigUpdated = " + mConfigUpdated); |
Brad Ebinger | 172977a | 2018-01-16 09:36:56 -0800 | [diff] [blame] | 2369 | pw.println(" mImsServiceProxy = " + mMmTelFeatureConnection); |
Amit Mahajan | 24f7b16 | 2016-07-21 16:33:53 -0700 | [diff] [blame] | 2370 | pw.println(" mDataEnabled = " + isDataEnabled()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2371 | pw.println(" ignoreDataEnabledChanged = " + getBooleanCarrierConfig( |
Jack Yu | 5778185 | 2016-11-16 17:20:38 -0800 | [diff] [blame] | 2372 | CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2373 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2374 | pw.println(" isGbaValid = " + isGbaValid()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2375 | pw.println(" isImsTurnOffAllowed = " + isImsTurnOffAllowed()); |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2376 | pw.println(" isNonTtyOrTtyOnVolteEnabled = " + isNonTtyOrTtyOnVolteEnabled()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2377 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2378 | pw.println(" isVolteEnabledByPlatform = " + isVolteEnabledByPlatform()); |
| 2379 | pw.println(" isVolteProvisionedOnDevice = " + isVolteProvisionedOnDevice()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2380 | pw.println(" isEnhanced4gLteModeSettingEnabledByUser = " + |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2381 | isEnhanced4gLteModeSettingEnabledByUser()); |
| 2382 | pw.println(" isVtEnabledByPlatform = " + isVtEnabledByPlatform()); |
| 2383 | pw.println(" isVtEnabledByUser = " + isVtEnabledByUser()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2384 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2385 | pw.println(" isWfcEnabledByPlatform = " + isWfcEnabledByPlatform()); |
| 2386 | pw.println(" isWfcEnabledByUser = " + isWfcEnabledByUser()); |
| 2387 | pw.println(" getWfcMode = " + getWfcMode()); |
| 2388 | pw.println(" isWfcRoamingEnabledByUser = " + isWfcRoamingEnabledByUser()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2389 | |
Brad Ebinger | 479f52c | 2017-08-28 13:19:22 -0700 | [diff] [blame] | 2390 | pw.println(" isVtProvisionedOnDevice = " + isVtProvisionedOnDevice()); |
| 2391 | pw.println(" isWfcProvisionedOnDevice = " + isWfcProvisionedOnDevice()); |
Jack Yu | 2f102bd | 2015-12-28 15:31:48 -0800 | [diff] [blame] | 2392 | pw.flush(); |
| 2393 | } |
Wink Saville | ef36ef6 | 2014-06-11 08:39:38 -0700 | [diff] [blame] | 2394 | } |