Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3b94292 authored by Bonian Chen's avatar Bonian Chen
Browse files

[Settings] Hidden API remove - WFC mode settings

Change API from getWfcMode/setWfcMode into APIs within ImsMmTelManager.

Bug: 140542283
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest
atest WifiCallingSettingUiTest

Change-Id: I2ee01852cb4ee90fe9db256d3333f461cc070da5
parent 5243629d
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -29,12 +29,12 @@ import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.ims.ImsConfig;
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -54,6 +54,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
    CarrierConfigManager mCarrierConfigManager;
    @VisibleForTesting
    ImsManager mImsManager;
    private ImsMmTelManager mImsMmTelManager;
    @VisibleForTesting
    PhoneAccountHandle mSimCallManager;
    private PhoneCallStateListener mPhoneStateListener;
@@ -88,7 +89,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
        Intent intent = mPreference.getIntent();
        final Intent intent = mPreference.getIntent();
        if (intent != null) {
            intent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
        }
@@ -98,14 +99,14 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
    public void updateState(Preference preference) {
        super.updateState(preference);
        if (mSimCallManager != null) {
            Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
            final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
                    mSimCallManager);
            if (intent == null) {
                // Do nothing in this case since preference is invisible
                return;
            }
            final PackageManager pm = mContext.getPackageManager();
            List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
            final List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
            preference.setTitle(resolutions.get(0).loadLabel(pm));
            preference.setSummary(null);
            preference.setIntent(intent);
@@ -126,16 +127,18 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
                    }
                }
                final boolean isRoaming = mTelephonyManager.isNetworkRoaming();
                int wfcMode = mImsManager.getWfcMode(isRoaming && !useWfcHomeModeForRoaming);
                final int wfcMode = (isRoaming && !useWfcHomeModeForRoaming)
                        ? mImsMmTelManager.getVoWiFiRoamingModeSetting() :
                        mImsMmTelManager.getVoWiFiModeSetting();
                switch (wfcMode) {
                    case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
                    case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
                        resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
                        break;
                    case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
                    case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
                        resId = com.android.internal.R.string
                                .wfc_mode_cellular_preferred_summary;
                        break;
                    case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
                    case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
                        resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
                        break;
                    default:
@@ -150,14 +153,20 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont

    public WifiCallingPreferenceController init(int subId) {
        mSubId = subId;
        mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
        mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
                .createForSubscriptionId(mSubId);
        mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
        mImsMmTelManager = getImsMmTelManager(mSubId);
        mSimCallManager = mContext.getSystemService(TelecomManager.class)
                .getSimCallManagerForSubscription(mSubId);

        return this;
    }

    protected ImsMmTelManager getImsMmTelManager(int subId) {
        return ImsMmTelManager.createForSubscriptionId(subId);
    }

    private class PhoneCallStateListener extends PhoneStateListener {

        public PhoneCallStateListener(Looper looper) {
+49 −40
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ProvisioningManager;
import android.text.TextUtils;
import android.util.Log;
@@ -98,6 +99,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment

    private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private ImsManager mImsManager;
    private ImsMmTelManager mImsMmTelManager;
    private TelephonyManager mTelephonyManager;

    private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@@ -110,8 +112,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            final SettingsActivity activity = (SettingsActivity) getActivity();
            boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
            boolean isWfcEnabled = mSwitchBar.isChecked()
            final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
            final boolean isWfcEnabled = mSwitchBar.isChecked()
                    && isNonTtyOrTtyOnVolteEnabled;

            mSwitchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE)
@@ -132,12 +134,12 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
                }
            }

            Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
            final Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
            if (pref != null) {
                pref.setEnabled(isWfcEnabled && isWfcModeEditable
                        && (state == TelephonyManager.CALL_STATE_IDLE));
            }
            Preference pref_roam =
            final Preference pref_roam =
                    getPreferenceScreen().findPreference(BUTTON_WFC_ROAMING_MODE);
            if (pref_roam != null) {
                pref_roam.setEnabled(isWfcEnabled && isWfcRoamingModeEditable
@@ -151,7 +153,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
     */
    private final OnPreferenceClickListener mUpdateAddressListener =
            preference -> {
                Intent carrierAppIntent = getCarrierActivityIntent();
                final Intent carrierAppIntent = getCarrierActivityIntent();
                if (carrierAppIntent != null) {
                    carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_UPDATE);
                    startActivity(carrierAppIntent);
@@ -179,7 +181,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        mEmptyView = getView().findViewById(android.R.id.empty);
        setEmptyView(mEmptyView);
        final Resources res = getResourcesForSubId();
        String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
        final String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
                res.getString(R.string.wifi_calling_off_explanation_2));
        mEmptyView.setText(emptyViewText);

@@ -195,17 +197,17 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
    }

    private void showAlert(Intent intent) {
        Context context = getActivity();
        final Context context = getActivity();

        CharSequence title = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_TITLE);
        CharSequence message = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_MESSAGE);
        final CharSequence title = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_TITLE);
        final CharSequence message = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_MESSAGE);

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(message)
                .setTitle(title)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.ok, null);
        AlertDialog dialog = builder.create();
        final AlertDialog dialog = builder.create();
        dialog.show();
    }

