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