use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.
the class ImsManagerTest method testSetWfcSetting_true_shouldSetWfcModeWrtRoamingState.
/**
* Tests that when WFC is enabled/disabled for home/roaming, that setting is sent to the
* ImsService correctly.
*
* Preconditions:
* - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
* - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true
*/
@Test
@SmallTest
public void testSetWfcSetting_true_shouldSetWfcModeWrtRoamingState() throws Exception {
// First, Set WFC home/roaming mode that is not the Carrier Config default.
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_MODE), anyString(), nullable(String.class));
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), anyString(), nullable(String.class));
ImsManager imsManager = getImsManagerAndInitProvisionedValues();
// Roaming
doReturn(true).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
// Turn on WFC
imsManager.setWfcSetting(true);
// Roaming mode (CELLULAR_PREFERRED) should be set.
verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
// WFC is enabled, so we should set user roaming setting
verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED));
// Not roaming
doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
// Turn on WFC
imsManager.setWfcSetting(true);
// Home mode (WIFI_PREFERRED) should be set.
verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED));
// WFC is enabled, so we should set user roaming setting
verify(mImsConfigImplBaseMock, times(2)).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED));
// Turn off WFC and ensure that roaming setting is disabled.
doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
imsManager.setWfcSetting(false);
verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), eq(ProvisioningManager.PROVISIONING_VALUE_DISABLED));
}
use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.
the class ImsManagerTest method getImsManagerAndInitProvisionedValues.
private ImsManager getImsManagerAndInitProvisionedValues() {
when(mImsConfigImplBaseMock.getConfigInt(anyInt())).thenAnswer(invocation -> {
return getProvisionedInt((Integer) (invocation.getArguments()[0]));
});
when(mImsConfigImplBaseMock.setConfig(anyInt(), anyInt())).thenAnswer(invocation -> {
mProvisionedIntVals.put((Integer) (invocation.getArguments()[0]), (Integer) (invocation.getArguments()[1]));
return ImsConfig.OperationStatusConstants.SUCCESS;
});
// Configure ImsConfigStub
mImsConfigStub = new ImsConfigImplBase.ImsConfigStub(mImsConfigImplBaseMock);
doReturn(mImsConfigStub).when(mMmTelFeatureConnection).getConfigInterface();
// Configure ImsManager
ImsManager imsManager = ImsManager.getInstance(mContext, mPhoneId);
try {
replaceInstance(ImsManager.class, "mMmTelFeatureConnection", imsManager, mMmTelFeatureConnection);
} catch (Exception ex) {
fail("failed with " + ex);
}
((ImsManager.ImsExecutorFactory) imsManager.mExecutorFactory).destroy();
imsManager.mExecutorFactory = Runnable::run;
return imsManager;
}
use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.
the class ImsManagerTest method testSetWfcMode_shouldSetWfcModeRoamingDisabled.
/**
* Tests that when a WFC mode is updated for home, that setting is sent to the
* ImsService correctly or ignored if the roaming mode is changed.
*
* Preconditions:
* - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
* - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true
*/
@Test
@SmallTest
public void testSetWfcMode_shouldSetWfcModeRoamingDisabled() throws Exception {
ImsManager imsManager = getImsManagerAndInitProvisionedValues();
// the device is not currently roaming
doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
// set the WFC roaming mode while the device is not roaming, so any changes to roaming mode
// should be ignored
imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true);
verify(mImsConfigImplBaseMock, never()).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), anyInt());
verify(mImsConfigImplBaseMock, never()).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), anyInt());
// set home WFC mode setting while not roaming, the configuration should be set correctly.
imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false);
verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
// WiFi Roaming enabled setting is not related to WFC mode
verify(mImsConfigImplBaseMock, never()).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), anyInt());
}
use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.
the class ImsManagerTest method getWfcMode_useWfcHomeModeConfigFalse_shouldUseWfcRoamingMode.
/**
* Tests the operation of getWfcMode when the configuration to use the home network mode when
* roaming for WFC is false. First, it checks that the user setting for WFC_IMS_ROAMING_MODE is
* returned when WFC roaming is set to editable. Then, it switches the WFC roaming mode to not
* editable and ensures that the default WFC roaming mode is returned.
*
* Preconditions:
* - CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL = false
*/
@Test
@SmallTest
public void getWfcMode_useWfcHomeModeConfigFalse_shouldUseWfcRoamingMode() {
// Set some values that are different than the defaults for WFC mode.
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_MODE), anyString(), nullable(String.class));
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), anyString(), nullable(String.class));
ImsManager imsManager = getImsManagerAndInitProvisionedValues();
// Check that use the WFC roaming network mode.
assertEquals(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED, imsManager.getWfcMode(true));
verify(mSubscriptionController, times(1)).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), anyString(), nullable(String.class));
// Set WFC roaming network mode to not editable.
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, WFC_IMS_ROAMING_NOT_EDITABLE_VAL);
// Check that use the default WFC roaming network mode.
assertEquals(WFC_IMS_ROAMING_MODE_DEFAULT_VAL, imsManager.getWfcMode(true));
verify(mSubscriptionController, times(1)).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), anyString(), nullable(String.class));
}
use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.
the class ImsManagerTest method testSetWfcSetting_wfcNotEditable.
/**
* Tests that the settings for WFC mode are ignored if the Carrier sets the settings to not
* editable.
*
* Preconditions:
* - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = false
*/
@Test
@SmallTest
public void testSetWfcSetting_wfcNotEditable() throws Exception {
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, WFC_IMS_NOT_EDITABLE_VAL);
// Set some values that are different than the defaults for WFC mode.
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_MODE), anyString(), nullable(String.class));
doReturn(String.valueOf(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_MODE), anyString(), nullable(String.class));
ImsManager imsManager = getImsManagerAndInitProvisionedValues();
// Roaming
doReturn(true).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
// Turn on WFC
imsManager.setWfcSetting(true);
// User defined setting for Roaming mode (WIFI_ONLY) should be set independent of whether or
// not WFC mode is editable. With 1000 ms timeout.
verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
// Not roaming
doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
// Turn on WFC
imsManager.setWfcSetting(true);
// Default Home mode (CELLULAR_PREFERRED) should be set. With 1000 ms timeout.
verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(WFC_IMS_MODE_DEFAULT_VAL));
}
Aggregations