Search in sources :

Example 26 with ImsManager

use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.

the class ImsManagerTest method testSetWfcMode_shouldSetWfcModeRoamingDisabledUserEnabled.

/**
 * Tests that when user changed WFC mode while not roaming, the new mode is sent to the modem
 * and roaming enabled indication is sent to the ImsService correctly when changing the roaming
 * mode.
 *
 * Preconditions:
 *  - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
 *  - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true
 */
@Test
@SmallTest
public void testSetWfcMode_shouldSetWfcModeRoamingDisabledUserEnabled() throws Exception {
    // The user has enabled the WFC setting in the UI.
    doReturn(String.valueOf(1)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ENABLED), anyString(), nullable(String.class));
    // The user has enabled the "WFC while roaming" setting in the UI while WFC was enabled
    doReturn(String.valueOf(1)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), anyString(), nullable(String.class));
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    // The device is currently on the home network
    doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // The user has changed the WFC mode in the UI for the non-roaming configuration
    imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false);
    verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), // ensure that the correct cellular preferred config change is sent
    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());
}
Also used : ImsManager(com.android.ims.ImsManager) Mockito.anyString(org.mockito.Mockito.anyString) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Example 27 with ImsManager

use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.

the class ImsManagerTest method testSetWfcMode_WfcDisabledShouldNotSetWfcModeRoamingEnabled.

/**
 * Tests that when a WFC mode is updated for roaming while WFC is disabled, the WFC roaming
 * setting is always set to disabled.
 *
 * Preconditions:
 *  - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
 *  - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true
 */
@Test
@SmallTest
public void testSetWfcMode_WfcDisabledShouldNotSetWfcModeRoamingEnabled() throws Exception {
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    // The user has previously disabled WFC in the settings UI.
    doReturn(String.valueOf(0)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ENABLED), anyString(), nullable(String.class));
    // The device is roaming
    doReturn(true).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // WFC is disabled and the carrier app has set the WFC mode for roaming while the device is
    // roaming. The WFC mode should be updated to reflect the roaming setting and the roaming
    // enabled configuration should be disabled because WFC is disabled.
    imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true);
    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());
}
Also used : ImsManager(com.android.ims.ImsManager) Mockito.anyString(org.mockito.Mockito.anyString) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Example 28 with ImsManager

use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.

the class ImsManagerTest method testSetWfcMode_wfcEnabledShouldSetWfcModeRoamingEnabled.

/**
 * Tests that when a WFC mode is updated for roaming while WFC is enabled, that setting is sent
 * to the ImsService correctly when changing the roaming mode or ignored if the home setting 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_wfcEnabledShouldSetWfcModeRoamingEnabled() throws Exception {
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    // The user has previously enabled WFC in the settings UI.
    doReturn(String.valueOf(1)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ENABLED), anyString(), nullable(String.class));
    // The device is roaming
    doReturn(true).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // The carrier app has changed the WFC mode for roaming while the device is home. The
    // result of this operation is that the neither the WFC mode or the roaming enabled
    // configuration should change.
    imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, false);
    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());
    // The carrier app has set the WFC mode for roaming while the device is roaming. The
    // WFC mode should be updated to reflect the roaming setting and the roaming enabled
    // configuration should be changed to enabled.
    imsManager.setWfcMode(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, true);
    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());
}
Also used : ImsManager(com.android.ims.ImsManager) Mockito.anyString(org.mockito.Mockito.anyString) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Example 29 with ImsManager

use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.

the class ImsManagerTest method testSetWfcSetting_noUserSettingSet.

/**
 * Tests that the CarrierConfig defaults will be used if no setting is set in the Subscription
 * Manager.
 *
 * Preconditions:
 *  - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
 *  - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT = Carrier preferred
 *  - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT = WiFi preferred
 */
@Test
@SmallTest
public void testSetWfcSetting_noUserSettingSet() throws Exception {
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    // Roaming
    doReturn(true).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // Turn on WFC
    imsManager.setWfcSetting(true);
    // Default Roaming mode (WIFI_PREFERRED) for carrier should be set. With 1000 ms timeout.
    verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(WFC_IMS_ROAMING_MODE_DEFAULT_VAL));
    // Not roaming
    doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // Turn on WFC
    imsManager.setWfcSetting(true);
    // Default Home mode (CELLULAR_PREFERRED) for carrier should be set. With 1000 ms timeout.
    verify(mImsConfigImplBaseMock).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE), eq(WFC_IMS_MODE_DEFAULT_VAL));
}
Also used : ImsManager(com.android.ims.ImsManager) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Example 30 with ImsManager

use of com.android.ims.ImsManager in project android_frameworks_opt_telephony by LineageOS.

the class ImsManagerTest method testSetWfcSetting_shouldSetWfcModeRoamingDisabledUserEnabled.

/**
 * Tests that when user changed WFC setting while NOT roaming, the home WFC mode is sent to the
 * modem and the roaming enabled configuration is pushed.
 *
 * Preconditions:
 *  - CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL = true
 *  - CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL = true
 */
@Test
@SmallTest
public void testSetWfcSetting_shouldSetWfcModeRoamingDisabledUserEnabled() throws Exception {
    // The user has previously enabled "WFC while roaming" setting in UI and then turned WFC
    // off.
    doReturn(String.valueOf(1)).when(mSubscriptionController).getSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), anyString(), nullable(String.class));
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    // We are currently on the home network, not roaming.
    doReturn(false).when(mTelephonyManager).isNetworkRoaming(eq(mSubId[0]));
    // User enables WFC from UI
    imsManager.setWfcSetting(true);
    verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE), eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
    verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), // independent of whether or not we are roaming.
    eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED));
}
Also used : ImsManager(com.android.ims.ImsManager) Mockito.anyString(org.mockito.Mockito.anyString) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Aggregations

ImsManager (com.android.ims.ImsManager)31 SmallTest (androidx.test.filters.SmallTest)18 TelephonyTest (com.android.internal.telephony.TelephonyTest)18 Test (org.junit.Test)18 Mockito.anyString (org.mockito.Mockito.anyString)11 Intent (android.content.Intent)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 PendingIntent (android.app.PendingIntent)2 CarrierConfigManager (android.telephony.CarrierConfigManager)2 AsyncResult (android.os.AsyncResult)1 Message (android.os.Message)1 PersistableBundle (android.os.PersistableBundle)1 RegistrantList (android.os.RegistrantList)1 PhoneAccountHandle (android.telecom.PhoneAccountHandle)1 BarringInfo (android.telephony.BarringInfo)1 ImsConfigImplBase (android.telephony.ims.stub.ImsConfigImplBase)1 Pair (android.util.Pair)1 GsmMmiCode (com.android.internal.telephony.gsm.GsmMmiCode)1 SuppServiceNotification (com.android.internal.telephony.gsm.SuppServiceNotification)1