Search in sources :

Example 11 with ImsManager

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

the class ImsManagerTest method testSetProvisionedValues.

@Test
public void testSetProvisionedValues() throws Exception {
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    assertEquals(true, imsManager.isWfcProvisionedOnDevice());
    verify(mImsConfigImplBaseMock, times(1)).getConfigInt(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED));
    imsManager.getConfigInterface().setProvisionedValue(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED, ImsConfig.FeatureValueConstants.OFF);
    assertEquals(0, (int) mProvisionedIntVals.get(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED));
    assertEquals(false, imsManager.isWfcProvisionedOnDevice());
    verify(mImsConfigImplBaseMock, times(1)).setConfig(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED), eq(0));
    verify(mImsConfigImplBaseMock, times(1)).getConfigInt(eq(ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED));
}
Also used : ImsManager(com.android.ims.ImsManager) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 12 with ImsManager

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

the class ImsManagerTest method setWfcRoamingSettingTest.

/**
 * Tests the operation of setWfcRoamingSetting and ensures that the user setting for WFC roaming
 * and the ImsConfig setting are both called properly.
 */
@Test
@SmallTest
public void setWfcRoamingSettingTest() {
    ImsManager imsManager = getImsManagerAndInitProvisionedValues();
    imsManager.setWfcRoamingSetting(true);
    verify(mSubscriptionController, times(1)).setSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), eq("1"));
    verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), eq(ProvisioningManager.PROVISIONING_VALUE_ENABLED));
    imsManager.setWfcRoamingSetting(false);
    verify(mSubscriptionController, times(1)).setSubscriptionProperty(anyInt(), eq(SubscriptionManager.WFC_IMS_ROAMING_ENABLED), eq("0"));
    verify(mImsConfigImplBaseMock).setConfig(eq(ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE), eq(ProvisioningManager.PROVISIONING_VALUE_DISABLED));
}
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 13 with ImsManager

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

the class Phone method checkWfcWifiOnlyModeBeforeDial.

public static void checkWfcWifiOnlyModeBeforeDial(Phone imsPhone, int phoneId, Context context) throws CallStateException {
    if (imsPhone == null || !imsPhone.isWifiCallingEnabled()) {
        ImsManager imsManager = ImsManager.getInstance(context, phoneId);
        boolean wfcWiFiOnly = (imsManager.isWfcEnabledByPlatform() && imsManager.isWfcEnabledByUser() && (imsManager.getWfcMode() == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
        if (wfcWiFiOnly) {
            throw new CallStateException(CallStateException.ERROR_OUT_OF_SERVICE, "WFC Wi-Fi Only Mode: IMS not registered");
        }
    }
}
Also used : ImsManager(com.android.ims.ImsManager)

Example 14 with ImsManager

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

the class Phone method isImsUseEnabled.

/**
 * Determines if  IMS is enabled for call.
 *
 * @return {@code true} if IMS calling is enabled.
 */
public boolean isImsUseEnabled() {
    ImsManager imsManager = ImsManager.getInstance(mContext, mPhoneId);
    boolean imsUseEnabled = ((imsManager.isVolteEnabledByPlatform() && imsManager.isEnhanced4gLteModeSettingEnabledByUser()) || (imsManager.isWfcEnabledByPlatform() && imsManager.isWfcEnabledByUser()) && imsManager.isNonTtyOrTtyOnVolteEnabled());
    return imsUseEnabled;
}
Also used : ImsManager(com.android.ims.ImsManager)

Example 15 with ImsManager

use of com.android.ims.ImsManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiCallingSliceHelper method handleWifiCallingPreferenceChanged.

/**
 * Handles wifi calling preference Setting change from wifi calling preference Slice and posts
 * notification for the change. Should be called when intent action is one of the below
 * ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY
 * ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED
 * ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED
 *
 * @param intent intent
 */
public void handleWifiCallingPreferenceChanged(Intent intent) {
    final int subId = getDefaultVoiceSubId();
    final int errorValue = -1;
    if (subId > SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        final boolean isWifiCallingPrefEditable = isCarrierConfigManagerKeyEnabled(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
        final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
        ImsManager imsManager = getImsManager(subId);
        if (isWifiCallingPrefEditable && imsManager.isWfcEnabledByPlatform() && imsManager.isWfcProvisionedOnDevice() && imsManager.isWfcEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled()) {
            // Change the preference only when wifi calling is enabled
            // And when wifi calling preference is editable for the current carrier
            final int currentValue = imsManager.getWfcMode(false);
            int newValue = errorValue;
            switch(intent.getAction()) {
                case ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY:
                    if (isWifiOnlySupported) {
                        // change to wifi_only when wifi_only is enabled.
                        newValue = ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
                    }
                    break;
                case ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED:
                    newValue = ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED;
                    break;
                case ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED:
                    newValue = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
                    break;
            }
            if (newValue != errorValue && newValue != currentValue) {
                // Update the setting only when there is a valid update
                imsManager.setWfcMode(newValue, false);
            }
        }
    }
    // notify change in slice in any case to get re-queried. This would result in displaying
    // appropriate message.
    mContext.getContentResolver().notifyChange(WIFI_CALLING_PREFERENCE_URI, null);
}
Also used : ImsManager(com.android.ims.ImsManager)

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