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