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