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