1 /* 2 * Copyright (C) 2020 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 static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertTrue; 21 import static org.mockito.ArgumentMatchers.anyString; 22 import static org.mockito.ArgumentMatchers.eq; 23 import static org.mockito.Mockito.anyInt; 24 import static org.mockito.Mockito.doReturn; 25 import static org.mockito.Mockito.never; 26 import static org.mockito.Mockito.times; 27 import static org.mockito.Mockito.verify; 28 import static org.mockito.Mockito.when; 29 30 import android.content.pm.PackageManager; 31 import android.content.res.Resources; 32 import android.os.IBinder; 33 import android.os.PersistableBundle; 34 import android.telephony.CarrierConfigManager; 35 import android.telephony.SubscriptionManager; 36 import android.telephony.ims.ImsMmTelManager; 37 import android.telephony.ims.ProvisioningManager; 38 import android.telephony.ims.aidl.IImsConfig; 39 import android.telephony.ims.aidl.IImsRegistration; 40 import android.telephony.ims.aidl.ISipTransport; 41 import android.telephony.ims.feature.MmTelFeature; 42 import android.telephony.ims.stub.ImsConfigImplBase; 43 import android.telephony.ims.stub.ImsRegistrationImplBase; 44 45 import androidx.test.ext.junit.runners.AndroidJUnit4; 46 import androidx.test.filters.SmallTest; 47 48 import com.android.internal.os.SomeArgs; 49 50 import org.junit.After; 51 import org.junit.Before; 52 import org.junit.Test; 53 import org.junit.runner.RunWith; 54 import org.mockito.Mock; 55 56 import java.util.Hashtable; 57 58 @RunWith(AndroidJUnit4.class) 59 public class ImsManagerTest extends ImsTestBase { 60 private static final boolean ENHANCED_4G_MODE_DEFAULT_VAL = true; 61 private static final boolean ENHANCED_4G_MODE_EDITABLE = true; 62 private static final boolean WFC_IMS_ENABLE_DEFAULT_VAL = false; 63 private static final boolean WFC_IMS_ROAMING_ENABLE_DEFAULT_VAL = true; 64 private static final boolean VT_IMS_ENABLE_DEFAULT_VAL = true; 65 private static final boolean WFC_IMS_EDITABLE_VAL = true; 66 private static final boolean WFC_IMS_NOT_EDITABLE_VAL = false; 67 private static final boolean WFC_IMS_ROAMING_EDITABLE_VAL = true; 68 private static final boolean WFC_IMS_ROAMING_NOT_EDITABLE_VAL = false; 69 private static final int WFC_IMS_MODE_DEFAULT_VAL = 70 ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED; 71 private static final int WFC_IMS_ROAMING_MODE_DEFAULT_VAL = 72 ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED; 73 private static final boolean WFC_USE_HOME_MODE_FOR_ROAMING_VAL = true; 74 private static final boolean WFC_NOT_USE_HOME_MODE_FOR_ROAMING_VAL = false; 75 76 PersistableBundle mBundle; 77 @Mock ImsConfigImplBase mImsConfigImplBaseMock; 78 Hashtable<Integer, Integer> mProvisionedIntVals = new Hashtable<>(); 79 ImsConfigImplBase.ImsConfigStub mImsConfigStub; 80 @Mock MmTelFeatureConnection mMmTelFeatureConnection; 81 @Mock IBinder mMmTelFeature; 82 @Mock IImsConfig mImsConfig; 83 @Mock IImsRegistration mImsReg; 84 @Mock ISipTransport mSipTransport; 85 @Mock ImsManager.SubscriptionManagerProxy mSubscriptionManagerProxy; 86 @Mock ImsManager.SettingsProxy mSettingsProxy; 87 88 private final int[] mSubId = {0}; 89 private final int mPhoneId = 1; 90 91 @Before setUp()92 public void setUp() throws Exception { 93 super.setUp(); 94 mBundle = mContextFixture.getTestCarrierConfigBundle(); 95 // Force MmTelFeatureConnection to create an executor using Looper.myLooper(). 96 doReturn(null).when(mContext).getMainLooper(); 97 98 doReturn(true).when(mMmTelFeatureConnection).isBinderAlive(); 99 mContextFixture.addSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS); 100 101 doReturn(true).when(mSubscriptionManagerProxy).isValidSubscriptionId(anyInt()); 102 doReturn(mSubId).when(mSubscriptionManagerProxy).getSubscriptionIds(eq(mPhoneId)); 103 doReturn(mSubId).when(mSubscriptionManagerProxy).getActiveSubscriptionIdList(); 104 doReturn(mPhoneId).when(mSubscriptionManagerProxy).getDefaultVoicePhoneId(); 105 doReturn(-1).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty(anyInt(), 106 anyString(), anyInt()); 107 108 109 setDefaultValues(); 110 } 111 112 @After tearDown()113 public void tearDown() throws Exception { 114 super.tearDown(); 115 } 116 setDefaultValues()117 private void setDefaultValues() { 118 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL, 119 ENHANCED_4G_MODE_EDITABLE); 120 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, 121 WFC_IMS_EDITABLE_VAL); 122 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, 123 WFC_IMS_ROAMING_EDITABLE_VAL); 124 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL, 125 WFC_IMS_ENABLE_DEFAULT_VAL); 126 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL, 127 WFC_IMS_ROAMING_ENABLE_DEFAULT_VAL); 128 mBundle.putInt(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT, 129 WFC_IMS_MODE_DEFAULT_VAL); 130 mBundle.putInt(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT, 131 WFC_IMS_ROAMING_MODE_DEFAULT_VAL); 132 mBundle.putBoolean(CarrierConfigManager.KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL, 133 ENHANCED_4G_MODE_DEFAULT_VAL); 134 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL, true); 135 mBundle.putBoolean( 136 CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, 137 WFC_NOT_USE_HOME_MODE_FOR_ROAMING_VAL); 138 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_RCS_PROVISIONING_REQUIRED_BOOL, true); 139 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL, true); 140 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_IMS_GBA_REQUIRED_BOOL, false); 141 142 } 143 144 @Test @SmallTest testGetDefaultValues()145 public void testGetDefaultValues() { 146 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 147 148 assertEquals(WFC_IMS_ENABLE_DEFAULT_VAL, imsManager.isWfcEnabledByUser()); 149 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 150 anyInt(), 151 eq(SubscriptionManager.WFC_IMS_ENABLED), 152 anyInt()); 153 154 assertEquals(WFC_IMS_ROAMING_ENABLE_DEFAULT_VAL, imsManager.isWfcRoamingEnabledByUser()); 155 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 156 anyInt(), 157 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 158 anyInt()); 159 160 assertEquals(ENHANCED_4G_MODE_DEFAULT_VAL, 161 imsManager.isEnhanced4gLteModeSettingEnabledByUser()); 162 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 163 anyInt(), 164 eq(SubscriptionManager.ENHANCED_4G_MODE_ENABLED), 165 anyInt()); 166 167 assertEquals(WFC_IMS_MODE_DEFAULT_VAL, imsManager.getWfcMode(false)); 168 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 169 anyInt(), 170 eq(SubscriptionManager.WFC_IMS_MODE), 171 anyInt()); 172 173 assertEquals(WFC_IMS_ROAMING_MODE_DEFAULT_VAL, imsManager.getWfcMode(true)); 174 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 175 anyInt(), 176 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 177 anyInt()); 178 179 assertEquals(VT_IMS_ENABLE_DEFAULT_VAL, imsManager.isVtEnabledByUser()); 180 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 181 anyInt(), 182 eq(SubscriptionManager.VT_IMS_ENABLED), 183 anyInt()); 184 } 185 186 @SmallTest 187 @Test testImsStats()188 public void testImsStats() { 189 setWfcEnabledByUser(true); 190 SomeArgs args = SomeArgs.obtain(); 191 ImsManager.setImsStatsCallback(mPhoneId, new ImsManager.ImsStatsCallback() { 192 @Override 193 public void onEnabledMmTelCapabilitiesChanged(int capability, int regTech, 194 boolean isEnabled) { 195 args.arg1 = capability; 196 args.arg2 = regTech; 197 args.arg3 = isEnabled; 198 } 199 }); 200 mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL, 201 false); 202 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 203 // Assert that the IMS stats callback is called properly when a setting changes. 204 imsManager.setWfcSetting(true); 205 assertEquals(args.arg1, MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE); 206 assertEquals(args.arg2, ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN); 207 assertEquals(args.arg3, true); 208 args.recycle(); 209 } 210 211 @Test @SmallTest testSetValues()212 public void testSetValues() { 213 setWfcEnabledByUser(true); 214 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 215 216 imsManager.setWfcMode(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED); 217 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 218 eq(mSubId[0]), 219 eq(SubscriptionManager.WFC_IMS_MODE), 220 eq("1")); 221 222 imsManager.setWfcMode(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED, true); 223 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 224 eq(mSubId[0]), 225 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 226 eq("1")); 227 228 imsManager.setVtSetting(false); 229 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 230 eq(mSubId[0]), 231 eq(SubscriptionManager.VT_IMS_ENABLED), 232 eq("0")); 233 234 // enhanced 4g mode must be editable to use setEnhanced4gLteModeSetting 235 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL, 236 ENHANCED_4G_MODE_EDITABLE); 237 imsManager.setEnhanced4gLteModeSetting(true); 238 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 239 eq(mSubId[0]), 240 eq(SubscriptionManager.ENHANCED_4G_MODE_ENABLED), 241 eq("1")); 242 243 imsManager.setWfcSetting(true); 244 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 245 eq(mSubId[0]), 246 eq(SubscriptionManager.WFC_IMS_ENABLED), 247 eq("1")); 248 } 249 @Test testGetProvisionedValues()250 public void testGetProvisionedValues() throws Exception { 251 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 252 253 assertEquals(true, imsManager.isWfcProvisionedOnDevice()); 254 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 255 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED)); 256 257 assertEquals(true, imsManager.isVtProvisionedOnDevice()); 258 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 259 eq(ImsConfig.ConfigConstants.LVC_SETTING_ENABLED)); 260 261 assertEquals(true, imsManager.isVolteProvisionedOnDevice()); 262 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 263 eq(ImsConfig.ConfigConstants.VLT_SETTING_ENABLED)); 264 265 // If we call get again, times should still be one because the value should be fetched 266 // from cache. 267 assertEquals(true, imsManager.isWfcProvisionedOnDevice()); 268 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 269 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED)); 270 271 assertEquals(true, imsManager.isVtProvisionedOnDevice()); 272 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 273 eq(ImsConfig.ConfigConstants.LVC_SETTING_ENABLED)); 274 275 assertEquals(true, imsManager.isVolteProvisionedOnDevice()); 276 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 277 eq(ImsConfig.ConfigConstants.VLT_SETTING_ENABLED)); 278 279 assertEquals(true, imsManager.isEabProvisionedOnDevice()); 280 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 281 eq(ImsConfig.ConfigConstants.EAB_SETTING_ENABLED)); 282 } 283 284 @Test testSetProvisionedValues()285 public void testSetProvisionedValues() throws Exception { 286 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 287 288 assertEquals(true, imsManager.isWfcProvisionedOnDevice()); 289 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 290 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED)); 291 292 imsManager.getConfigInterface().setProvisionedValue( 293 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED, 294 ImsConfig.FeatureValueConstants.OFF); 295 296 assertEquals(0, (int) mProvisionedIntVals.get( 297 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED)); 298 299 assertEquals(false, imsManager.isWfcProvisionedOnDevice()); 300 301 verify(mImsConfigImplBaseMock, times(1)).setConfig( 302 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED), 303 eq(0)); 304 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 305 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED)); 306 } 307 308 @Test testEabSetProvisionedValues()309 public void testEabSetProvisionedValues() throws Exception { 310 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 311 312 assertEquals(true, imsManager.isEabProvisionedOnDevice()); 313 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 314 eq(ImsConfig.ConfigConstants.EAB_SETTING_ENABLED)); 315 316 imsManager.getConfigInterface().setProvisionedValue( 317 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED, 318 ImsConfig.FeatureValueConstants.OFF); 319 320 assertEquals(0, (int) mProvisionedIntVals.get( 321 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED)); 322 323 assertEquals(false, imsManager.isEabProvisionedOnDevice()); 324 325 verify(mImsConfigImplBaseMock, times(1)).setConfig( 326 eq(ImsConfig.ConfigConstants.EAB_SETTING_ENABLED), 327 eq(0)); 328 verify(mImsConfigImplBaseMock, times(1)).getConfigInt( 329 eq(ImsConfig.ConfigConstants.EAB_SETTING_ENABLED)); 330 } 331 332 /** 333 * Tests that when WFC is enabled/disabled for home/roaming, that setting is sent to the 334 * ImsService correctly. 335 * 336 * Preconditions: 337 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 338 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 339 */ 340 @Test @SmallTest testSetWfcSetting_true_shouldSetWfcModeWrtRoamingState()341 public void testSetWfcSetting_true_shouldSetWfcModeWrtRoamingState() throws Exception { 342 setWfcEnabledByUser(true); 343 // First, Set WFC home/roaming mode that is not the Carrier Config default. 344 doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED) 345 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 346 anyInt(), 347 eq(SubscriptionManager.WFC_IMS_MODE), 348 anyInt()); 349 doReturn(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED) 350 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 351 anyInt(), 352 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 353 anyInt()); 354 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 355 356 // Roaming 357 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 358 // Turn on WFC 359 imsManager.setWfcSetting(true); 360 // Roaming mode (CELLULAR_PREFERRED) should be set. 361 verify(mImsConfigImplBaseMock).setConfig( 362 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 363 eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED)); 364 // WFC is enabled, so we should set user roaming setting 365 verify(mImsConfigImplBaseMock).setConfig( 366 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 367 eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED)); 368 369 // Not roaming 370 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 371 // Turn on WFC 372 imsManager.setWfcSetting(true); 373 // Home mode (WIFI_PREFERRED) should be set. 374 verify(mImsConfigImplBaseMock).setConfig( 375 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 376 eq(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)); 377 // WFC is enabled, so we should set user roaming setting 378 verify(mImsConfigImplBaseMock, times(2)).setConfig( 379 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 380 eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED)); 381 382 383 // Turn off WFC and ensure that roaming setting is disabled. 384 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 385 // mock Subscription DB change due to WFC setting being set to false 386 setWfcEnabledByUser(false); 387 imsManager.setWfcSetting(false); 388 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 389 anyInt(), 390 eq(SubscriptionManager.WFC_IMS_ENABLED), 391 eq("0" /*false*/)); 392 verify(mImsConfigImplBaseMock).setConfig( 393 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 394 eq(ProvisioningManager.PROVISIONING_VALUE_DISABLED)); 395 } 396 397 398 /** 399 * Tests that when user changed WFC setting while NOT roaming, the home WFC mode is sent to the 400 * modem and the roaming enabled configuration is pushed. 401 * 402 * Preconditions: 403 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 404 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 405 */ 406 @Test @SmallTest testSetWfcSetting_shouldSetWfcModeRoamingDisabledUserEnabled()407 public void testSetWfcSetting_shouldSetWfcModeRoamingDisabledUserEnabled() throws Exception { 408 setWfcEnabledByUser(true); 409 // The user has previously enabled "WFC while roaming" setting in UI and then turned WFC 410 // off. 411 doReturn(1 /*true*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 412 anyInt(), 413 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 414 anyInt()); 415 416 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 417 418 // We are currently on the home network, not roaming. 419 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 420 421 // User enables WFC from UI 422 imsManager.setWfcSetting(true /*enabled*/); 423 verify(mImsConfigImplBaseMock).setConfig( 424 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 425 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 426 verify(mImsConfigImplBaseMock).setConfig( 427 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 428 // Should be enabled because the user enabled the "WFC while roaming" setting 429 // independent of whether or not we are roaming. 430 eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED)); 431 } 432 433 /** 434 * Tests that when user changed WFC setting while roaming, that the correct user setting 435 * is sent to the ImsService when changing the roaming mode. 436 * 437 * Preconditions: 438 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 439 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 440 */ 441 @Test @SmallTest testSetWfcSetting_shouldSetWfcModeRoamingEnabledUserEnabled()442 public void testSetWfcSetting_shouldSetWfcModeRoamingEnabledUserEnabled() throws Exception { 443 setWfcEnabledByUser(true); 444 // The user has previously enabled "WFC while roaming" setting in UI and then turned WFC 445 // off. 446 doReturn(1 /*true*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 447 anyInt(), 448 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 449 anyInt()); 450 451 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 452 453 // The device is currently roaming 454 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 455 456 // The user has enabled WFC in the UI while the device is roaming. 457 imsManager.setWfcSetting(true /*enabled*/); 458 459 verify(mImsConfigImplBaseMock).setConfig( 460 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 461 // Default for roaming is WFC_IMS_ROAMING_MODE_DEFAULT_VAL 462 eq(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)); 463 verify(mImsConfigImplBaseMock).setConfig( 464 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 465 // Should be enabled because user enabled the setting in the UI previously. 466 eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED)); 467 } 468 469 /** 470 * Tests that when a WFC mode is updated for home, that setting is sent to the 471 * ImsService correctly or ignored if the roaming mode is changed. 472 * 473 * Preconditions: 474 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 475 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 476 */ 477 @Test @SmallTest testSetWfcMode_shouldSetWfcModeRoamingDisabled()478 public void testSetWfcMode_shouldSetWfcModeRoamingDisabled() throws Exception { 479 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 480 481 // the device is not currently roaming 482 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 483 484 // set the WFC roaming mode while the device is not roaming, so any changes to roaming mode 485 // should be ignored 486 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true /*IsRoaming*/); 487 verify(mImsConfigImplBaseMock, never()).setConfig( 488 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 489 anyInt()); 490 verify(mImsConfigImplBaseMock, never()).setConfig( 491 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 492 anyInt()); 493 494 // set home WFC mode setting while not roaming, the configuration should be set correctly. 495 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false /*IsRoaming*/); 496 verify(mImsConfigImplBaseMock).setConfig( 497 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 498 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 499 // WiFi Roaming enabled setting is not related to WFC mode 500 verify(mImsConfigImplBaseMock, never()).setConfig( 501 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 502 anyInt()); 503 } 504 505 /** 506 * Tests that when a WFC mode is updated for roaming while WFC is enabled, that setting is sent 507 * to the ImsService correctly when changing the roaming mode or ignored if the home setting is 508 * changed. 509 * 510 * Preconditions: 511 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 512 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 513 */ 514 @Test @SmallTest testSetWfcMode_wfcEnabledShouldSetWfcModeRoamingEnabled()515 public void testSetWfcMode_wfcEnabledShouldSetWfcModeRoamingEnabled() throws Exception { 516 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 517 518 // The user has previously enabled WFC in the settings UI. 519 doReturn(1 /*true*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 520 anyInt(), 521 eq(SubscriptionManager.WFC_IMS_ENABLED), 522 anyInt()); 523 524 // The device is roaming 525 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 526 527 // The carrier app has changed the WFC mode for roaming while the device is home. The 528 // result of this operation is that the neither the WFC mode or the roaming enabled 529 // configuration should change. 530 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false /*IsRoaming*/); 531 verify(mImsConfigImplBaseMock, never()).setConfig( 532 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 533 anyInt()); 534 verify(mImsConfigImplBaseMock, never()).setConfig( 535 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 536 anyInt()); 537 538 // The carrier app has set the WFC mode for roaming while the device is roaming. The 539 // WFC mode should be updated to reflect the roaming setting and the roaming enabled 540 // configuration should be changed to enabled. 541 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true /*IsRoaming*/); 542 verify(mImsConfigImplBaseMock).setConfig( 543 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 544 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 545 // WiFi Roaming enabled setting is not related to WFC mode 546 verify(mImsConfigImplBaseMock, never()).setConfig( 547 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 548 anyInt()); 549 } 550 551 /** 552 * Tests that when a WFC mode is updated for roaming while WFC is disabled, the WFC roaming 553 * setting is always set to disabled. 554 * 555 * Preconditions: 556 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 557 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 558 */ 559 @Test @SmallTest testSetWfcMode_WfcDisabledShouldNotSetWfcModeRoamingEnabled()560 public void testSetWfcMode_WfcDisabledShouldNotSetWfcModeRoamingEnabled() throws Exception { 561 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 562 563 // The user has previously disabled WFC in the settings UI. 564 doReturn(0 /*false*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 565 anyInt(), 566 eq(SubscriptionManager.WFC_IMS_ENABLED), 567 anyInt()); 568 569 // The device is roaming 570 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 571 572 // WFC is disabled and the carrier app has set the WFC mode for roaming while the device is 573 // roaming. The WFC mode should be updated to reflect the roaming setting and the roaming 574 // enabled configuration should be disabled because WFC is disabled. 575 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true /*IsRoaming*/); 576 verify(mImsConfigImplBaseMock).setConfig( 577 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 578 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 579 // WiFi Roaming enabled setting is not related to WFC mode 580 verify(mImsConfigImplBaseMock, never()).setConfig( 581 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 582 anyInt()); 583 } 584 585 /** 586 * Tests that when user changed WFC mode while not roaming, the new mode is sent to the modem 587 * and roaming enabled indication is sent to the ImsService correctly when changing the roaming 588 * mode. 589 * 590 * Preconditions: 591 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 592 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 593 */ 594 @Test @SmallTest testSetWfcMode_shouldSetWfcModeRoamingDisabledUserEnabled()595 public void testSetWfcMode_shouldSetWfcModeRoamingDisabledUserEnabled() throws Exception { 596 // The user has enabled the WFC setting in the UI. 597 doReturn(1 /*true*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 598 anyInt(), 599 eq(SubscriptionManager.WFC_IMS_ENABLED), 600 anyInt()); 601 // The user has enabled the "WFC while roaming" setting in the UI while WFC was enabled 602 doReturn(1 /*true*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 603 anyInt(), 604 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 605 anyInt()); 606 607 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 608 609 // The device is currently on the home network 610 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 611 612 // The user has changed the WFC mode in the UI for the non-roaming configuration 613 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false /*IsRoaming*/); 614 verify(mImsConfigImplBaseMock).setConfig( 615 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 616 // ensure that the correct cellular preferred config change is sent 617 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 618 // WiFi Roaming enabled setting is not related to WFC mode 619 verify(mImsConfigImplBaseMock, never()).setConfig( 620 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 621 anyInt()); 622 } 623 624 /** 625 * Tests that when user changed WFC mode while roaming, that setting is sent to the 626 * ImsService correctly when changing the roaming mode. 627 * 628 * Preconditions: 629 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 630 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true 631 */ 632 @Test @SmallTest testSetWfcMode_shouldSetWfcModeRoamingEnabledUserDisabled()633 public void testSetWfcMode_shouldSetWfcModeRoamingEnabledUserDisabled() throws Exception { 634 // The user disabled "WFC while roaming" setting in the UI 635 doReturn(0 /*false*/).when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 636 anyInt(), 637 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 638 anyInt()); 639 640 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 641 642 // the device is currently roaming 643 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 644 645 // The carrier app has changed the WFC mode while roaming, so we must set the WFC mode 646 // to the new configuration. 647 imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true /*IsRoaming*/); 648 verify(mImsConfigImplBaseMock).setConfig( 649 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), 650 eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED)); 651 // WiFi Roaming enabled setting is not related to WFC mode 652 verify(mImsConfigImplBaseMock, never()).setConfig( 653 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 654 anyInt()); 655 } 656 657 /** 658 * Tests that the settings for WFC mode are ignored if the Carrier sets the settings to not 659 * editable. 660 * 661 * Preconditions: 662 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = false 663 */ 664 @Test @SmallTest testSetWfcSetting_wfcNotEditable()665 public void testSetWfcSetting_wfcNotEditable() throws Exception { 666 setWfcEnabledByUser(true); 667 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, 668 WFC_IMS_NOT_EDITABLE_VAL); 669 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, 670 WFC_IMS_ROAMING_NOT_EDITABLE_VAL); 671 // Set some values that are different than the defaults for WFC mode. 672 doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) 673 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 674 anyInt(), 675 eq(SubscriptionManager.WFC_IMS_MODE), 676 anyInt()); 677 doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) 678 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 679 anyInt(), 680 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 681 anyInt()); 682 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 683 684 // Roaming 685 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 686 // Turn on WFC 687 imsManager.setWfcSetting(true); 688 verify(mImsConfigImplBaseMock).setConfig( 689 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 690 eq(WFC_IMS_ROAMING_MODE_DEFAULT_VAL)); 691 692 // Not roaming 693 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 694 // Turn on WFC 695 imsManager.setWfcSetting(true); 696 // Default Home mode (CELLULAR_PREFERRED) should be set. 697 verify(mImsConfigImplBaseMock).setConfig( 698 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 699 eq(WFC_IMS_MODE_DEFAULT_VAL)); 700 } 701 702 /** 703 * Tests that the CarrierConfig defaults will be used if no setting is set in the Subscription 704 * Manager. 705 * 706 * Preconditions: 707 * - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true 708 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT = Carrier preferred 709 * - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT = WiFi preferred 710 */ 711 @Test @SmallTest testSetWfcSetting_noUserSettingSet()712 public void testSetWfcSetting_noUserSettingSet() throws Exception { 713 setWfcEnabledByUser(true); 714 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 715 716 // Roaming 717 doReturn(true).when(mTelephonyManager).isNetworkRoaming(); 718 // Turn on WFC 719 imsManager.setWfcSetting(true); 720 721 // Default Roaming mode (WIFI_PREFERRED) for carrier should be set. With 1000 ms timeout. 722 verify(mImsConfigImplBaseMock).setConfig( 723 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 724 eq(WFC_IMS_ROAMING_MODE_DEFAULT_VAL)); 725 726 // Not roaming 727 doReturn(false).when(mTelephonyManager).isNetworkRoaming(); 728 // Turn on WFC 729 imsManager.setWfcSetting(true); 730 731 // Default Home mode (CELLULAR_PREFERRED) for carrier should be set. With 1000 ms timeout. 732 verify(mImsConfigImplBaseMock).setConfig( 733 eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), 734 eq(WFC_IMS_MODE_DEFAULT_VAL)); 735 } 736 737 /** 738 * Tests the operation of getWfcMode when the configuration to use the home network mode when 739 * roaming for WFC is false. First, it checks that the user setting for WFC_IMS_ROAMING_MODE is 740 * returned when WFC roaming is set to editable. Then, it switches the WFC roaming mode to not 741 * editable and ensures that the default WFC roaming mode is returned. 742 * 743 * Preconditions: 744 * - CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL = false 745 */ 746 @Test @SmallTest getWfcMode_useWfcHomeModeConfigFalse_shouldUseWfcRoamingMode()747 public void getWfcMode_useWfcHomeModeConfigFalse_shouldUseWfcRoamingMode() { 748 // Set some values that are different than the defaults for WFC mode. 749 doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) 750 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 751 anyInt(), 752 eq(SubscriptionManager.WFC_IMS_MODE), 753 anyInt()); 754 doReturn(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED) 755 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 756 anyInt(), 757 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 758 anyInt()); 759 760 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 761 762 // Check that use the WFC roaming network mode. 763 assertEquals(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED, 764 imsManager.getWfcMode(true)); 765 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 766 anyInt(), 767 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 768 anyInt()); 769 770 // Set WFC roaming network mode to not editable. 771 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, 772 WFC_IMS_ROAMING_NOT_EDITABLE_VAL); 773 774 // Check that use the default WFC roaming network mode. 775 assertEquals(WFC_IMS_ROAMING_MODE_DEFAULT_VAL, imsManager.getWfcMode(true)); 776 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 777 anyInt(), 778 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 779 anyInt()); 780 } 781 782 /** 783 * Tests the operation of getWfcMode when the configuration to use the home network mode when 784 * roaming for WFC is true independent of whether or not the WFC roaming mode is editable. 785 * 786 * Preconditions: 787 * - CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL = true 788 */ 789 @Test @SmallTest getWfcMode_useWfcHomeModeConfigTrue_shouldUseWfcHomeMode()790 public void getWfcMode_useWfcHomeModeConfigTrue_shouldUseWfcHomeMode() { 791 // Set some values that are different than the defaults for WFC mode. 792 doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) 793 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 794 anyInt(), 795 eq(SubscriptionManager.WFC_IMS_MODE), 796 anyInt()); 797 doReturn(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED) 798 .when(mSubscriptionManagerProxy).getIntegerSubscriptionProperty( 799 anyInt(), 800 eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), 801 anyInt()); 802 803 // Set to use WFC home network mode in roaming network. 804 mBundle.putBoolean( 805 CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, 806 WFC_USE_HOME_MODE_FOR_ROAMING_VAL); 807 808 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 809 810 // Check that use the WFC home network mode. 811 assertEquals(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY, imsManager.getWfcMode(true)); 812 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 813 anyInt(), 814 eq(SubscriptionManager.WFC_IMS_MODE), 815 anyInt()); 816 817 // Set WFC home network mode to not editable. 818 mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, 819 WFC_IMS_NOT_EDITABLE_VAL); 820 821 // Check that use the default WFC home network mode. 822 assertEquals(WFC_IMS_MODE_DEFAULT_VAL, imsManager.getWfcMode(true)); 823 verify(mSubscriptionManagerProxy, times(1)).getIntegerSubscriptionProperty( 824 anyInt(), 825 eq(SubscriptionManager.WFC_IMS_MODE), 826 anyInt()); 827 } 828 829 /** 830 * Tests the operation of setWfcRoamingSetting and ensures that the user setting for WFC roaming 831 * and the ImsConfig setting are both called properly. 832 */ 833 @Test @SmallTest setWfcRoamingSettingTest()834 public void setWfcRoamingSettingTest() { 835 ImsManager imsManager = getImsManagerAndInitProvisionedValues(); 836 837 imsManager.setWfcRoamingSetting(true); 838 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 839 anyInt(), 840 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 841 eq("1")); 842 verify(mImsConfigImplBaseMock).setConfig( 843 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 844 eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED)); 845 846 imsManager.setWfcRoamingSetting(false); 847 verify(mSubscriptionManagerProxy, times(1)).setSubscriptionProperty( 848 anyInt(), 849 eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), 850 eq("0")); 851 verify(mImsConfigImplBaseMock).setConfig( 852 eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), 853 eq(ProvisioningManager.PROVISIONING_VALUE_DISABLED)); 854 855 } 856 getImsManagerAndInitProvisionedValues()857 private ImsManager getImsManagerAndInitProvisionedValues() { 858 when(mImsConfigImplBaseMock.getConfigInt(anyInt())) 859 .thenAnswer(invocation -> { 860 return getProvisionedInt((Integer) (invocation.getArguments()[0])); 861 }); 862 863 when(mImsConfigImplBaseMock.setConfig(anyInt(), anyInt())) 864 .thenAnswer(invocation -> { 865 mProvisionedIntVals.put((Integer) (invocation.getArguments()[0]), 866 (Integer) (invocation.getArguments()[1])); 867 return ImsConfig.OperationStatusConstants.SUCCESS; 868 }); 869 870 871 // Configure ImsConfigStub 872 mImsConfigStub = new ImsConfigImplBase.ImsConfigStub(mImsConfigImplBaseMock); 873 doReturn(mImsConfigStub).when(mMmTelFeatureConnection).getConfig(); 874 875 ImsManager mgr = new ImsManager(mContext, mPhoneId, 876 (context, phoneId, feature, c, r, s) -> mMmTelFeatureConnection, 877 mSubscriptionManagerProxy, mSettingsProxy); 878 ImsFeatureContainer c = new ImsFeatureContainer(mMmTelFeature, mImsConfig, mImsReg, 879 mSipTransport, 0 /*caps*/); 880 mgr.associate(c); 881 // Enabled WFC by default 882 setWfcEnabledByPlatform(true); 883 return mgr; 884 } 885 setWfcEnabledByPlatform(boolean isEnabled)886 private void setWfcEnabledByPlatform(boolean isEnabled) { 887 Resources res = mContext.getResources(); 888 doReturn(isEnabled).when(res).getBoolean( 889 com.android.internal.R.bool.config_device_wfc_ims_available); 890 } 891 setWfcEnabledByUser(boolean isEnabled)892 private void setWfcEnabledByUser(boolean isEnabled) { 893 // The user has previously enabled WFC in the settings UI. 894 doReturn(isEnabled ? 1 /*true*/ : 0).when(mSubscriptionManagerProxy) 895 .getIntegerSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ENABLED), 896 anyInt()); 897 } 898 899 // If the value is ever set, return the set value. If not, return a constant value 1000. getProvisionedInt(int item)900 private int getProvisionedInt(int item) { 901 if (mProvisionedIntVals.containsKey(item)) { 902 return mProvisionedIntVals.get(item); 903 } else { 904 return ImsConfig.FeatureValueConstants.ON; 905 } 906 } 907 } 908