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