@@ -214,7 +216,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
    private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            final String action = intent.getAction();
            if (action.equals(ImsManager.ACTION_IMS_REGISTRATION_ERROR)) {
                // If this fragment is active then we are immediately
                // showing alert on screen. There is no need to add
@@ -245,6 +247,11 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId));
    }

    @VisibleForTesting
    ImsMmTelManager getImsMmTelManager() {
        return ImsMmTelManager.createForSubscriptionId(mSubId);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -261,6 +268,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        }

        mImsManager = getImsManager();
        mImsMmTelManager = getImsMmTelManager();

        mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
                .createForSubscriptionId(mSubId);
@@ -288,12 +296,12 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View view = inflater.inflate(
        final View view = inflater.inflate(
                R.layout.wifi_calling_settings_preferences, container, false);

        final ViewGroup prefs_container = view.findViewById(R.id.prefs_container);
        Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
        View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
        final View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
        prefs_container.addView(prefs);

        return view;
@@ -307,12 +315,12 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
            return;
        }

        CarrierConfigManager configManager = (CarrierConfigManager)
        final CarrierConfigManager configManager = (CarrierConfigManager)
                getSystemService(Context.CARRIER_CONFIG_SERVICE);
        boolean isWifiOnlySupported = true;

        if (configManager != null) {
            PersistableBundle b = configManager.getConfigForSubId(mSubId);
            final PersistableBundle b = configManager.getConfigForSubId(mSubId);
            if (b != null) {
                mEditableWfcMode = b.getBoolean(
                        CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
@@ -341,11 +349,11 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment


        // NOTE: Buttons will be enabled/disabled in mPhoneStateListener
        boolean wfcEnabled = mImsManager.isWfcEnabledByUser()
        final boolean wfcEnabled = mImsManager.isWfcEnabledByUser()
                && mImsManager.isNonTtyOrTtyOnVolteEnabled();
        mSwitch.setChecked(wfcEnabled);
        int wfcMode = mImsManager.getWfcMode(false);
        int wfcRoamingMode = mImsManager.getWfcMode(true);
        final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
        final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
        mButtonWfcMode.setValue(Integer.toString(wfcMode));
        mButtonWfcRoamingMode.setValue(Integer.toString(wfcRoamingMode));
        updateButtonWfcMode(wfcEnabled, wfcMode, wfcRoamingMode);
@@ -369,7 +377,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment

        context.registerReceiver(mIntentReceiver, mIntentFilter);

        Intent intent = getActivity().getIntent();
        final Intent intent = getActivity().getIntent();
        if (intent.getBooleanExtra(Phone.EXTRA_KEY_ALERT_SHOW, false)) {
            showAlert(intent);
        }
@@ -392,7 +400,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        if (mValidListener) {
            mValidListener = false;

            TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            final TelephonyManager tm = (TelephonyManager)
                    getSystemService(Context.TELEPHONY_SERVICE);
            tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);

            mSwitchBar.removeOnSwitchChangeListener(this);
@@ -441,22 +450,22 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
     */
    private Intent getCarrierActivityIntent() {
        // Retrive component name from carrier config
        CarrierConfigManager configManager =
        final CarrierConfigManager configManager =
                getActivity().getSystemService(CarrierConfigManager.class);
        if (configManager == null) return null;

        PersistableBundle bundle = configManager.getConfigForSubId(mSubId);
        final PersistableBundle bundle = configManager.getConfigForSubId(mSubId);
        if (bundle == null) return null;

        String carrierApp = bundle.getString(
        final String carrierApp = bundle.getString(
                CarrierConfigManager.KEY_WFC_EMERGENCY_ADDRESS_CARRIER_APP_STRING);
        if (TextUtils.isEmpty(carrierApp)) return null;

        ComponentName componentName = ComponentName.unflattenFromString(carrierApp);
        final ComponentName componentName = ComponentName.unflattenFromString(carrierApp);
        if (componentName == null) return null;

        // Build and return intent
        Intent intent = new Intent();
        final Intent intent = new Intent();
        intent.setComponent(componentName);
        intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, mSubId);
        return intent;
@@ -469,8 +478,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        Log.i(TAG, "updateWfcMode(" + wfcEnabled + ")");
        mImsManager.setWfcSetting(wfcEnabled);

        int wfcMode = mImsManager.getWfcMode(false);
        int wfcRoamingMode = mImsManager.getWfcMode(true);
        final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting();
        final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
        updateButtonWfcMode(wfcEnabled, wfcMode, wfcRoamingMode);
        if (wfcEnabled) {
            mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), wfcMode);
@@ -496,7 +505,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
            case REQUEST_CHECK_WFC_DISCLAIMER:
                if (resultCode == Activity.RESULT_OK) {
                    // Call address management activity before turning on WFC
                    Intent carrierAppIntent = getCarrierActivityIntent();
                    final Intent carrierAppIntent = getCarrierActivityIntent();
                    if (carrierAppIntent != null) {
                        carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_ACTIVATE);
                        startActivityForResult(carrierAppIntent,
@@ -520,7 +529,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        mButtonWfcRoamingMode.setEnabled(wfcEnabled && mEditableWfcRoamingMode);

        final PreferenceScreen preferenceScreen = getPreferenceScreen();
        boolean updateAddressEnabled = (getCarrierActivityIntent() != null);
        final boolean updateAddressEnabled = (getCarrierActivityIntent() != null);
        if (wfcEnabled) {
            if (mEditableWfcMode) {
                preferenceScreen.addPreference(mButtonWfcMode);
@@ -551,24 +560,24 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        if (preference == mButtonWfcMode) {
            Log.d(TAG, "onPreferenceChange mButtonWfcMode " + newValue);
            mButtonWfcMode.setValue((String) newValue);
            int buttonMode = Integer.valueOf((String) newValue);
            int currentWfcMode = mImsManager.getWfcMode(false);
            final int buttonMode = Integer.valueOf((String) newValue);
            final int currentWfcMode = mImsMmTelManager.getVoWiFiModeSetting();
            if (buttonMode != currentWfcMode) {
                mImsManager.setWfcMode(buttonMode, false);
                mImsMmTelManager.setVoWiFiModeSetting(buttonMode);
                mButtonWfcMode.setSummary(getWfcModeSummary(buttonMode));
                mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), buttonMode);

                if (mUseWfcHomeModeForRoaming) {
                    mImsManager.setWfcMode(buttonMode, true);
                    mImsMmTelManager.setVoWiFiRoamingModeSetting(buttonMode);
                    // mButtonWfcRoamingMode.setSummary is not needed; summary is selected value
                }
            }
        } else if (preference == mButtonWfcRoamingMode) {
            mButtonWfcRoamingMode.setValue((String) newValue);
            int buttonMode = Integer.valueOf((String) newValue);
            int currentMode = mImsManager.getWfcMode(true);
            final int buttonMode = Integer.valueOf((String) newValue);
            final int currentMode = mImsMmTelManager.getVoWiFiRoamingModeSetting();
            if (buttonMode != currentMode) {
                mImsManager.setWfcMode(buttonMode, true);
                mImsMmTelManager.setVoWiFiRoamingModeSetting(buttonMode);
                // mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value.
                mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), buttonMode);
            }
@@ -580,13 +589,13 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
        int resId = com.android.internal.R.string.wifi_calling_off_summary;
        if (mImsManager.isWfcEnabledByUser()) {
            switch (wfcMode) {
                case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
                case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
                    resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
                    break;
                case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
                case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
                    resId = com.android.internal.R.string.wfc_mode_cellular_preferred_summary;
                    break;
                case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
                case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
                    resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
                    break;
                default:
+25 −18
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.PersistableBundle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsMmTelManager;
import android.text.TextUtils;
import android.util.Log;

@@ -233,6 +234,7 @@ public class WifiCallingSliceHelper {
        final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
                CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
        final ImsManager imsManager = getImsManager(subId);
        final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);

        if (!imsManager.isWfcEnabledByPlatform()
                || !imsManager.isWfcProvisionedOnDevice()) {
@@ -249,7 +251,7 @@ public class WifiCallingSliceHelper {
        int wfcMode = -1;
        try {
            isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
            wfcMode = getWfcMode(imsManager);
            wfcMode = getWfcMode(imsMmTelManager);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            Log.e(TAG, "Unable to get wifi calling preferred mode", e);
            return null;
@@ -279,7 +281,7 @@ public class WifiCallingSliceHelper {
            Uri sliceUri) {
        final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
        // Top row shows information on current preference state
        ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
        final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                .setAccentColor(Utils.getColorAccentDefaultColor(mContext));
        listBuilder.setHeader(new ListBuilder.HeaderBuilder()
                .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
@@ -294,18 +296,18 @@ public class WifiCallingSliceHelper {
            listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                    com.android.internal.R.string.wfc_mode_wifi_only_summary,
                    ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY,
                    currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
                    currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY));
        }

        listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                com.android.internal.R.string.wfc_mode_wifi_preferred_summary,
                ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED,
                currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED));
                currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED));

        listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                com.android.internal.R.string.wfc_mode_cellular_preferred_summary,
                ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED,
                currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
                currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));

        return listBuilder.build();
    }
@@ -337,13 +339,13 @@ public class WifiCallingSliceHelper {
     */
    private CharSequence getWifiCallingPreferenceSummary(int wfcMode) {
        switch (wfcMode) {
            case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
            case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
                return mContext.getText(
                        com.android.internal.R.string.wfc_mode_wifi_only_summary);
            case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
            case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
                return mContext.getText(
                        com.android.internal.R.string.wfc_mode_wifi_preferred_summary);
            case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
            case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
                return mContext.getText(
                        com.android.internal.R.string.wfc_mode_cellular_preferred_summary);
            default:
@@ -355,15 +357,19 @@ public class WifiCallingSliceHelper {
        return ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId));
    }

    private int getWfcMode(ImsManager imsManager)
    protected ImsMmTelManager getImsMmTelManager(int subId) {
        return ImsMmTelManager.createForSubscriptionId(subId);
    }

    private int getWfcMode(ImsMmTelManager imsMmTelManager)
            throws InterruptedException, ExecutionException, TimeoutException {
        FutureTask<Integer> wfcModeTask = new FutureTask<>(new Callable<Integer>() {
        final FutureTask<Integer> wfcModeTask = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() {
                return imsManager.getWfcMode(false);
                return imsMmTelManager.getVoWiFiModeSetting();
            }
        });
        ExecutorService executor = Executors.newSingleThreadExecutor();
        final ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(wfcModeTask);
        return wfcModeTask.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    }
@@ -420,7 +426,7 @@ public class WifiCallingSliceHelper {
            final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
                    CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);

            ImsManager imsManager = getImsManager(subId);
            final ImsManager imsManager = getImsManager(subId);
            if (isWifiCallingPrefEditable
                    && imsManager.isWfcEnabledByPlatform()
                    && imsManager.isWfcProvisionedOnDevice()
@@ -428,25 +434,26 @@ public class WifiCallingSliceHelper {
                    && 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);
                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 = ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
                            newValue = ImsMmTelManager.WIFI_MODE_WIFI_ONLY;
                        }
                        break;
                    case ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED:
                        newValue = ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED;
                        newValue = ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED;
                        break;
                    case ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED:
                        newValue = ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
                        newValue = ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED;
                        break;
                }
                if (newValue != errorValue && newValue != currentValue) {
                    // Update the setting only when there is a valid update
                    imsManager.setWfcMode(newValue, false);
                    imsMmTelManager.setVoWiFiModeSetting(newValue);
                }
            }
        }
+22 −15

File changed.

Preview size limit exceeded, changes collapsed.

+24 −24

File changed.

Preview size limit exceeded, changes collapsed.

Loading