blob: 29176a27bbb49ae14610028ab0ee8e772343d39f [file] [log] [blame]
Wink Savilleef36ef62014-06-11 08:39:38 -07001/*
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
17package com.android.ims;
18
Brad Ebinger172977a2018-01-16 09:36:56 -080019import android.annotation.Nullable;
Wink Savilleef36ef62014-06-11 08:39:38 -070020import android.app.PendingIntent;
21import android.content.Context;
Brad Ebinger172977a2018-01-16 09:36:56 -080022import android.os.Bundle;
Brad Ebinger6ddf28e2018-02-21 16:07:23 -080023import android.os.Handler;
Wink Savilleef36ef62014-06-11 08:39:38 -070024import android.os.IBinder;
Brad Ebinger6ddf28e2018-02-21 16:07:23 -080025import android.os.Looper;
Wink Savilleef36ef62014-06-11 08:39:38 -070026import android.os.Message;
Naveen Kalla525c3a22017-02-06 14:46:42 -080027import android.os.Parcel;
Jonathan Basseri2acea6f2015-07-01 15:00:38 -070028import android.os.PersistableBundle;
Wink Savilleef36ef62014-06-11 08:39:38 -070029import android.os.RemoteException;
Etan Cohenaf55a402014-09-04 22:34:41 -070030import android.os.SystemProperties;
Etan Cohen82f78122014-12-15 10:10:14 -080031import android.telecom.TelecomManager;
Junda Liue7663c02015-06-23 11:16:26 -070032import android.telephony.CarrierConfigManager;
Mohamed Abdalkadere1453f42018-01-19 19:48:31 -080033import android.telephony.ims.stub.ImsRegistrationImplBase;
Wink Savilleef36ef62014-06-11 08:39:38 -070034import android.telephony.Rlog;
Etan Cohen82f78122014-12-15 10:10:14 -080035import android.telephony.SubscriptionManager;
Etan Cohencfc784d2014-08-07 18:40:31 -070036import android.telephony.TelephonyManager;
Brad Ebinger190ed932018-01-23 13:41:32 -080037import android.telephony.ims.ImsCallProfile;
38import android.telephony.ims.ImsReasonInfo;
Brad Ebinger172977a2018-01-16 09:36:56 -080039import android.telephony.ims.aidl.IImsConfig;
40import android.telephony.ims.aidl.IImsSmsListener;
41import android.telephony.ims.feature.CapabilityChangeRequest;
42import android.telephony.ims.feature.ImsFeature;
43import android.telephony.ims.feature.MmTelFeature;
Hall Liue511a202017-08-17 15:49:58 -070044import android.util.Log;
Wink Savilleef36ef62014-06-11 08:39:38 -070045
46import com.android.ims.internal.IImsCallSession;
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -070047import com.android.ims.internal.IImsEcbm;
Tyler Gunn4d128b62016-04-13 15:44:38 -070048import com.android.ims.internal.IImsMultiEndpoint;
Wink Savilleef36ef62014-06-11 08:39:38 -070049import com.android.ims.internal.IImsUt;
Brad Ebinger190ed932018-01-23 13:41:32 -080050import android.telephony.ims.ImsCallSession;
Brad Ebinger16780ff2017-01-26 11:18:21 -080051import com.android.internal.annotations.VisibleForTesting;
Libin.Tang@motorola.com076c55d2014-06-23 19:46:36 -050052
Jack Yu2f102bd2015-12-28 15:31:48 -080053import java.io.FileDescriptor;
54import java.io.PrintWriter;
Naveen Kalla525c3a22017-02-06 14:46:42 -080055import java.util.ArrayList;
Etan Cohend7727462014-07-12 14:54:10 -070056import java.util.HashMap;
Brad Ebinger16780ff2017-01-26 11:18:21 -080057import java.util.Set;
Malcolm Chen18837ff2017-10-25 17:05:41 -070058import java.util.concurrent.ConcurrentLinkedDeque;
Brad Ebinger44fd8af2017-12-14 14:24:02 -080059import java.util.concurrent.CopyOnWriteArraySet;
Etan Cohend7727462014-07-12 14:54:10 -070060
Wink Savilleef36ef62014-06-11 08:39:38 -070061/**
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 */
69public class ImsManager {
Etan Cohen19604c02014-08-11 14:32:57 -070070
Etan Cohenaf55a402014-09-04 22:34:41 -070071 /*
72 * Debug flag to override configuration flag
73 */
Etan Cohenb651fa52014-10-22 10:51:29 -070074 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 Cohenea2b5832014-10-23 18:50:35 -070076 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 Cohena00c9192014-12-23 15:02:29 -080078 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 Wang9352c432016-06-08 14:22:20 -070080 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 Cohenaf55a402014-09-04 22:34:41 -070082
Wink Savilleef36ef62014-06-11 08:39:38 -070083 /**
Wink Savilleef36ef62014-06-11 08:39:38 -070084 * The result code to be sent back with the incoming call {@link PendingIntent}.
Brad Ebinger172977a2018-01-16 09:36:56 -080085 * @see #open(MmTelFeature.Listener)
Wink Savilleef36ef62014-06-11 08:39:38 -070086 */
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 Ebinger172977a2018-01-16 09:36:56 -080091 * @see #open(MmTelFeature.Listener)
Wink Savilleef36ef62014-06-11 08:39:38 -070092 */
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 Ebinger16780ff2017-01-26 11:18:21 -080098 * @deprecated
Wink Savilleef36ef62014-06-11 08:39:38 -070099 * @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 Ebinger16780ff2017-01-26 11:18:21 -0800107 * @deprecated
Wink Savilleef36ef62014-06-11 08:39:38 -0700108 * @hide
109 */
110 public static final String ACTION_IMS_SERVICE_DOWN =
111 "com.android.ims.IMS_SERVICE_DOWN";
112
113 /**
Pavel Zhamaitsiak0c2f15c2015-03-12 15:37:54 -0700114 * 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 Cohend7727462014-07-12 14:54:10 -0700122 * Part of the ACTION_IMS_SERVICE_UP or _DOWN intents.
Etan Cohenabbd7882014-09-26 22:35:35 -0700123 * A long value; the phone ID corresponding to the IMS service coming up or down.
Etan Cohend7727462014-07-12 14:54:10 -0700124 * Internal use only.
125 * @hide
126 */
Etan Cohenabbd7882014-09-26 22:35:35 -0700127 public static final String EXTRA_PHONE_ID = "android:phone_id";
Etan Cohend7727462014-07-12 14:54:10 -0700128
129 /**
Wink Savilleef36ef62014-06-11 08:39:38 -0700130 * 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 Ganeshd3adfad2015-05-31 10:06:15 -0700154 /**
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 Mathapati9c033792015-06-16 16:33:16 -0700164 public static final String EXTRA_IS_UNKNOWN_CALL = "android:isUnknown";
Shriram Ganeshd3adfad2015-05-31 10:06:15 -0700165
Malcolm Chen18837ff2017-10-25 17:05:41 -0700166 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 Savilleef36ef62014-06-11 08:39:38 -0700171 private static final String TAG = "ImsManager";
172 private static final boolean DBG = true;
173
Brad Ebinger6ddf28e2018-02-21 16:07:23 -0800174 /**
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 Ebinger6ddf28e2018-02-21 16:07:23 -0800342 manager = mImsManager;
343 }
Brad Ebinger0aed76d2018-03-05 16:39:02 -0800344 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 Ebinger6ddf28e2018-02-21 16:07:23 -0800355 }
356
357 private void notifyNotReady() {
358 mListener.connectionUnavailable();
359 }
360 }
361
Wink Saville1e5a38a2014-10-23 10:24:46 -0700362 private static HashMap<Integer, ImsManager> sImsManagerInstances =
363 new HashMap<Integer, ImsManager>();
Etan Cohend7727462014-07-12 14:54:10 -0700364
Wink Savilleef36ef62014-06-11 08:39:38 -0700365 private Context mContext;
Brad Ebinger16417b42017-03-07 13:48:50 -0800366 private CarrierConfigManager mConfigManager;
Etan Cohenabbd7882014-09-26 22:35:35 -0700367 private int mPhoneId;
Brad Ebinger16780ff2017-01-26 11:18:21 -0800368 private final boolean mConfigDynamicBind;
Brad Ebinger172977a2018-01-16 09:36:56 -0800369 private @Nullable MmTelFeatureConnection mMmTelFeatureConnection = null;
Wink Savilleef36ef62014-06-11 08:39:38 -0700370 private ImsServiceDeathRecipient mDeathRecipient = new ImsServiceDeathRecipient();
371 // Ut interface for the supplementary service configuration
372 private ImsUt mUt = null;
Libin.Tang@motorola.com076c55d2014-06-23 19:46:36 -0500373 // Interface to get/set ims config items
374 private ImsConfig mConfig = null;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -0700375 private boolean mConfigUpdated = false;
Wink Savilleef36ef62014-06-11 08:39:38 -0700376
Pavel Zhamaitsiakf4b90322016-01-26 14:34:09 -0800377 private ImsConfigListener mImsConfigListener;
378
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -0700379 // ECBM interface
380 private ImsEcbm mEcbm = null;
381
Tyler Gunn4d128b62016-04-13 15:44:38 -0700382 private ImsMultiEndpoint mMultiEndpoint = null;
383
Brad Ebinger172977a2018-01-16 09:36:56 -0800384 private Set<MmTelFeatureConnection.IFeatureUpdate> mStatusCallbacks =
385 new CopyOnWriteArraySet<>();
Brad Ebinger16780ff2017-01-26 11:18:21 -0800386
Amit Mahajan24f7b162016-07-21 16:33:53 -0700387 public static final String TRUE = "true";
388 public static final String FALSE = "false";
Jack Yu643ffe42016-07-08 14:25:46 -0700389
Naveen Kalla525c3a22017-02-06 14:46:42 -0800390 // 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 Savilleef36ef62014-06-11 08:39:38 -0700395 /**
396 * Gets a manager instance.
397 *
398 * @param context application context for creating the manager object
Etan Cohenabbd7882014-09-26 22:35:35 -0700399 * @param phoneId the phone ID for the IMS Service
400 * @return the manager instance corresponding to the phoneId
Wink Savilleef36ef62014-06-11 08:39:38 -0700401 */
Etan Cohenabbd7882014-09-26 22:35:35 -0700402 public static ImsManager getInstance(Context context, int phoneId) {
Etan Cohend7727462014-07-12 14:54:10 -0700403 synchronized (sImsManagerInstances) {
Naveen Kalla525c3a22017-02-06 14:46:42 -0800404 if (sImsManagerInstances.containsKey(phoneId)) {
Brad Ebingerff097922017-06-19 15:43:08 -0700405 ImsManager m = sImsManagerInstances.get(phoneId);
406 // May be null for some tests
407 if (m != null) {
408 m.connectIfServiceIsAvailable();
409 }
410 return m;
Naveen Kalla525c3a22017-02-06 14:46:42 -0800411 }
Wink Savilleef36ef62014-06-11 08:39:38 -0700412
Etan Cohenabbd7882014-09-26 22:35:35 -0700413 ImsManager mgr = new ImsManager(context, phoneId);
414 sImsManagerInstances.put(phoneId, mgr);
Etan Cohend7727462014-07-12 14:54:10 -0700415
416 return mgr;
417 }
Wink Savilleef36ef62014-06-11 08:39:38 -0700418 }
419
Etan Cohen45b5f312014-08-19 15:55:08 -0700420 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800421 * Returns the user configuration of Enhanced 4G LTE Mode setting.
422 *
423 * @deprecated Doesn't support MSIM devices. Use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700424 * {@link #isEnhanced4gLteModeSettingEnabledByUser()} instead.
Etan Cohen45b5f312014-08-19 15:55:08 -0700425 */
426 public static boolean isEnhanced4gLteModeSettingEnabledByUser(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700427 ImsManager mgr = ImsManager.getInstance(context,
428 SubscriptionManager.getDefaultVoicePhoneId());
429 if (mgr != null) {
430 return mgr.isEnhanced4gLteModeSettingEnabledByUser();
Sungmin Choi2f1af952016-02-01 17:15:35 +0900431 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700432 loge("isEnhanced4gLteModeSettingEnabledByUser: ImsManager null, returning default value.");
433 return false;
Etan Cohen45b5f312014-08-19 15:55:08 -0700434 }
435
436 /**
manabu, shimoda96aee542017-10-06 15:39:36 +0900437 * 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 Ebinger16417b42017-03-07 13:48:50 -0800444 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700445 public boolean isEnhanced4gLteModeSettingEnabledByUser() {
Malcolm Chen212ca652017-09-28 17:28:45 -0700446 int setting = SubscriptionManager.getIntegerSubscriptionProperty(
447 getSubId(), SubscriptionManager.ENHANCED_4G_MODE_ENABLED,
448 SUB_PROPERTY_NOT_INITIALIZED, mContext);
manabu, shimoda96aee542017-10-06 15:39:36 +0900449 boolean onByDefault = getBooleanCarrierConfig(
450 CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL);
Malcolm Chen212ca652017-09-28 17:28:45 -0700451
manabu, shimoda96aee542017-10-06 15:39:36 +0900452 // 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 Ebinger16417b42017-03-07 13:48:50 -0800459 }
460
461 /**
462 * Change persistent Enhanced 4G LTE Mode setting.
463 *
Brad Ebinger479f52c2017-08-28 13:19:22 -0700464 * @deprecated Doesn't support MSIM devices. Use {@link #setEnhanced4gLteModeSetting(boolean)}
Brad Ebinger16417b42017-03-07 13:48:50 -0800465 * instead.
Etan Cohen82f78122014-12-15 10:10:14 -0800466 */
467 public static void setEnhanced4gLteModeSetting(Context context, boolean enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700468 ImsManager mgr = ImsManager.getInstance(context,
469 SubscriptionManager.getDefaultVoicePhoneId());
470 if (mgr != null) {
471 mgr.setEnhanced4gLteModeSetting(enabled);
Etan Cohen82f78122014-12-15 10:10:14 -0800472 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700473 loge("setEnhanced4gLteModeSetting: ImsManager null, value not set.");
Etan Cohen82f78122014-12-15 10:10:14 -0800474 }
475
476 /**
manabu, shimoda96aee542017-10-06 15:39:36 +0900477 * Change persistent Enhanced 4G LTE Mode setting. If the option is not editable
Brad Ebinger16417b42017-03-07 13:48:50 -0800478 * ({@link CarrierConfigManager#KEY_EDITABLE_ENHANCED_4G_LTE_BOOL} is false), this method will
manabu, shimoda96aee542017-10-06 15:39:36 +0900479 * set the setting to the default value specified by
480 * {@link CarrierConfigManager#KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL}.
Brad Ebinger16417b42017-03-07 13:48:50 -0800481 *
482 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700483 public void setEnhanced4gLteModeSetting(boolean enabled) {
manabu, shimoda96aee542017-10-06 15:39:36 +0900484 // 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 Ebinger16417b42017-03-07 13:48:50 -0800489
Malcolm Chen212ca652017-09-28 17:28:45 -0700490 int prevSetting = SubscriptionManager.getIntegerSubscriptionProperty(
491 getSubId(), SubscriptionManager.ENHANCED_4G_MODE_ENABLED,
492 SUB_PROPERTY_NOT_INITIALIZED, mContext);
Brad Ebinger16417b42017-03-07 13:48:50 -0800493
manabu, shimoda96aee542017-10-06 15:39:36 +0900494 if (prevSetting != (enabled ?
495 ImsConfig.FeatureValueConstants.ON :
496 ImsConfig.FeatureValueConstants.OFF)) {
Malcolm Chen212ca652017-09-28 17:28:45 -0700497 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 Ebinger16417b42017-03-07 13:48:50 -0800505 }
506 }
507 }
508
509 /**
Etan Cohen82f78122014-12-15 10:10:14 -0800510 * Indicates whether the call is non-TTY or if TTY - whether TTY on VoLTE is
511 * supported.
Brad Ebinger16417b42017-03-07 13:48:50 -0800512 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700513 * {@link #isNonTtyOrTtyOnVolteEnabled()} instead.
Etan Cohen82f78122014-12-15 10:10:14 -0800514 */
515 public static boolean isNonTtyOrTtyOnVolteEnabled(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700516 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(
fionaxu5803ef02016-03-08 11:48:48 -0800531 CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) {
Etan Cohen82f78122014-12-15 10:10:14 -0800532 return true;
533 }
534
Brad Ebinger479f52c2017-08-28 13:19:22 -0700535 TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
Hall Liue511a202017-08-17 15:49:58 -0700536 if (tm == null) {
537 Log.w(TAG, "isNonTtyOrTtyOnVolteEnabled: telecom not available");
538 return true;
539 }
540 return tm.getCurrentTtyMode() == TelecomManager.TTY_MODE_OFF;
Etan Cohen82f78122014-12-15 10:10:14 -0800541 }
542
543 /**
Etan Cohenea2b5832014-10-23 18:50:35 -0700544 * Returns a platform configuration for VoLTE which may override the user setting.
Brad Ebinger16417b42017-03-07 13:48:50 -0800545 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700546 * {@link #isVolteEnabledByPlatform()} instead.
Etan Cohen45b5f312014-08-19 15:55:08 -0700547 */
Etan Cohenea2b5832014-10-23 18:50:35 -0700548 public static boolean isVolteEnabledByPlatform(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700549 ImsManager mgr = ImsManager.getInstance(context,
550 SubscriptionManager.getDefaultVoicePhoneId());
551 if (mgr != null) {
552 return mgr.isVolteEnabledByPlatform();
Etan Cohenaf55a402014-09-04 22:34:41 -0700553 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700554 loge("isVolteEnabledByPlatform: ImsManager null, returning default value.");
555 return false;
Etan Cohenb5388a32014-11-26 11:57:47 -0800556 }
557
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700558 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800559 * Returns a platform configuration for VoLTE which may override the user setting on a per Slot
560 * basis.
561 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700562 public boolean isVolteEnabledByPlatform() {
Malcolm Chen18837ff2017-10-25 17:05:41 -0700563 // 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 Ebinger16417b42017-03-07 13:48:50 -0800570 return true;
571 }
572
573 return mContext.getResources().getBoolean(
574 com.android.internal.R.bool.config_device_volte_available)
Malcolm Chen212ca652017-09-28 17:28:45 -0700575 && getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL)
Brad Ebinger479f52c2017-08-28 13:19:22 -0700576 && isGbaValid();
Brad Ebinger16417b42017-03-07 13:48:50 -0800577 }
578
579 /**
580 * Indicates whether VoLTE is provisioned on device.
581 *
582 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700583 * {@link #isVolteProvisionedOnDevice()} instead.
Etan Cohenb5388a32014-11-26 11:57:47 -0800584 */
585 public static boolean isVolteProvisionedOnDevice(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700586 ImsManager mgr = ImsManager.getInstance(context,
587 SubscriptionManager.getDefaultVoicePhoneId());
588 if (mgr != null) {
589 return mgr.isVolteProvisionedOnDevice();
Etan Cohenb5388a32014-11-26 11:57:47 -0800590 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700591 loge("isVolteProvisionedOnDevice: ImsManager null, returning default value.");
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700592 return true;
593 }
594
595 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800596 * Indicates whether VoLTE is provisioned on this slot.
597 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700598 public boolean isVolteProvisionedOnDevice() {
599 if (getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -0800600 CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) {
601 return isVolteProvisioned();
602 }
603
604 return true;
605 }
606
607 /**
Meng Wang54fd41a2017-04-12 11:44:47 -0700608 * 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 Ebinger16417b42017-03-07 13:48:50 -0800612 *
613 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700614 * {@link #isWfcProvisionedOnDevice()} instead.
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700615 */
616 public static boolean isWfcProvisionedOnDevice(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700617 ImsManager mgr = ImsManager.getInstance(context,
618 SubscriptionManager.getDefaultVoicePhoneId());
619 if (mgr != null) {
620 return mgr.isWfcProvisionedOnDevice();
Meng Wang54fd41a2017-04-12 11:44:47 -0700621 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700622 loge("isWfcProvisionedOnDevice: ImsManager null, returning default value.");
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700623 return true;
624 }
625
626 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800627 * Indicates whether VoWifi is provisioned on slot.
Meng Wang54fd41a2017-04-12 11:44:47 -0700628 *
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 Ebinger16417b42017-03-07 13:48:50 -0800631 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700632 public boolean isWfcProvisionedOnDevice() {
633 if (getBooleanCarrierConfig(
Meng Wang54fd41a2017-04-12 11:44:47 -0700634 CarrierConfigManager.KEY_CARRIER_VOLTE_OVERRIDE_WFC_PROVISIONING_BOOL)) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700635 if (!isVolteProvisionedOnDevice()) {
Meng Wang54fd41a2017-04-12 11:44:47 -0700636 return false;
637 }
638 }
639
Brad Ebinger479f52c2017-08-28 13:19:22 -0700640 if (getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -0800641 CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) {
Meng Wang54fd41a2017-04-12 11:44:47 -0700642 return isWfcProvisioned();
Brad Ebinger16417b42017-03-07 13:48:50 -0800643 }
644
645 return true;
646 }
647
648 /**
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700649 * Indicates whether VT is provisioned on device
Brad Ebinger16417b42017-03-07 13:48:50 -0800650 *
651 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700652 * {@link #isVtProvisionedOnDevice()} instead.
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700653 */
654 public static boolean isVtProvisionedOnDevice(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700655 ImsManager mgr = ImsManager.getInstance(context,
656 SubscriptionManager.getDefaultVoicePhoneId());
657 if (mgr != null) {
658 return mgr.isVtProvisionedOnDevice();
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700659 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700660 loge("isVtProvisionedOnDevice: ImsManager null, returning default value.");
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -0700661 return true;
Etan Cohenb651fa52014-10-22 10:51:29 -0700662 }
663
Etan Cohenea2b5832014-10-23 18:50:35 -0700664 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800665 * Indicates whether VT is provisioned on slot.
666 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700667 public boolean isVtProvisionedOnDevice() {
668 if (getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -0800669 CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) {
670 return isVtProvisioned();
671 }
672
673 return true;
674 }
675
676 /**
Etan Cohenea2b5832014-10-23 18:50:35 -0700677 * 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 Ebinger16417b42017-03-07 13:48:50 -0800681 *
682 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700683 * {@link #isVtEnabledByPlatform()} instead.
Etan Cohenea2b5832014-10-23 18:50:35 -0700684 */
Etan Cohenb651fa52014-10-22 10:51:29 -0700685 public static boolean isVtEnabledByPlatform(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700686 ImsManager mgr = ImsManager.getInstance(context,
687 SubscriptionManager.getDefaultVoicePhoneId());
688 if (mgr != null) {
689 return mgr.isVtEnabledByPlatform();
Etan Cohenea2b5832014-10-23 18:50:35 -0700690 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700691 loge("isVtEnabledByPlatform: ImsManager null, returning default value.");
692 return false;
Etan Cohen45b5f312014-08-19 15:55:08 -0700693 }
694
Etan Cohena00c9192014-12-23 15:02:29 -0800695 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800696 * 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 Ebinger479f52c2017-08-28 13:19:22 -0700701 public boolean isVtEnabledByPlatform() {
Malcolm Chen18837ff2017-10-25 17:05:41 -0700702 // 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 Ebinger16417b42017-03-07 13:48:50 -0800708 return true;
709 }
710
711 return mContext.getResources().getBoolean(
712 com.android.internal.R.bool.config_device_vt_available) &&
Malcolm Chen212ca652017-09-28 17:28:45 -0700713 getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VT_AVAILABLE_BOOL) &&
Brad Ebinger479f52c2017-08-28 13:19:22 -0700714 isGbaValid();
Brad Ebinger16417b42017-03-07 13:48:50 -0800715 }
716
717 /**
Etan Cohena7d32e82015-05-04 18:02:09 -0700718 * Returns the user configuration of VT setting
Brad Ebinger16417b42017-03-07 13:48:50 -0800719 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700720 * {@link #isVtEnabledByUser()} instead.
Etan Cohena7d32e82015-05-04 18:02:09 -0700721 */
722 public static boolean isVtEnabledByUser(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700723 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 Cohena7d32e82015-05-04 18:02:09 -0700730 }
731
732 /**
Malcolm Chen212ca652017-09-28 17:28:45 -0700733 * Returns the user configuration of VT setting per slot. If not set, it
734 * returns true as default value.
Brad Ebinger16417b42017-03-07 13:48:50 -0800735 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700736 public boolean isVtEnabledByUser() {
Malcolm Chen212ca652017-09-28 17:28:45 -0700737 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, shimoda96aee542017-10-06 15:39:36 +0900742 return (setting == SUB_PROPERTY_NOT_INITIALIZED
743 || setting == ImsConfig.FeatureValueConstants.ON);
Brad Ebinger16417b42017-03-07 13:48:50 -0800744 }
745
746 /**
Etan Cohena7d32e82015-05-04 18:02:09 -0700747 * Change persistent VT enabled setting
Brad Ebinger16417b42017-03-07 13:48:50 -0800748 *
Brad Ebinger479f52c2017-08-28 13:19:22 -0700749 * @deprecated Does not support MSIM devices. Please use {@link #setVtSetting(boolean)} instead.
Etan Cohena7d32e82015-05-04 18:02:09 -0700750 */
751 public static void setVtSetting(Context context, boolean enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700752 ImsManager mgr = ImsManager.getInstance(context,
Etan Cohena7d32e82015-05-04 18:02:09 -0700753 SubscriptionManager.getDefaultVoicePhoneId());
Brad Ebinger479f52c2017-08-28 13:19:22 -0700754 if (mgr != null) {
755 mgr.setVtSetting(enabled);
Etan Cohena7d32e82015-05-04 18:02:09 -0700756 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700757 loge("setVtSetting: ImsManager null, can not set value.");
Etan Cohena7d32e82015-05-04 18:02:09 -0700758 }
759
Brad Ebinger16417b42017-03-07 13:48:50 -0800760 /**
761 * Change persistent VT enabled setting for slot.
762 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700763 public void setVtSetting(boolean enabled) {
Brad Ebinger172977a2018-01-16 09:36:56 -0800764 SubscriptionManager.setSubscriptionProperty(getSubId(), SubscriptionManager.VT_IMS_ENABLED,
Malcolm Chen212ca652017-09-28 17:28:45 -0700765 booleanToPropertyString(enabled));
Brad Ebinger172977a2018-01-16 09:36:56 -0800766
Brad Ebinger16417b42017-03-07 13:48:50 -0800767 try {
Brad Ebinger172977a2018-01-16 09:36:56 -0800768 changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
769 ImsRegistrationImplBase.REGISTRATION_TECH_LTE, enabled);
Brad Ebinger16417b42017-03-07 13:48:50 -0800770
771 if (enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700772 log("setVtSetting(b) : turnOnIms");
Brad Ebinger16417b42017-03-07 13:48:50 -0800773 turnOnIms();
Brad Ebinger479f52c2017-08-28 13:19:22 -0700774 } else if (isVolteEnabledByPlatform()
775 && (!isVolteEnabledByPlatform()
776 || !isEnhanced4gLteModeSettingEnabledByUser())) {
777 log("setVtSetting(b) : imsServiceAllowTurnOff -> turnOffIms");
Brad Ebinger16417b42017-03-07 13:48:50 -0800778 turnOffIms();
779 }
Brad Ebinger172977a2018-01-16 09:36:56 -0800780 } 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 Ebinger479f52c2017-08-28 13:19:22 -0700784 loge("setVtSetting(b): ", e);
Brad Ebinger16417b42017-03-07 13:48:50 -0800785 }
786 }
787
788 /**
Meng Wang9352c432016-06-08 14:22:20 -0700789 * Returns whether turning off ims is allowed by platform.
790 * The platform property may override the carrier config.
Brad Ebinger16417b42017-03-07 13:48:50 -0800791 *
792 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700793 * {@link #isTurnOffImsAllowedByPlatform()} instead.
Meng Wang9352c432016-06-08 14:22:20 -0700794 */
795 private static boolean isTurnOffImsAllowedByPlatform(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700796 ImsManager mgr = ImsManager.getInstance(context,
797 SubscriptionManager.getDefaultVoicePhoneId());
798 if (mgr != null) {
799 return mgr.isTurnOffImsAllowedByPlatform();
Meng Wang9352c432016-06-08 14:22:20 -0700800 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700801 loge("isTurnOffImsAllowedByPlatform: ImsManager null, returning default value.");
802 return true;
Meng Wang9352c432016-06-08 14:22:20 -0700803 }
804
Etan Cohena7d32e82015-05-04 18:02:09 -0700805 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800806 * Returns whether turning off ims is allowed by platform.
807 * The platform property may override the carrier config.
808 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700809 private boolean isTurnOffImsAllowedByPlatform() {
Malcolm Chen18837ff2017-10-25 17:05:41 -0700810 // 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 Ebinger16417b42017-03-07 13:48:50 -0800816 return true;
817 }
Malcolm Chen18837ff2017-10-25 17:05:41 -0700818
Brad Ebinger479f52c2017-08-28 13:19:22 -0700819 return getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -0800820 CarrierConfigManager.KEY_CARRIER_ALLOW_TURNOFF_IMS_BOOL);
821 }
822
823 /**
Etan Cohena00c9192014-12-23 15:02:29 -0800824 * Returns the user configuration of WFC setting
Brad Ebinger16417b42017-03-07 13:48:50 -0800825 *
826 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700827 * {@link #isWfcEnabledByUser()} instead.
Etan Cohena00c9192014-12-23 15:02:29 -0800828 */
829 public static boolean isWfcEnabledByUser(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700830 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 Cohena00c9192014-12-23 15:02:29 -0800837 }
838
839 /**
Malcolm Chen212ca652017-09-28 17:28:45 -0700840 * Returns the user configuration of WFC setting for slot. If not set, it
841 * queries CarrierConfig value as default.
Brad Ebinger16417b42017-03-07 13:48:50 -0800842 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700843 public boolean isWfcEnabledByUser() {
Malcolm Chen212ca652017-09-28 17:28:45 -0700844 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, shimoda96aee542017-10-06 15:39:36 +0900853 return setting == ImsConfig.FeatureValueConstants.ON;
Malcolm Chen212ca652017-09-28 17:28:45 -0700854 }
Brad Ebinger16417b42017-03-07 13:48:50 -0800855 }
856
857 /**
858 * Change persistent WFC enabled setting.
859 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -0700860 * {@link #setWfcSetting} instead.
Etan Cohena00c9192014-12-23 15:02:29 -0800861 */
862 public static void setWfcSetting(Context context, boolean enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700863 ImsManager mgr = ImsManager.getInstance(context,
Etan Cohena00c9192014-12-23 15:02:29 -0800864 SubscriptionManager.getDefaultVoicePhoneId());
Brad Ebinger479f52c2017-08-28 13:19:22 -0700865 if (mgr != null) {
866 mgr.setWfcSetting(enabled);
Etan Cohena00c9192014-12-23 15:02:29 -0800867 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700868 loge("setWfcSetting: ImsManager null, can not set value.");
Etan Cohena00c9192014-12-23 15:02:29 -0800869 }
870
871 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800872 * Change persistent WFC enabled setting for slot.
873 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700874 public void setWfcSetting(boolean enabled) {
Malcolm Chen212ca652017-09-28 17:28:45 -0700875 SubscriptionManager.setSubscriptionProperty(getSubId(),
876 SubscriptionManager.WFC_IMS_ENABLED, booleanToPropertyString(enabled));
Brad Ebinger16417b42017-03-07 13:48:50 -0800877
Brad Ebinger479f52c2017-08-28 13:19:22 -0700878 setWfcNonPersistent(enabled, getWfcMode());
Meng Wang51c09072017-03-27 10:47:45 -0700879 }
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 Ebinger479f52c2017-08-28 13:19:22 -0700886 public void setWfcNonPersistent(boolean enabled, int wfcMode) {
Meng Wang51c09072017-03-27 10:47:45 -0700887 // Force IMS to register over LTE when turning off WFC
888 int imsWfcModeFeatureValue =
889 enabled ? wfcMode : ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
890
Brad Ebinger16417b42017-03-07 13:48:50 -0800891 try {
Brad Ebinger172977a2018-01-16 09:36:56 -0800892 changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
893 ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, enabled);
Brad Ebinger16417b42017-03-07 13:48:50 -0800894
895 if (enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700896 log("setWfcSetting() : turnOnIms");
Brad Ebinger16417b42017-03-07 13:48:50 -0800897 turnOnIms();
Brad Ebinger479f52c2017-08-28 13:19:22 -0700898 } else if (isTurnOffImsAllowedByPlatform()
899 && (!isVolteEnabledByPlatform()
900 || !isEnhanced4gLteModeSettingEnabledByUser())) {
901 log("setWfcSetting() : imsServiceAllowTurnOff -> turnOffIms");
Brad Ebinger16417b42017-03-07 13:48:50 -0800902 turnOffIms();
903 }
904
Brad Ebinger479f52c2017-08-28 13:19:22 -0700905 setWfcModeInternal(imsWfcModeFeatureValue);
Brad Ebinger172977a2018-01-16 09:36:56 -0800906 } catch (ImsException | RemoteException e) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700907 loge("setWfcSetting(): ", e);
Brad Ebinger16417b42017-03-07 13:48:50 -0800908 }
909 }
910
911 /**
912 * Returns the user configuration of WFC preference setting.
913 *
Malcolm Chen212ca652017-09-28 17:28:45 -0700914 * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean roaming)} instead.
Etan Cohena00c9192014-12-23 15:02:29 -0800915 */
916 public static int getWfcMode(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700917 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 Cohena00c9192014-12-23 15:02:29 -0800924 }
925
926 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800927 * Returns the user configuration of WFC preference setting
Malcolm Chen212ca652017-09-28 17:28:45 -0700928 * @deprecated. Use {@link #getWfcMode(boolean roaming)} instead.
Brad Ebinger16417b42017-03-07 13:48:50 -0800929 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700930 public int getWfcMode() {
Malcolm Chen212ca652017-09-28 17:28:45 -0700931 return getWfcMode(false);
Brad Ebinger16417b42017-03-07 13:48:50 -0800932 }
933
934 /**
935 * Change persistent WFC preference setting.
936 *
Brad Ebinger479f52c2017-08-28 13:19:22 -0700937 * @deprecated Doesn't support MSIM devices. Use {@link #setWfcMode(int)} instead.
Etan Cohena00c9192014-12-23 15:02:29 -0800938 */
939 public static void setWfcMode(Context context, int wfcMode) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700940 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 Zhamaitsiak9e6eca22015-03-16 15:30:53 -0700946 }
947
Meng Wang37477012016-09-20 09:59:56 -0700948 /**
Brad Ebinger16417b42017-03-07 13:48:50 -0800949 * Change persistent WFC preference setting for slot.
950 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700951 public void setWfcMode(int wfcMode) {
952 if (DBG) log("setWfcMode(i) - setting=" + wfcMode);
Malcolm Chen212ca652017-09-28 17:28:45 -0700953
954 SubscriptionManager.setSubscriptionProperty(getSubId(),
955 SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode));
Brad Ebinger16417b42017-03-07 13:48:50 -0800956
Brad Ebinger479f52c2017-08-28 13:19:22 -0700957 setWfcModeInternal(wfcMode);
Brad Ebinger16417b42017-03-07 13:48:50 -0800958 }
959
960 /**
Suresh Koleti76491082017-04-21 18:39:50 +0530961 * 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 Ebinger479f52c2017-08-28 13:19:22 -0700965 if (!getBooleanCarrierConfig(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL)) {
966 setWfcMode(getIntCarrierConfig(
Suresh Koleti76491082017-04-21 18:39:50 +0530967 CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT));
968 }
969 }
970
971 /**
Meng Wang37477012016-09-20 09:59:56 -0700972 * Returns the user configuration of WFC preference setting
973 *
974 * @param roaming {@code false} for home network setting, {@code true} for roaming setting
Brad Ebinger16417b42017-03-07 13:48:50 -0800975 *
Brad Ebinger479f52c2017-08-28 13:19:22 -0700976 * @deprecated Doesn't support MSIM devices. Use {@link #getWfcMode(boolean)} instead.
Meng Wang37477012016-09-20 09:59:56 -0700977 */
978 public static int getWfcMode(Context context, boolean roaming) {
Brad Ebinger479f52c2017-08-28 13:19:22 -0700979 ImsManager mgr = ImsManager.getInstance(context,
980 SubscriptionManager.getDefaultVoicePhoneId());
981 if (mgr != null) {
982 return mgr.getWfcMode(roaming);
Meng Wang37477012016-09-20 09:59:56 -0700983 }
Brad Ebinger479f52c2017-08-28 13:19:22 -0700984 loge("getWfcMode: ImsManager null, returning default value.");
985 return ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
Meng Wang37477012016-09-20 09:59:56 -0700986 }
987
988 /**
Malcolm Chen212ca652017-09-28 17:28:45 -0700989 * Returns the user configuration of WFC preference setting for slot. If not set, it
990 * queries CarrierConfig value as default.
Brad Ebinger16417b42017-03-07 13:48:50 -0800991 *
992 * @param roaming {@code false} for home network setting, {@code true} for roaming setting
993 */
Brad Ebinger479f52c2017-08-28 13:19:22 -0700994 public int getWfcMode(boolean roaming) {
Brad Ebinger16417b42017-03-07 13:48:50 -0800995 int setting = 0;
996 if (!roaming) {
Malcolm Chen212ca652017-09-28 17:28:45 -0700997 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 Ebinger479f52c2017-08-28 13:19:22 -07001006 if (DBG) log("getWfcMode - setting=" + setting);
Brad Ebinger16417b42017-03-07 13:48:50 -08001007 } else {
Malcolm Chen212ca652017-09-28 17:28:45 -07001008 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 Ebinger479f52c2017-08-28 13:19:22 -07001018 if (DBG) log("getWfcMode (roaming) - setting=" + setting);
Brad Ebinger16417b42017-03-07 13:48:50 -08001019 }
1020 return setting;
1021 }
1022
1023 /**
Meng Wang37477012016-09-20 09:59:56 -07001024 * Change persistent WFC preference setting
1025 *
1026 * @param roaming {@code false} for home network setting, {@code true} for roaming setting
Brad Ebinger16417b42017-03-07 13:48:50 -08001027 *
Brad Ebinger479f52c2017-08-28 13:19:22 -07001028 * @deprecated Doesn't support MSIM devices. Please use {@link #setWfcMode(int, boolean)}
1029 * instead.
Meng Wang37477012016-09-20 09:59:56 -07001030 */
1031 public static void setWfcMode(Context context, int wfcMode, boolean roaming) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001032 ImsManager mgr = ImsManager.getInstance(context,
1033 SubscriptionManager.getDefaultVoicePhoneId());
1034 if (mgr != null) {
1035 mgr.setWfcMode(wfcMode, roaming);
Meng Wang37477012016-09-20 09:59:56 -07001036 }
Brad Ebinger479f52c2017-08-28 13:19:22 -07001037 loge("setWfcMode: ImsManager null, can not set value.");
Meng Wang37477012016-09-20 09:59:56 -07001038 }
1039
Brad Ebinger16417b42017-03-07 13:48:50 -08001040 /**
1041 * Change persistent WFC preference setting
1042 *
1043 * @param roaming {@code false} for home network setting, {@code true} for roaming setting
1044 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001045 public void setWfcMode(int wfcMode, boolean roaming) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001046 if (!roaming) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001047 if (DBG) log("setWfcMode(i,b) - setting=" + wfcMode);
Malcolm Chen212ca652017-09-28 17:28:45 -07001048 SubscriptionManager.setSubscriptionProperty(getSubId(),
1049 SubscriptionManager.WFC_IMS_MODE, Integer.toString(wfcMode));
Brad Ebinger16417b42017-03-07 13:48:50 -08001050 } else {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001051 if (DBG) log("setWfcMode(i,b) (roaming) - setting=" + wfcMode);
Malcolm Chen212ca652017-09-28 17:28:45 -07001052 SubscriptionManager.setSubscriptionProperty(getSubId(),
1053 SubscriptionManager.WFC_IMS_ROAMING_MODE, Integer.toString(wfcMode));
Brad Ebinger16417b42017-03-07 13:48:50 -08001054 }
1055
Brad Ebinger479f52c2017-08-28 13:19:22 -07001056 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 Ebinger16417b42017-03-07 13:48:50 -08001064 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 Ebinger479f52c2017-08-28 13:19:22 -07001069 return subId;
Brad Ebinger16417b42017-03-07 13:48:50 -08001070 }
1071
Pavel Zhamaitsiak9e6eca22015-03-16 15:30:53 -07001072 private static void setWfcModeInternal(Context context, int wfcMode) {
Etan Cohena00c9192014-12-23 15:02:29 -08001073 final ImsManager imsManager = ImsManager.getInstance(context,
1074 SubscriptionManager.getDefaultVoicePhoneId());
1075 if (imsManager != null) {
1076 final int value = wfcMode;
Pavel Zhamaitsiak47aeacf2016-03-30 18:54:55 -07001077 Thread thread = new Thread(new Runnable() {
Etan Cohena00c9192014-12-23 15:02:29 -08001078 public void run() {
1079 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001080 imsManager.getConfigInterface().setConfig(
Etan Cohena00c9192014-12-23 15:02:29 -08001081 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE,
1082 value);
1083 } catch (ImsException e) {
1084 // do nothing
1085 }
1086 }
1087 });
Pavel Zhamaitsiak47aeacf2016-03-30 18:54:55 -07001088 thread.start();
Etan Cohena00c9192014-12-23 15:02:29 -08001089 }
1090 }
1091
Brad Ebinger479f52c2017-08-28 13:19:22 -07001092 private void setWfcModeInternal(int wfcMode) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001093 final int value = wfcMode;
1094 Thread thread = new Thread(() -> {
Malcolm Chen212ca652017-09-28 17:28:45 -07001095 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001096 getConfigInterface().setConfig(
Malcolm Chen212ca652017-09-28 17:28:45 -07001097 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE, value);
1098 } catch (ImsException e) {
1099 // do nothing
1100 }
Brad Ebinger16417b42017-03-07 13:48:50 -08001101 });
1102 thread.start();
1103 }
1104
Etan Cohena00c9192014-12-23 15:02:29 -08001105 /**
1106 * Returns the user configuration of WFC roaming setting
Brad Ebinger16417b42017-03-07 13:48:50 -08001107 *
1108 * @deprecated Does not support MSIM devices. Please use
Brad Ebinger479f52c2017-08-28 13:19:22 -07001109 * {@link #isWfcRoamingEnabledByUser()} instead.
Etan Cohena00c9192014-12-23 15:02:29 -08001110 */
1111 public static boolean isWfcRoamingEnabledByUser(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001112 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 Cohena00c9192014-12-23 15:02:29 -08001119 }
1120
1121 /**
Malcolm Chen212ca652017-09-28 17:28:45 -07001122 * Returns the user configuration of WFC roaming setting for slot. If not set, it
1123 * queries CarrierConfig value as default.
Brad Ebinger16417b42017-03-07 13:48:50 -08001124 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001125 public boolean isWfcRoamingEnabledByUser() {
Malcolm Chen212ca652017-09-28 17:28:45 -07001126 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, shimoda96aee542017-10-06 15:39:36 +09001133 return setting == ImsConfig.FeatureValueConstants.ON;
Malcolm Chen212ca652017-09-28 17:28:45 -07001134 }
Brad Ebinger16417b42017-03-07 13:48:50 -08001135 }
1136
1137 /**
Etan Cohena00c9192014-12-23 15:02:29 -08001138 * Change persistent WFC roaming enabled setting
1139 */
1140 public static void setWfcRoamingSetting(Context context, boolean enabled) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001141 ImsManager mgr = ImsManager.getInstance(context,
Etan Cohena00c9192014-12-23 15:02:29 -08001142 SubscriptionManager.getDefaultVoicePhoneId());
Brad Ebinger479f52c2017-08-28 13:19:22 -07001143 if (mgr != null) {
1144 mgr.setWfcRoamingSetting(enabled);
Etan Cohena00c9192014-12-23 15:02:29 -08001145 }
Brad Ebinger479f52c2017-08-28 13:19:22 -07001146 loge("setWfcRoamingSetting: ImsManager null, value not set.");
Etan Cohena00c9192014-12-23 15:02:29 -08001147 }
1148
1149 /**
Brad Ebinger16417b42017-03-07 13:48:50 -08001150 * Change persistent WFC roaming enabled setting
1151 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001152 public void setWfcRoamingSetting(boolean enabled) {
Malcolm Chen212ca652017-09-28 17:28:45 -07001153 SubscriptionManager.setSubscriptionProperty(getSubId(),
1154 SubscriptionManager.WFC_IMS_ROAMING_ENABLED, booleanToPropertyString(enabled)
1155 );
Brad Ebinger16417b42017-03-07 13:48:50 -08001156
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 Chen212ca652017-09-28 17:28:45 -07001165 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001166 getConfigInterface().setConfig(
Malcolm Chen212ca652017-09-28 17:28:45 -07001167 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_ROAMING, value);
1168 } catch (ImsException e) {
1169 // do nothing
1170 }
Brad Ebinger16417b42017-03-07 13:48:50 -08001171 });
1172 thread.start();
1173 }
1174
1175 /**
Etan Cohena00c9192014-12-23 15:02:29 -08001176 * 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 Ebinger16417b42017-03-07 13:48:50 -08001179 *
Brad Ebinger479f52c2017-08-28 13:19:22 -07001180 * @deprecated Doesn't work for MSIM devices. Use {@link #isWfcEnabledByPlatform()}
Brad Ebinger16417b42017-03-07 13:48:50 -08001181 * instead.
Etan Cohena00c9192014-12-23 15:02:29 -08001182 */
1183 public static boolean isWfcEnabledByPlatform(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001184 ImsManager mgr = ImsManager.getInstance(context,
1185 SubscriptionManager.getDefaultVoicePhoneId());
1186 if (mgr != null) {
1187 return mgr.isWfcEnabledByPlatform();
Etan Cohena00c9192014-12-23 15:02:29 -08001188 }
Brad Ebinger479f52c2017-08-28 13:19:22 -07001189 loge("isWfcEnabledByPlatform: ImsManager null, returning default value.");
1190 return false;
Pavel Zhamaitsiak57911d12015-10-20 14:26:34 -07001191 }
1192
1193 /**
Brad Ebinger16417b42017-03-07 13:48:50 -08001194 * 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 Ebinger479f52c2017-08-28 13:19:22 -07001198 public boolean isWfcEnabledByPlatform() {
Malcolm Chen18837ff2017-10-25 17:05:41 -07001199 // 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 Ebinger16417b42017-03-07 13:48:50 -08001205 return true;
1206 }
1207
1208 return mContext.getResources().getBoolean(
1209 com.android.internal.R.bool.config_device_wfc_ims_available) &&
Brad Ebinger479f52c2017-08-28 13:19:22 -07001210 getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -08001211 CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL) &&
Brad Ebinger479f52c2017-08-28 13:19:22 -07001212 isGbaValid();
Etan Cohena00c9192014-12-23 15:02:29 -08001213 }
1214
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001215 /**
Brad Ebinger16417b42017-03-07 13:48:50 -08001216 * 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 Ebinger479f52c2017-08-28 13:19:22 -07001221 private boolean isGbaValid() {
1222 if (getBooleanCarrierConfig(
Brad Ebinger16417b42017-03-07 13:48:50 -08001223 CarrierConfigManager.KEY_CARRIER_IMS_GBA_REQUIRED_BOOL)) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001224 final TelephonyManager telephonyManager = new TelephonyManager(mContext, getSubId());
Brad Ebinger16417b42017-03-07 13:48:50 -08001225 String efIst = telephonyManager.getIsimIst();
1226 if (efIst == null) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001227 loge("isGbaValid - ISF is NULL");
Brad Ebinger16417b42017-03-07 13:48:50 -08001228 return true;
1229 }
1230 boolean result = efIst != null && efIst.length() > 1 &&
1231 (0x02 & (byte)efIst.charAt(1)) != 0;
Brad Ebinger479f52c2017-08-28 13:19:22 -07001232 if (DBG) log("isGbaValid - GBA capable=" + result + ", ISF=" + efIst);
Brad Ebinger16417b42017-03-07 13:48:50 -08001233 return result;
1234 }
1235 return true;
1236 }
1237
1238 /**
Malcolm Chen18837ff2017-10-25 17:05:41 -07001239 * 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 Zhamaitsiak002b2042016-06-03 16:05:31 -07001247 }
Malcolm Chen18837ff2017-10-25 17:05:41 -07001248 return config.getProvisionedValue(item) == ImsConfig.FeatureValueConstants.ON;
Pavel Zhamaitsiak002b2042016-06-03 16:05:31 -07001249 }
1250
1251 /**
Malcolm Chen18837ff2017-10-25 17:05:41 -07001252 * Will return with config value or return false if we receive an error from
1253 * ImsConfig for that value.
Brad Ebingerbe6cb672017-08-25 14:55:00 -07001254 */
Malcolm Chen18837ff2017-10-25 17:05:41 -07001255 private boolean getProvisionedBoolNoException(int item) {
1256 try {
1257 ImsConfig config = getConfigInterface();
1258 return getProvisionedBool(config, item);
1259 } catch (ImsException ex) {
1260 return false;
Brad Ebingerbe6cb672017-08-25 14:55:00 -07001261 }
1262 }
1263
1264 /**
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001265 * 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 Ebinger16417b42017-03-07 13:48:50 -08001270 *
Brad Ebinger479f52c2017-08-28 13:19:22 -07001271 * @deprecated Doesn't support MSIM devices. Use {@link #updateImsServiceConfig(boolean)}
1272 * instead.
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001273 */
1274 public static void updateImsServiceConfig(Context context, int phoneId, boolean force) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001275 ImsManager mgr = ImsManager.getInstance(context, phoneId);
1276 if (mgr != null) {
1277 mgr.updateImsServiceConfig(force);
Pavel Zhamaitsiakfc202992016-03-29 18:07:38 -07001278 }
Brad Ebinger479f52c2017-08-28 13:19:22 -07001279 loge("updateImsServiceConfig: ImsManager null, returning without update.");
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001280 }
1281
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001282 /**
Brad Ebinger16417b42017-03-07 13:48:50 -08001283 * Sync carrier config and user settings with ImsConfig.
1284 *
Brad Ebinger16417b42017-03-07 13:48:50 -08001285 * @param force update
1286 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001287 public void updateImsServiceConfig(boolean force) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001288 if (!force) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001289 TelephonyManager tm = new TelephonyManager(mContext, getSubId());
1290 if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) {
1291 log("updateImsServiceConfig: SIM not ready");
Brad Ebinger16417b42017-03-07 13:48:50 -08001292 // Don't disable IMS if SIM is not ready
1293 return;
1294 }
1295 }
1296
1297 if (!mConfigUpdated || force) {
1298 try {
Brad Ebinger16417b42017-03-07 13:48:50 -08001299 // 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 Ebinger172977a2018-01-16 09:36:56 -08001302 // changeEnabledCapabilities() function calls from setAdvanced4GMode(). This is done
1303 // to differentiate this code path from vendor code perspective.
Brad Ebinger16417b42017-03-07 13:48:50 -08001304 boolean isImsUsed = updateVolteFeatureValue();
1305 isImsUsed |= updateWfcFeatureAndProvisionedValues();
1306 isImsUsed |= updateVideoCallFeatureValue();
1307
Brad Ebinger479f52c2017-08-28 13:19:22 -07001308 if (isImsUsed || !isTurnOffImsAllowedByPlatform()) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001309 // 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 Ebinger479f52c2017-08-28 13:19:22 -07001313 log("updateImsServiceConfig: turnOnIms");
Brad Ebinger16417b42017-03-07 13:48:50 -08001314 turnOnIms();
1315 } else {
1316 // Turn off IMS if it is not used AND turning off is allowed for carrier.
Brad Ebinger479f52c2017-08-28 13:19:22 -07001317 log("updateImsServiceConfig: turnOffIms");
Brad Ebinger16417b42017-03-07 13:48:50 -08001318 turnOffIms();
1319 }
1320
1321 mConfigUpdated = true;
Brad Ebinger172977a2018-01-16 09:36:56 -08001322 } catch (ImsException | RemoteException e) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001323 loge("updateImsServiceConfig: ", e);
Brad Ebinger16417b42017-03-07 13:48:50 -08001324 mConfigUpdated = false;
1325 }
1326 }
1327 }
1328
1329 /**
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001330 * Update VoLTE config
1331 * @return whether feature is On
1332 * @throws ImsException
1333 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001334 private boolean updateVolteFeatureValue() throws RemoteException {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001335 boolean available = isVolteEnabledByPlatform();
1336 boolean enabled = isEnhanced4gLteModeSettingEnabledByUser();
1337 boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001338 boolean isFeatureOn = available && enabled && isNonTty;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001339
1340 log("updateVolteFeatureValue: available = " + available
1341 + ", enabled = " + enabled
1342 + ", nonTTY = " + isNonTty);
1343
Brad Ebinger172977a2018-01-16 09:36:56 -08001344 changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
1345 ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn);
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001346
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001347 return isFeatureOn;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001348 }
1349
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001350 /**
Jack Yu643ffe42016-07-08 14:25:46 -07001351 * Update video call over LTE config
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001352 * @return whether feature is On
1353 * @throws ImsException
1354 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001355 private boolean updateVideoCallFeatureValue() throws RemoteException {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001356 boolean available = isVtEnabledByPlatform();
1357 boolean enabled = isVtEnabledByUser();
1358 boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
Amit Mahajan24f7b162016-07-21 16:33:53 -07001359 boolean isDataEnabled = isDataEnabled();
Brad Ebinger479f52c2017-08-28 13:19:22 -07001360 boolean ignoreDataEnabledChanged = getBooleanCarrierConfig(
Jack Yu57781852016-11-16 17:20:38 -08001361 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS);
Jack Yu643ffe42016-07-08 14:25:46 -07001362
Jack Yu57781852016-11-16 17:20:38 -08001363 boolean isFeatureOn = available && enabled && isNonTty
1364 && (ignoreDataEnabledChanged || isDataEnabled);
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001365
1366 log("updateVideoCallFeatureValue: available = " + available
1367 + ", enabled = " + enabled
Jack Yu643ffe42016-07-08 14:25:46 -07001368 + ", nonTTY = " + isNonTty
Amit Mahajan24f7b162016-07-21 16:33:53 -07001369 + ", data enabled = " + isDataEnabled);
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001370
Brad Ebinger172977a2018-01-16 09:36:56 -08001371 changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
1372 ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn);
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001373
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001374 return isFeatureOn;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001375 }
1376
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001377 /**
1378 * Update WFC config
1379 * @return whether feature is On
1380 * @throws ImsException
1381 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001382 private boolean updateWfcFeatureAndProvisionedValues() throws RemoteException {
Brad Ebinger479f52c2017-08-28 13:19:22 -07001383 TelephonyManager tm = new TelephonyManager(mContext, getSubId());
1384 boolean isNetworkRoaming = tm.isNetworkRoaming();
1385 boolean available = isWfcEnabledByPlatform();
1386 boolean enabled = isWfcEnabledByUser();
Suresh Koleti76491082017-04-21 18:39:50 +05301387 updateDefaultWfcMode();
Brad Ebinger479f52c2017-08-28 13:19:22 -07001388 int mode = getWfcMode(isNetworkRoaming);
1389 boolean roaming = isWfcRoamingEnabledByUser();
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001390 boolean isFeatureOn = available && enabled;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001391
1392 log("updateWfcFeatureAndProvisionedValues: available = " + available
1393 + ", enabled = " + enabled
1394 + ", mode = " + mode
1395 + ", roaming = " + roaming);
1396
Brad Ebinger172977a2018-01-16 09:36:56 -08001397 changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
1398 ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, isFeatureOn);
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001399
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001400 if (!isFeatureOn) {
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001401 mode = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
1402 roaming = false;
1403 }
1404 setWfcModeInternal(mContext, mode);
Brad Ebinger16417b42017-03-07 13:48:50 -08001405 setWfcRoamingSettingInternal(roaming);
Pavel Zhamaitsiakdc16e452015-09-08 17:12:06 -07001406
Pavel Zhamaitsiak9510b1c2015-12-18 11:30:49 -08001407 return isFeatureOn;
Pavel Zhamaitsiak8ca52ff2015-09-04 17:08:35 -07001408 }
1409
Brad Ebinger16780ff2017-01-26 11:18:21 -08001410 /**
Brad Ebinger479f52c2017-08-28 13:19:22 -07001411 * Do NOT use this directly, instead use {@link #getInstance(Context, int)}.
Brad Ebinger16780ff2017-01-26 11:18:21 -08001412 */
1413 @VisibleForTesting
1414 public ImsManager(Context context, int phoneId) {
Wink Savilleef36ef62014-06-11 08:39:38 -07001415 mContext = context;
Etan Cohenabbd7882014-09-26 22:35:35 -07001416 mPhoneId = phoneId;
Brad Ebinger16780ff2017-01-26 11:18:21 -08001417 mConfigDynamicBind = mContext.getResources().getBoolean(
1418 com.android.internal.R.bool.config_dynamic_bind_ims);
Brad Ebinger16417b42017-03-07 13:48:50 -08001419 mConfigManager = (CarrierConfigManager) context.getSystemService(
1420 Context.CARRIER_CONFIG_SERVICE);
Brad Ebinger16780ff2017-01-26 11:18:21 -08001421 createImsService();
1422 }
1423
1424 /**
Brad Ebinger16780ff2017-01-26 11:18:21 -08001425 * @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 Savilleef36ef62014-06-11 08:39:38 -07001430 }
1431
Etan Cohenf4311122015-02-26 17:47:13 -08001432 /*
Brad Ebinger0aed76d2018-03-05 16:39:02 -08001433 * 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 Cohenf4311122015-02-26 17:47:13 -08001435 */
1436 public boolean isServiceAvailable() {
Brad Ebinger0aed76d2018-03-05 16:39:02 -08001437 // 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 Ebingerff097922017-06-19 15:43:08 -07001445 connectIfServiceIsAvailable();
Brad Ebinger16780ff2017-01-26 11:18:21 -08001446 // mImsServiceProxy will always create an ImsServiceProxy.
Brad Ebinger172977a2018-01-16 09:36:56 -08001447 return mMmTelFeatureConnection.isBinderAlive();
Etan Cohenf4311122015-02-26 17:47:13 -08001448 }
1449
Suresh Koleticc3139c2017-11-03 18:23:57 +05301450 /*
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 Ebinger172977a2018-01-16 09:36:56 -08001455 return mMmTelFeatureConnection.isBinderReady();
Suresh Koleticc3139c2017-11-03 18:23:57 +05301456 }
1457
Brad Ebingerff097922017-06-19 15:43:08 -07001458 /**
1459 * If the service is available, try to reconnect.
1460 */
1461 public void connectIfServiceIsAvailable() {
Brad Ebinger172977a2018-01-16 09:36:56 -08001462 if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) {
Brad Ebingerff097922017-06-19 15:43:08 -07001463 createImsService();
1464 }
1465 }
1466
Brad Ebinger172977a2018-01-16 09:36:56 -08001467 public void setConfigListener(ImsConfigListener listener) {
Pavel Zhamaitsiakf4b90322016-01-26 14:34:09 -08001468 mImsConfigListener = listener;
1469 }
1470
Brad Ebingerb10b61e2017-04-18 11:45:26 -07001471
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 Ebinger6ddf28e2018-02-21 16:07:23 -08001476 @VisibleForTesting
Brad Ebinger172977a2018-01-16 09:36:56 -08001477 public void addNotifyStatusChangedCallbackIfAvailable(MmTelFeatureConnection.IFeatureUpdate c)
Brad Ebingerb10b61e2017-04-18 11:45:26 -07001478 throws ImsException {
Brad Ebinger172977a2018-01-16 09:36:56 -08001479 if (!mMmTelFeatureConnection.isBinderAlive()) {
Brad Ebingerb10b61e2017-04-18 11:45:26 -07001480 throw new ImsException("Binder is not active!",
1481 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
1482 }
Brad Ebinger16780ff2017-01-26 11:18:21 -08001483 if (c != null) {
1484 mStatusCallbacks.add(c);
1485 }
1486 }
1487
Brad Ebinger6ddf28e2018-02-21 16:07:23 -08001488 void removeNotifyStatusChangedCallback(MmTelFeatureConnection.IFeatureUpdate c) {
Brad Ebinger44fd8af2017-12-14 14:24:02 -08001489 if (c != null) {
1490 mStatusCallbacks.remove(c);
1491 } else {
1492 Log.w(TAG, "removeNotifyStatusChangedCallback: callback is null!");
1493 }
1494 }
1495
Wink Savilleef36ef62014-06-11 08:39:38 -07001496 /**
1497 * Opens the IMS service for making calls and/or receiving generic IMS calls.
Brad Ebinger172977a2018-01-16 09:36:56 -08001498 * The caller may make subsequent calls through {@link #makeCall}.
Wink Savilleef36ef62014-06-11 08:39:38 -07001499 * 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 Ebinger172977a2018-01-16 09:36:56 -08001501 * 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 Savilleef36ef62014-06-11 08:39:38 -07001507 * @throws ImsException if calling the IMS service results in an error
1508 * @see #getCallId
Wink Savilleef36ef62014-06-11 08:39:38 -07001509 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001510 public void open(MmTelFeature.Listener listener) throws ImsException {
Wink Savilleef36ef62014-06-11 08:39:38 -07001511 checkAndThrowExceptionIfServiceUnavailable();
1512
Wink Savilleef36ef62014-06-11 08:39:38 -07001513 if (listener == null) {
1514 throw new NullPointerException("listener can't be null");
1515 }
1516
Wink Savilleef36ef62014-06-11 08:39:38 -07001517 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001518 mMmTelFeatureConnection.openConnection(listener);
Wink Savilleef36ef62014-06-11 08:39:38 -07001519 } catch (RemoteException e) {
Brad Ebinger172977a2018-01-16 09:36:56 -08001520 throw new ImsException("open()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
Wink Savilleef36ef62014-06-11 08:39:38 -07001521 }
Wink Savilleef36ef62014-06-11 08:39:38 -07001522 }
1523
1524 /**
Pavel Zhamaitsiakce410172016-04-15 10:55:56 -07001525 * 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 Ebinger9a0280c2017-06-01 15:58:48 -07001532 *
1533 * @deprecated Use {@link #addRegistrationListener(ImsConnectionStateListener)} instead.
Pavel Zhamaitsiakce410172016-04-15 10:55:56 -07001534 */
1535 public void addRegistrationListener(int serviceClass, ImsConnectionStateListener listener)
1536 throws ImsException {
Brad Ebinger9a0280c2017-06-01 15:58:48 -07001537 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 Ebinger172977a2018-01-16 09:36:56 -08001546 * @deprecated use {@link #addRegistrationCallback(ImsRegistrationImplBase.Callback)} and
1547 * {@link #addCapabilitiesCallback(ImsFeature.CapabilityCallback)} instead.
Brad Ebinger9a0280c2017-06-01 15:58:48 -07001548 */
Brad Ebinger44fd8af2017-12-14 14:24:02 -08001549 public void addRegistrationListener(ImsConnectionStateListener listener) throws ImsException {
Pavel Zhamaitsiakce410172016-04-15 10:55:56 -07001550 if (listener == null) {
1551 throw new NullPointerException("listener can't be null");
1552 }
Brad Ebinger172977a2018-01-16 09:36:56 -08001553 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 Ebinger9a0280c2017-06-01 15:58:48 -07001559 }
Brad Ebinger172977a2018-01-16 09:36:56 -08001560 });
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 Ebinger9a0280c2017-06-01 15:58:48 -07001574 }
Brad Ebinger172977a2018-01-16 09:36:56 -08001575
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 Zhamaitsiakce410172016-04-15 10:55:56 -07001608 }
1609 }
1610
1611 /**
Brad Ebinger16780ff2017-01-26 11:18:21 -08001612 * Removes the registration listener from the IMS service.
1613 *
Brad Ebinger16780ff2017-01-26 11:18:21 -08001614 * @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 Ebingerb5f30c72017-02-17 14:54:31 -08001619 public void removeRegistrationListener(ImsConnectionStateListener listener)
Brad Ebinger16780ff2017-01-26 11:18:21 -08001620 throws ImsException {
Brad Ebinger16780ff2017-01-26 11:18:21 -08001621 if (listener == null) {
1622 throw new NullPointerException("listener can't be null");
1623 }
1624
Brad Ebinger172977a2018-01-16 09:36:56 -08001625 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 Ebinger16780ff2017-01-26 11:18:21 -08001642 }
1643 }
1644
1645 /**
Brad Ebinger172977a2018-01-16 09:36:56 -08001646 * Closes the connection and removes all active callbacks.
Wink Savilleef36ef62014-06-11 08:39:38 -07001647 * All the resources that were allocated to the service are also released.
Wink Savilleef36ef62014-06-11 08:39:38 -07001648 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001649 public void close() {
1650 if (mMmTelFeatureConnection != null) {
1651 mMmTelFeatureConnection.closeConnection();
Wink Savilleef36ef62014-06-11 08:39:38 -07001652 }
Brad Ebinger172977a2018-01-16 09:36:56 -08001653 mUt = null;
1654 mConfig = null;
1655 mEcbm = null;
1656 mMultiEndpoint = null;
Wink Savilleef36ef62014-06-11 08:39:38 -07001657 }
1658
1659 /**
1660 * Gets the configuration interface to provision / withdraw the supplementary service settings.
1661 *
Wink Savilleef36ef62014-06-11 08:39:38 -07001662 * @return the Ut interface instance
1663 * @throws ImsException if getting the Ut interface results in an error
1664 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001665 public ImsUtInterface getSupplementaryServiceConfiguration() throws ImsException {
Brad Ebinger16780ff2017-01-26 11:18:21 -08001666 // FIXME: manage the multiple Ut interfaces based on the session id
Brad Ebinger138b4a62017-06-20 16:29:50 -07001667 if (mUt != null && mUt.isBinderAlive()) {
1668 return mUt;
Wink Savilleef36ef62014-06-11 08:39:38 -07001669 }
1670
Brad Ebinger138b4a62017-06-20 16:29:50 -07001671 checkAndThrowExceptionIfServiceUnavailable();
1672 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001673 IImsUt iUt = mMmTelFeatureConnection.getUtInterface();
Brad Ebinger138b4a62017-06-20 16:29:50 -07001674
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 Savilleef36ef62014-06-11 08:39:38 -07001685 return mUt;
1686 }
1687
1688 /**
Wink Savilleef36ef62014-06-11 08:39:38 -07001689 * Creates a {@link ImsCallProfile} from the service capabilities & IMS registration state.
1690 *
Wink Savilleef36ef62014-06-11 08:39:38 -07001691 * @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 Ebinger172977a2018-01-16 09:36:56 -08001707 public ImsCallProfile createCallProfile(int serviceType, int callType) throws ImsException {
Wink Savilleef36ef62014-06-11 08:39:38 -07001708 checkAndThrowExceptionIfServiceUnavailable();
1709
1710 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001711 return mMmTelFeatureConnection.createCallProfile(serviceType, callType);
Wink Savilleef36ef62014-06-11 08:39:38 -07001712 } 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 Savilleef36ef62014-06-11 08:39:38 -07001721 * @param profile a call profile to make the call
1722 * (it contains service type, call type, media information, etc.)
Brad Ebinger172977a2018-01-16 09:36:56 -08001723 * @param callees participants to invite the conference call
Wink Savilleef36ef62014-06-11 08:39:38 -07001724 * @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 Ebinger172977a2018-01-16 09:36:56 -08001728 public ImsCall makeCall(ImsCallProfile profile, String[] callees,
Wink Savilleef36ef62014-06-11 08:39:38 -07001729 ImsCall.Listener listener) throws ImsException {
1730 if (DBG) {
Brad Ebinger172977a2018-01-16 09:36:56 -08001731 log("makeCall :: profile=" + profile);
Wink Savilleef36ef62014-06-11 08:39:38 -07001732 }
1733
1734 checkAndThrowExceptionIfServiceUnavailable();
1735
1736 ImsCall call = new ImsCall(mContext, profile);
1737
1738 call.setListener(listener);
Brad Ebinger172977a2018-01-16 09:36:56 -08001739 ImsCallSession session = createCallSession(profile);
Wink Savilleef36ef62014-06-11 08:39:38 -07001740
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 Ebinger16780ff2017-01-26 11:18:21 -08001753 * @param sessionId a session id which is obtained from {@link ImsManager#open}
Brad Ebinger172977a2018-01-16 09:36:56 -08001754 * @param incomingCallExtras the incoming call broadcast intent
Wink Savilleef36ef62014-06-11 08:39:38 -07001755 * @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 Ebinger172977a2018-01-16 09:36:56 -08001759 public ImsCall takeCall(IImsCallSession session, Bundle incomingCallExtras,
Wink Savilleef36ef62014-06-11 08:39:38 -07001760 ImsCall.Listener listener) throws ImsException {
1761 if (DBG) {
Brad Ebinger172977a2018-01-16 09:36:56 -08001762 log("takeCall :: incomingCall=" + incomingCallExtras);
Wink Savilleef36ef62014-06-11 08:39:38 -07001763 }
1764
1765 checkAndThrowExceptionIfServiceUnavailable();
1766
Brad Ebinger172977a2018-01-16 09:36:56 -08001767 if (incomingCallExtras == null) {
Wink Savilleef36ef62014-06-11 08:39:38 -07001768 throw new ImsException("Can't retrieve session with null intent",
1769 ImsReasonInfo.CODE_LOCAL_ILLEGAL_ARGUMENT);
1770 }
1771
Brad Ebinger172977a2018-01-16 09:36:56 -08001772 String callId = getCallId(incomingCallExtras);
Wink Savilleef36ef62014-06-11 08:39:38 -07001773
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 Savilleef36ef62014-06-11 08:39:38 -07001780 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.com076c55d2014-06-23 19:46:36 -05001797 * 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 Ebinger138b4a62017-06-20 16:29:50 -07001803 if (mConfig != null && mConfig.isBinderAlive()) {
1804 return mConfig;
Libin.Tang@motorola.com076c55d2014-06-23 19:46:36 -05001805 }
Brad Ebinger138b4a62017-06-20 16:29:50 -07001806
1807 checkAndThrowExceptionIfServiceUnavailable();
1808 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001809 IImsConfig config = mMmTelFeatureConnection.getConfigInterface();
Brad Ebinger138b4a62017-06-20 16:29:50 -07001810 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.com076c55d2014-06-23 19:46:36 -05001819 return mConfig;
1820 }
1821
Brad Ebinger172977a2018-01-16 09:36:56 -08001822 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 Liub77d8972018-01-22 19:15:05 -08001841 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 Liue511a202017-08-17 15:49:58 -07001863 /**
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 Ebinger479f52c2017-08-28 13:19:22 -07001867 if (!getBooleanCarrierConfig(
Hall Liue511a202017-08-17 15:49:58 -07001868 CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) {
1869 setAdvanced4GMode((ttyMode == TelecomManager.TTY_MODE_OFF) &&
Brad Ebinger479f52c2017-08-28 13:19:22 -07001870 isEnhanced4gLteModeSettingEnabledByUser());
Hall Liue511a202017-08-17 15:49:58 -07001871 }
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 Ebingerb5f30c72017-02-17 14:54:31 -08001878 public void setUiTTYMode(Context context, int uiTtyMode, Message onComplete)
Shriram Ganeshc403b7b2014-08-14 14:18:57 +05301879 throws ImsException {
1880
Etan Cohen82f78122014-12-15 10:10:14 -08001881 checkAndThrowExceptionIfServiceUnavailable();
Shriram Ganeshc403b7b2014-08-14 14:18:57 +05301882
Etan Cohen82f78122014-12-15 10:10:14 -08001883 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08001884 mMmTelFeatureConnection.setUiTTYMode(uiTtyMode, onComplete);
Etan Cohen82f78122014-12-15 10:10:14 -08001885 } catch (RemoteException e) {
1886 throw new ImsException("setTTYMode()", e,
1887 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
1888 }
Shriram Ganeshc403b7b2014-08-14 14:18:57 +05301889 }
1890
Naveen Kalla525c3a22017-02-06 14:46:42 -08001891 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 Ebinger16417b42017-03-07 13:48:50 -08001915
Brad Ebinger172977a2018-01-16 09:36:56 -08001916 public int getImsServiceState() throws ImsException {
1917 return mMmTelFeatureConnection.getFeatureState();
Brad Ebinger16780ff2017-01-26 11:18:21 -08001918 }
Naveen Kalla525c3a22017-02-06 14:46:42 -08001919
Libin.Tang@motorola.com076c55d2014-06-23 19:46:36 -05001920 /**
Junda Liue7663c02015-06-23 11:16:26 -07001921 * Get the boolean config from carrier config manager.
1922 *
Brad Ebinger16417b42017-03-07 13:48:50 -08001923 * @param key config key defined in CarrierConfigManager
1924 * @return boolean value of corresponding key.
1925 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001926 private boolean getBooleanCarrierConfig(String key) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001927 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 /**
fionaxu5803ef02016-03-08 11:48:48 -08001946 * Get the int config from carrier config manager.
1947 *
Brad Ebinger16417b42017-03-07 13:48:50 -08001948 * @param key config key defined in CarrierConfigManager
1949 * @return integer value of corresponding key.
1950 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07001951 private int getIntCarrierConfig(String key) {
Brad Ebinger16417b42017-03-07 13:48:50 -08001952 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 Savilleef36ef62014-06-11 08:39:38 -07001971 * Gets the call ID from the specified incoming call broadcast intent.
1972 *
Brad Ebinger172977a2018-01-16 09:36:56 -08001973 * @param incomingCallExtras the incoming call broadcast intent
Wink Savilleef36ef62014-06-11 08:39:38 -07001974 * @return the call ID or null if the intent does not contain it
1975 */
Brad Ebinger172977a2018-01-16 09:36:56 -08001976 private static String getCallId(Bundle incomingCallExtras) {
1977 if (incomingCallExtras == null) {
Wink Savilleef36ef62014-06-11 08:39:38 -07001978 return null;
1979 }
1980
Brad Ebinger172977a2018-01-16 09:36:56 -08001981 return incomingCallExtras.getString(EXTRA_CALL_ID);
Wink Savilleef36ef62014-06-11 08:39:38 -07001982 }
1983
1984 /**
Brad Ebingerb10b61e2017-04-18 11:45:26 -07001985 * Checks to see if the ImsService Binder is connected. If it is not, we try to create the
1986 * connection again.
Wink Savilleef36ef62014-06-11 08:39:38 -07001987 */
1988 private void checkAndThrowExceptionIfServiceUnavailable()
1989 throws ImsException {
Brad Ebinger172977a2018-01-16 09:36:56 -08001990 if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) {
Brad Ebinger16780ff2017-01-26 11:18:21 -08001991 createImsService();
Wink Savilleef36ef62014-06-11 08:39:38 -07001992
Brad Ebinger172977a2018-01-16 09:36:56 -08001993 if (mMmTelFeatureConnection == null) {
Wink Savilleef36ef62014-06-11 08:39:38 -07001994 throw new ImsException("Service is unavailable",
1995 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
1996 }
1997 }
1998 }
1999
Brad Ebinger16780ff2017-01-26 11:18:21 -08002000 /**
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 Ebinger172977a2018-01-16 09:36:56 -08002007 Rlog.i(TAG, "Creating ImsService");
2008 mMmTelFeatureConnection = MmTelFeatureConnection.create(mContext, mPhoneId);
2009
Brad Ebinger44fd8af2017-12-14 14:24:02 -08002010 // Forwarding interface to tell mStatusCallbacks that the Proxy is unavailable.
Brad Ebinger172977a2018-01-16 09:36:56 -08002011 mMmTelFeatureConnection.setStatusCallback(new MmTelFeatureConnection.IFeatureUpdate() {
Brad Ebinger44fd8af2017-12-14 14:24:02 -08002012 @Override
2013 public void notifyStateChanged() {
Brad Ebinger172977a2018-01-16 09:36:56 -08002014 mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyStateChanged);
Brad Ebinger44fd8af2017-12-14 14:24:02 -08002015 }
2016
2017 @Override
2018 public void notifyUnavailable() {
Brad Ebinger172977a2018-01-16 09:36:56 -08002019 mStatusCallbacks.forEach(MmTelFeatureConnection.IFeatureUpdate::notifyUnavailable);
Brad Ebinger44fd8af2017-12-14 14:24:02 -08002020 }
2021 });
Etan Cohend7727462014-07-12 14:54:10 -07002022 }
2023
Wink Savilleef36ef62014-06-11 08:39:38 -07002024 /**
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 Savilleef36ef62014-06-11 08:39:38 -07002029 * @param profile a call profile to make the call
2030 */
Brad Ebinger172977a2018-01-16 09:36:56 -08002031 private ImsCallSession createCallSession(ImsCallProfile profile) throws ImsException {
Wink Savilleef36ef62014-06-11 08:39:38 -07002032 try {
Brad Ebingerb10b61e2017-04-18 11:45:26 -07002033 // Throws an exception if the ImsService Feature is not ready to accept commands.
Brad Ebinger172977a2018-01-16 09:36:56 -08002034 return new ImsCallSession(mMmTelFeatureConnection.createCallSession(profile));
Wink Savilleef36ef62014-06-11 08:39:38 -07002035 } catch (RemoteException e) {
Brad Ebingerb10b61e2017-04-18 11:45:26 -07002036 Rlog.w(TAG, "CreateCallSession: Error, remote exception: " + e.getMessage());
2037 throw new ImsException("createCallSession()", e,
2038 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
2039
Wink Savilleef36ef62014-06-11 08:39:38 -07002040 }
2041 }
2042
Etan Cohena00c9192014-12-23 15:02:29 -08002043 private static void log(String s) {
Wink Savilleef36ef62014-06-11 08:39:38 -07002044 Rlog.d(TAG, s);
2045 }
2046
Etan Cohena00c9192014-12-23 15:02:29 -08002047 private static void loge(String s) {
Wink Savilleef36ef62014-06-11 08:39:38 -07002048 Rlog.e(TAG, s);
2049 }
2050
Etan Cohena00c9192014-12-23 15:02:29 -08002051 private static void loge(String s, Throwable t) {
Wink Savilleef36ef62014-06-11 08:39:38 -07002052 Rlog.e(TAG, s, t);
2053 }
2054
2055 /**
ram7da5a112014-07-16 20:59:27 +05302056 * Used for turning on IMS.if its off already
2057 */
Etan Cohen82f78122014-12-15 10:10:14 -08002058 private void turnOnIms() throws ImsException {
Brad Ebinger172977a2018-01-16 09:36:56 -08002059 TelephonyManager tm = (TelephonyManager)
2060 mContext.getSystemService(Context.TELEPHONY_SERVICE);
2061 tm.enableIms(mPhoneId);
ram7da5a112014-07-16 20:59:27 +05302062 }
2063
Omkar Kolangade75f3ca32014-10-24 11:10:52 -07002064 private boolean isImsTurnOffAllowed() {
Brad Ebinger479f52c2017-08-28 13:19:22 -07002065 return isTurnOffImsAllowedByPlatform()
2066 && (!isWfcEnabledByPlatform()
2067 || !isWfcEnabledByUser());
Omkar Kolangade75f3ca32014-10-24 11:10:52 -07002068 }
2069
Amit Mahajan9cba36d2016-08-11 10:17:23 -07002070 private void setLteFeatureValues(boolean turnOn) {
2071 log("setLteFeatureValues: " + turnOn);
Brad Ebinger172977a2018-01-16 09:36:56 -08002072 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 Zhamaitsiakff29b9d2016-04-15 12:16:57 -07002082
Brad Ebinger172977a2018-01-16 09:36:56 -08002083 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 Cohenb651fa52014-10-22 10:51:29 -07002096 }
Brad Ebinger172977a2018-01-16 09:36:56 -08002097 }
2098 try {
2099 mMmTelFeatureConnection.changeEnabledCapabilities(request, null);
2100 } catch (RemoteException e) {
2101 Log.e(TAG, "setLteFeatureValues: Exception: " + e.getMessage());
Etan Cohencfc784d2014-08-07 18:40:31 -07002102 }
Amit Mahajan9cba36d2016-08-11 10:17:23 -07002103 }
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 Cohencfc784d2014-08-07 18:40:31 -07002111 if (turnOn) {
Amit Mahajan9cba36d2016-08-11 10:17:23 -07002112 setLteFeatureValues(turnOn);
2113 log("setAdvanced4GMode: turnOnIms");
Etan Cohencfc784d2014-08-07 18:40:31 -07002114 turnOnIms();
Amit Mahajan9cba36d2016-08-11 10:17:23 -07002115 } else {
2116 if (isImsTurnOffAllowed()) {
2117 log("setAdvanced4GMode: turnOffIms");
2118 turnOffIms();
2119 }
2120 setLteFeatureValues(turnOn);
Etan Cohencfc784d2014-08-07 18:40:31 -07002121 }
2122 }
2123
ram7da5a112014-07-16 20:59:27 +05302124 /**
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 Cohen82f78122014-12-15 10:10:14 -08002128 private void turnOffIms() throws ImsException {
Brad Ebinger172977a2018-01-16 09:36:56 -08002129 TelephonyManager tm = (TelephonyManager)
2130 mContext.getSystemService(Context.TELEPHONY_SERVICE);
2131 tm.disableIms(mPhoneId);
ram7da5a112014-07-16 20:59:27 +05302132 }
2133
Naveen Kalla525c3a22017-02-06 14:46:42 -08002134 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
ram7da5a112014-07-16 20:59:27 +05302142 /**
Wink Savilleef36ef62014-06-11 08:39:38 -07002143 * Death recipient class for monitoring IMS service.
2144 */
2145 private class ImsServiceDeathRecipient implements IBinder.DeathRecipient {
2146 @Override
2147 public void binderDied() {
Brad Ebinger172977a2018-01-16 09:36:56 -08002148 mMmTelFeatureConnection = null;
Wink Savilleef36ef62014-06-11 08:39:38 -07002149 mUt = null;
Libin.Tang@motorola.com076c55d2014-06-23 19:46:36 -05002150 mConfig = null;
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002151 mEcbm = null;
Tyler Gunn4d128b62016-04-13 15:44:38 -07002152 mMultiEndpoint = null;
Wink Savilleef36ef62014-06-11 08:39:38 -07002153 }
2154 }
2155
2156 /**
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002157 * Gets the ECBM interface to request ECBM exit.
2158 *
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002159 * @return the ECBM interface instance
2160 * @throws ImsException if getting the ECBM interface results in an error
2161 */
Brad Ebinger172977a2018-01-16 09:36:56 -08002162 public ImsEcbm getEcbmInterface() throws ImsException {
Brad Ebinger138b4a62017-06-20 16:29:50 -07002163 if (mEcbm != null && mEcbm.isBinderAlive()) {
2164 return mEcbm;
2165 }
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002166
Brad Ebinger138b4a62017-06-20 16:29:50 -07002167 checkAndThrowExceptionIfServiceUnavailable();
2168 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08002169 IImsEcbm iEcbm = mMmTelFeatureConnection.getEcbmInterface();
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002170
Brad Ebinger138b4a62017-06-20 16:29:50 -07002171 if (iEcbm == null) {
2172 throw new ImsException("getEcbmInterface()",
2173 ImsReasonInfo.CODE_ECBM_NOT_SUPPORTED);
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002174 }
Brad Ebinger138b4a62017-06-20 16:29:50 -07002175 mEcbm = new ImsEcbm(iEcbm);
2176 } catch (RemoteException e) {
2177 throw new ImsException("getEcbmInterface()", e,
2178 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
Uma Maheswari Ramalingam4f2161d2014-07-31 16:01:47 -07002179 }
2180 return mEcbm;
2181 }
Pavel Zhamaitsiak8c065f52015-11-10 14:36:44 -08002182
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002183 public void sendSms(int token, int messageRef, String format, String smsc, boolean isRetry,
2184 byte[] pdu) throws ImsException {
2185 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08002186 mMmTelFeatureConnection.sendSms(token, messageRef, format, smsc, isRetry, pdu);
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002187 } 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 Ebinger172977a2018-01-16 09:36:56 -08002194 mMmTelFeatureConnection.acknowledgeSms(token, messageRef, result);
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002195 } 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 Ebinger172977a2018-01-16 09:36:56 -08002203 mMmTelFeatureConnection.acknowledgeSmsReport(token, messageRef, result);
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002204 } 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 Ebinger172977a2018-01-16 09:36:56 -08002212 return mMmTelFeatureConnection.getSmsFormat();
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002213 } 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 Ebinger172977a2018-01-16 09:36:56 -08002221 mMmTelFeatureConnection.setSmsListener(listener);
Mohamed Abdalkader4d68a982018-01-10 13:29:26 -08002222 } catch (RemoteException e) {
2223 throw new ImsException("setSmsListener()", e,
2224 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
2225 }
2226 }
Mohamed Abdalkadere1453f42018-01-19 19:48:31 -08002227
Brad Ebingerd449b232018-02-12 14:33:05 -08002228 public void onSmsReady() throws ImsException {
Mohamed Abdalkader0e734e12018-01-23 13:11:00 -08002229 try {
Brad Ebinger190ed932018-01-23 13:41:32 -08002230 mMmTelFeatureConnection.onSmsReady();
Mohamed Abdalkader0e734e12018-01-23 13:11:00 -08002231 } catch (RemoteException e) {
2232 throw new ImsException("onSmsReady()", e,
2233 ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
2234 }
2235 }
2236
Pavel Zhamaitsiak8c065f52015-11-10 14:36:44 -08002237 /**
Brad Ebingerd449b232018-02-12 14:33:05 -08002238 * 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 Gunn4d128b62016-04-13 15:44:38 -07002260 * Gets the Multi-Endpoint interface to subscribe to multi-enpoint notifications..
2261 *
Tyler Gunn4d128b62016-04-13 15:44:38 -07002262 * @return the multi-endpoint interface instance
2263 * @throws ImsException if getting the multi-endpoint interface results in an error
2264 */
Brad Ebinger172977a2018-01-16 09:36:56 -08002265 public ImsMultiEndpoint getMultiEndpointInterface() throws ImsException {
Brad Ebinger138b4a62017-06-20 16:29:50 -07002266 if (mMultiEndpoint != null && mMultiEndpoint.isBinderAlive()) {
2267 return mMultiEndpoint;
Tyler Gunn4d128b62016-04-13 15:44:38 -07002268 }
Brad Ebinger138b4a62017-06-20 16:29:50 -07002269
2270 checkAndThrowExceptionIfServiceUnavailable();
2271 try {
Brad Ebinger172977a2018-01-16 09:36:56 -08002272 IImsMultiEndpoint iImsMultiEndpoint = mMmTelFeatureConnection.getMultiEndpointInterface();
Brad Ebinger138b4a62017-06-20 16:29:50 -07002273
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 Gunn4d128b62016-04-13 15:44:38 -07002284 return mMultiEndpoint;
2285 }
2286
2287 /**
Pavel Zhamaitsiak8c065f52015-11-10 14:36:44 -08002288 * Resets ImsManager settings back to factory defaults.
2289 *
Brad Ebinger479f52c2017-08-28 13:19:22 -07002290 * @deprecated Doesn't support MSIM devices. Use {@link #factoryReset()} instead.
Brad Ebinger16417b42017-03-07 13:48:50 -08002291 *
Pavel Zhamaitsiak8c065f52015-11-10 14:36:44 -08002292 * @hide
2293 */
2294 public static void factoryReset(Context context) {
Brad Ebinger479f52c2017-08-28 13:19:22 -07002295 ImsManager mgr = ImsManager.getInstance(context,
2296 SubscriptionManager.getDefaultVoicePhoneId());
2297 if (mgr != null) {
2298 mgr.factoryReset();
2299 }
2300 loge("factoryReset: ImsManager null.");
Pavel Zhamaitsiak8c065f52015-11-10 14:36:44 -08002301 }
Jack Yu2f102bd2015-12-28 15:31:48 -08002302
Brad Ebinger16417b42017-03-07 13:48:50 -08002303 /**
2304 * Resets ImsManager settings back to factory defaults.
2305 *
2306 * @hide
2307 */
Brad Ebinger479f52c2017-08-28 13:19:22 -07002308 public void factoryReset() {
Brad Ebinger16417b42017-03-07 13:48:50 -08002309 // Set VoLTE to default
Malcolm Chen212ca652017-09-28 17:28:45 -07002310 SubscriptionManager.setSubscriptionProperty(getSubId(),
manabu, shimoda96aee542017-10-06 15:39:36 +09002311 SubscriptionManager.ENHANCED_4G_MODE_ENABLED,
2312 booleanToPropertyString(getBooleanCarrierConfig(
2313 CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL)));
Brad Ebinger16417b42017-03-07 13:48:50 -08002314
2315 // Set VoWiFi to default
Malcolm Chen212ca652017-09-28 17:28:45 -07002316 SubscriptionManager.setSubscriptionProperty(getSubId(),
2317 SubscriptionManager.WFC_IMS_ENABLED,
2318 booleanToPropertyString(getBooleanCarrierConfig(
2319 CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL)));
Brad Ebinger16417b42017-03-07 13:48:50 -08002320
2321 // Set VoWiFi mode to default
Malcolm Chen212ca652017-09-28 17:28:45 -07002322 SubscriptionManager.setSubscriptionProperty(getSubId(),
2323 SubscriptionManager.WFC_IMS_MODE,
2324 Integer.toString(getIntCarrierConfig(
2325 CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT)));
Brad Ebinger16417b42017-03-07 13:48:50 -08002326
2327 // Set VoWiFi roaming to default
Malcolm Chen212ca652017-09-28 17:28:45 -07002328 SubscriptionManager.setSubscriptionProperty(getSubId(),
2329 SubscriptionManager.WFC_IMS_ROAMING_ENABLED,
2330 booleanToPropertyString(getBooleanCarrierConfig(
2331 CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL)));
Brad Ebinger16417b42017-03-07 13:48:50 -08002332
2333 // Set VT to default
Malcolm Chen212ca652017-09-28 17:28:45 -07002334 SubscriptionManager.setSubscriptionProperty(getSubId(),
2335 SubscriptionManager.VT_IMS_ENABLED, booleanToPropertyString(true));
Brad Ebinger16417b42017-03-07 13:48:50 -08002336
2337 // Push settings to ImsConfig
Brad Ebinger479f52c2017-08-28 13:19:22 -07002338 updateImsServiceConfig(true);
Brad Ebinger16417b42017-03-07 13:48:50 -08002339 }
2340
Amit Mahajan24f7b162016-07-21 16:33:53 -07002341 private boolean isDataEnabled() {
Malcolm Chend0ef12c2017-12-20 11:38:25 -08002342 return new TelephonyManager(mContext, getSubId()).isMobileDataEnabled();
Amit Mahajan24f7b162016-07-21 16:33:53 -07002343 }
2344
2345 private boolean isVolteProvisioned() {
Malcolm Chen18837ff2017-10-25 17:05:41 -07002346 return getProvisionedBoolNoException(
2347 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED);
Amit Mahajan24f7b162016-07-21 16:33:53 -07002348 }
2349
2350 private boolean isWfcProvisioned() {
Malcolm Chen18837ff2017-10-25 17:05:41 -07002351 return getProvisionedBoolNoException(
2352 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED);
Amit Mahajan24f7b162016-07-21 16:33:53 -07002353 }
2354
2355 private boolean isVtProvisioned() {
Malcolm Chen18837ff2017-10-25 17:05:41 -07002356 return getProvisionedBoolNoException(
2357 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED);
Jack Yu643ffe42016-07-08 14:25:46 -07002358 }
2359
Malcolm Chen212ca652017-09-28 17:28:45 -07002360 private static String booleanToPropertyString(boolean bool) {
2361 return bool ? "1" : "0";
2362 }
2363
2364
Jack Yu2f102bd2015-12-28 15:31:48 -08002365 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
2366 pw.println("ImsManager:");
2367 pw.println(" mPhoneId = " + mPhoneId);
2368 pw.println(" mConfigUpdated = " + mConfigUpdated);
Brad Ebinger172977a2018-01-16 09:36:56 -08002369 pw.println(" mImsServiceProxy = " + mMmTelFeatureConnection);
Amit Mahajan24f7b162016-07-21 16:33:53 -07002370 pw.println(" mDataEnabled = " + isDataEnabled());
Brad Ebinger479f52c2017-08-28 13:19:22 -07002371 pw.println(" ignoreDataEnabledChanged = " + getBooleanCarrierConfig(
Jack Yu57781852016-11-16 17:20:38 -08002372 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS));
Jack Yu2f102bd2015-12-28 15:31:48 -08002373
Brad Ebinger479f52c2017-08-28 13:19:22 -07002374 pw.println(" isGbaValid = " + isGbaValid());
Jack Yu2f102bd2015-12-28 15:31:48 -08002375 pw.println(" isImsTurnOffAllowed = " + isImsTurnOffAllowed());
Brad Ebinger479f52c2017-08-28 13:19:22 -07002376 pw.println(" isNonTtyOrTtyOnVolteEnabled = " + isNonTtyOrTtyOnVolteEnabled());
Jack Yu2f102bd2015-12-28 15:31:48 -08002377
Brad Ebinger479f52c2017-08-28 13:19:22 -07002378 pw.println(" isVolteEnabledByPlatform = " + isVolteEnabledByPlatform());
2379 pw.println(" isVolteProvisionedOnDevice = " + isVolteProvisionedOnDevice());
Jack Yu2f102bd2015-12-28 15:31:48 -08002380 pw.println(" isEnhanced4gLteModeSettingEnabledByUser = " +
Brad Ebinger479f52c2017-08-28 13:19:22 -07002381 isEnhanced4gLteModeSettingEnabledByUser());
2382 pw.println(" isVtEnabledByPlatform = " + isVtEnabledByPlatform());
2383 pw.println(" isVtEnabledByUser = " + isVtEnabledByUser());
Jack Yu2f102bd2015-12-28 15:31:48 -08002384
Brad Ebinger479f52c2017-08-28 13:19:22 -07002385 pw.println(" isWfcEnabledByPlatform = " + isWfcEnabledByPlatform());
2386 pw.println(" isWfcEnabledByUser = " + isWfcEnabledByUser());
2387 pw.println(" getWfcMode = " + getWfcMode());
2388 pw.println(" isWfcRoamingEnabledByUser = " + isWfcRoamingEnabledByUser());
Jack Yu2f102bd2015-12-28 15:31:48 -08002389
Brad Ebinger479f52c2017-08-28 13:19:22 -07002390 pw.println(" isVtProvisionedOnDevice = " + isVtProvisionedOnDevice());
2391 pw.println(" isWfcProvisionedOnDevice = " + isWfcProvisionedOnDevice());
Jack Yu2f102bd2015-12-28 15:31:48 -08002392 pw.flush();
2393 }
Wink Savilleef36ef62014-06-11 08:39:38 -07002394}