Search in sources :

Example 1 with WifiCallingQueryImsState

use of com.android.settings.network.ims.WifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class MobileNetworkUtils method isWifiCallingEnabled.

/**
 * Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
 */
public static boolean isWifiCallingEnabled(Context context, int subId, @Nullable WifiCallingQueryImsState queryImsState, @Nullable PhoneAccountHandle phoneAccountHandle) {
    if (phoneAccountHandle == null) {
        phoneAccountHandle = context.getSystemService(TelecomManager.class).getSimCallManagerForSubscription(subId);
    }
    boolean isWifiCallingEnabled;
    if (phoneAccountHandle != null) {
        final Intent intent = buildPhoneAccountConfigureIntent(context, phoneAccountHandle);
        isWifiCallingEnabled = intent != null;
    } else {
        if (queryImsState == null) {
            queryImsState = new WifiCallingQueryImsState(context, subId);
        }
        isWifiCallingEnabled = queryImsState.isReadyToWifiCalling();
    }
    return isWifiCallingEnabled;
}
Also used : WifiCallingQueryImsState(com.android.settings.network.ims.WifiCallingQueryImsState) Intent(android.content.Intent)

Example 2 with WifiCallingQueryImsState

use of com.android.settings.network.ims.WifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingSettingsForSub method updateBody.

private void updateBody() {
    if (!isWfcProvisionedOnDevice()) {
        // This screen is not allowed to be shown due to provisioning policy and should
        // therefore be closed.
        finish();
        return;
    }
    final CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
    boolean isWifiOnlySupported = true;
    if (configManager != null) {
        final PersistableBundle b = configManager.getConfigForSubId(mSubId);
        if (b != null) {
            mEditableWfcMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
            mEditableWfcRoamingMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL);
            mUseWfcHomeModeForRoaming = b.getBoolean(CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, false);
            isWifiOnlySupported = b.getBoolean(CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, true);
        }
    }
    final Resources res = getResourcesForSubId();
    mButtonWfcMode.setTitle(res.getString(R.string.wifi_calling_mode_title));
    mButtonWfcMode.setDialogTitle(res.getString(R.string.wifi_calling_mode_dialog_title));
    mButtonWfcRoamingMode.setTitle(res.getString(R.string.wifi_calling_roaming_mode_title));
    mButtonWfcRoamingMode.setDialogTitle(res.getString(R.string.wifi_calling_roaming_mode_dialog_title));
    if (isWifiOnlySupported) {
        // Set string resources WITH option wifi only in mButtonWfcMode.
        mButtonWfcMode.setEntries(res.getStringArray(R.array.wifi_calling_mode_choices));
        mButtonWfcMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values));
        mButtonWfcMode.setEntrySummaries(res.getStringArray(R.array.wifi_calling_mode_summaries));
        // Set string resources WITH option wifi only in mButtonWfcRoamingMode.
        mButtonWfcRoamingMode.setEntries(res.getStringArray(R.array.wifi_calling_mode_choices_v2));
        mButtonWfcRoamingMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values));
        mButtonWfcRoamingMode.setEntrySummaries(res.getStringArray(R.array.wifi_calling_mode_summaries));
    } else {
        // Set string resources WITHOUT option wifi only in mButtonWfcMode.
        mButtonWfcMode.setEntries(res.getStringArray(R.array.wifi_calling_mode_choices_without_wifi_only));
        mButtonWfcMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
        mButtonWfcMode.setEntrySummaries(res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
        // Set string resources WITHOUT option wifi only in mButtonWfcRoamingMode.
        mButtonWfcRoamingMode.setEntries(res.getStringArray(R.array.wifi_calling_mode_choices_v2_without_wifi_only));
        mButtonWfcRoamingMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
        mButtonWfcRoamingMode.setEntrySummaries(res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
    }
    // NOTE: Buttons will be enabled/disabled in mTelephonyCallback
    final WifiCallingQueryImsState queryIms = queryImsState(mSubId);
    final boolean wfcEnabled = queryIms.isEnabledByUser() && queryIms.isAllowUserControl();
    mSwitchBar.setChecked(wfcEnabled);
    final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
    final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
    mButtonWfcMode.setValue(Integer.toString(wfcMode));
    mButtonWfcRoamingMode.setValue(Integer.toString(wfcRoamingMode));
    updateButtonWfcMode(wfcEnabled, wfcMode, wfcRoamingMode);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) WifiCallingQueryImsState(com.android.settings.network.ims.WifiCallingQueryImsState) PersistableBundle(android.os.PersistableBundle) Resources(android.content.res.Resources)

Example 3 with WifiCallingQueryImsState

use of com.android.settings.network.ims.WifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

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 (SubscriptionManager.isValidSubscriptionId(subId)) {
        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);
        final WifiCallingQueryImsState queryState = queryImsState(subId);
        if (isWifiCallingPrefEditable && queryState.isWifiCallingProvisioned() && queryState.isEnabledByUser() && queryState.isAllowUserControl()) {
            // Change the preference only when wifi calling is enabled
            // And when wifi calling preference is editable for the current carrier
            final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
            final int currentValue = imsMmTelManager.getVoWiFiModeSetting();
            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 = ImsMmTelManager.WIFI_MODE_WIFI_ONLY;
                    }
                    break;
                case ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED:
                    newValue = ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED;
                    break;
                case ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED:
                    newValue = ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED;
                    break;
            }
            if (newValue != errorValue && newValue != currentValue) {
                // Update the setting only when there is a valid update
                imsMmTelManager.setVoWiFiModeSetting(newValue);
            }
        }
    }
    // 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 : WifiCallingQueryImsState(com.android.settings.network.ims.WifiCallingQueryImsState) ImsMmTelManager(android.telephony.ims.ImsMmTelManager)

Example 4 with WifiCallingQueryImsState

use of com.android.settings.network.ims.WifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelper method handleWifiCallingChanged.

/**
 * Handles wifi calling setting change from wifi calling slice and posts notification. Should be
 * called when intent action is ACTION_WIFI_CALLING_CHANGED. Executed in @WorkerThread
 *
 * @param intent action performed
 */
public void handleWifiCallingChanged(Intent intent) {
    final int subId = getDefaultVoiceSubId();
    if (SubscriptionManager.isValidSubscriptionId(subId)) {
        final WifiCallingQueryImsState queryState = queryImsState(subId);
        if (queryState.isWifiCallingProvisioned()) {
            final boolean currentValue = queryState.isEnabledByUser() && queryState.isAllowUserControl();
            final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, currentValue);
            final Intent activationAppIntent = getWifiCallingCarrierActivityIntent(subId);
            if (!newValue || activationAppIntent == null) {
                // or there is no activation involved - Update the setting
                if (newValue != currentValue) {
                    final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
                    imsMmTelManager.setVoWiFiSettingEnabled(newValue);
                }
            }
        }
    }
    // notify change in slice in any case to get re-queried. This would result in displaying
    // appropriate message with the updated setting.
    mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
}
Also used : WifiCallingQueryImsState(com.android.settings.network.ims.WifiCallingQueryImsState) ImsMmTelManager(android.telephony.ims.ImsMmTelManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

WifiCallingQueryImsState (com.android.settings.network.ims.WifiCallingQueryImsState)4 Intent (android.content.Intent)2 ImsMmTelManager (android.telephony.ims.ImsMmTelManager)2 PendingIntent (android.app.PendingIntent)1 Resources (android.content.res.Resources)1 PersistableBundle (android.os.PersistableBundle)1 CarrierConfigManager (android.telephony.CarrierConfigManager)1