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

Commit 92e8a5d8 authored by Pengquan Meng's avatar Pengquan Meng Committed by Android (Google) Code Review
Browse files

Merge "Replace some configs with CarrierConfig"

parents 08d8ed80 b8d59fc9
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -142,12 +142,4 @@

    <!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
    <bool name="config_force_rounded_icon_TopLevelSettings">true</bool>

    <!-- TODO(b/115429501): move those 3 configs to framework-->
    <!-- Show enabled lte option for lte device -->
    <bool name="config_enabled_lte" translatable="false">false</bool>
    <!-- Show enabled tdscdma option for device -->
    <bool name="config_support_tdscdma" translatable="false">false</bool>
    <!-- Show enabled tdscdma option for device when connect roaming network -->
    <string-array name="config_support_tdscdma_roaming_on_networks" translatable="false"></string-array>
</resources>
+0 −3
Original line number Diff line number Diff line
@@ -10173,9 +10173,6 @@
    <!-- Text for Network global [CHAR LIMIT=NONE] -->
    <string name="network_global">Global</string>
    <!-- Configuration setting for world mode Format is <true;GID if any to be checked> [CHAR LIMIT=NONE] -->
    <string translatable="false" name="config_world_mode"/>
    <!-- Available networks screen title/heading [CHAR LIMIT=NONE] -->
    <string name="label_available">Available networks</string>
    <!-- Mobile network settings screen, toast when searching for available networks [CHAR LIMIT=NONE] -->
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class EnabledNetworkModePreferenceController extends BasePreferenceContro
                preference.setEntryValues(
                        R.array.enabled_networks_tdscdma_values);
            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
                    && !resources.getBoolean(R.bool.config_enabled_lte)) {
                    && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
                preference.setEntries(R.array.enabled_networks_except_gsm_lte_choices);
                preference.setEntryValues(R.array.enabled_networks_except_gsm_lte_values);
            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
@@ -190,7 +190,7 @@ public class EnabledNetworkModePreferenceController extends BasePreferenceContro
                preference.setEntries(select);
                preference.setEntryValues(
                        R.array.enabled_networks_except_gsm_values);
            } else if (!resources.getBoolean(R.bool.config_enabled_lte)) {
            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
                preference.setEntries(
                        R.array.enabled_networks_except_lte_choices);
                preference.setEntryValues(
+18 −27
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.database.Cursor;
import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.provider.Settings;
import android.service.carrier.CarrierMessagingService;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
@@ -329,28 +330,11 @@ public class MobileNetworkUtils {
     * settings
     */
    public static boolean isWorldMode(Context context, int subId) {
        final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
                .createForSubscriptionId(subId);
        boolean worldModeOn = false;
        final String configString = context.getString(R.string.config_world_mode);

        if (!TextUtils.isEmpty(configString)) {
            String[] configArray = configString.split(";");
            // Check if we have World mode configuration set to True only or config is set to True
            // and SIM GID value is also set and matches to the current SIM GID.
            if (configArray != null &&
                    ((configArray.length == 1 && configArray[0].equalsIgnoreCase("true"))
                            || (configArray.length == 2 && !TextUtils.isEmpty(configArray[1])
                            && telephonyManager != null
                            && configArray[1].equalsIgnoreCase(
                            telephonyManager.getGroupIdLevel1())))) {
                worldModeOn = true;
            }
        }

        Log.d(TAG, "isWorldMode=" + worldModeOn);

        return worldModeOn;
        final PersistableBundle carrierConfig = context.getSystemService(
                CarrierConfigManager.class).getConfigForSubId(subId);
        return carrierConfig == null
                ? false
                : carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL);
    }

    /**
@@ -396,14 +380,21 @@ public class MobileNetworkUtils {

    //TODO(b/117651939): move it to telephony
    private static boolean isTdscdmaSupported(Context context, TelephonyManager telephonyManager) {
        if (context.getResources().getBoolean(R.bool.config_support_tdscdma)) {
        final PersistableBundle carrierConfig = context.getSystemService(
                CarrierConfigManager.class).getConfig();

        if (carrierConfig == null) {
            return false;
        }

        if (carrierConfig.getBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL)) {
            return true;
        }

        String operatorNumeric = telephonyManager.getServiceState().getOperatorNumeric();
        String[] numericArray = context.getResources().getStringArray(
                R.array.config_support_tdscdma_roaming_on_networks);
        if (numericArray.length == 0 || operatorNumeric == null) {
        String[] numericArray = carrierConfig.getStringArray(
                CarrierConfigManager.KEY_SUPPORT_TDSCDMA_ROAMING_NETWORKS_STRING_ARRAY);
        if (numericArray == null || operatorNumeric == null) {
            return false;
        }
        for (String numeric : numericArray) {
+2 −1
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ public class MobileNetworkUtilsTest {
    @Test
    public void isCdmaOptions_worldModeWithGsmWcdma_returnTrue() {
        when(mTelephonyManager.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_GSM);
        when(mContext.getString(R.string.config_world_mode)).thenReturn("true");
        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);

        Settings.Global.putInt(mContext.getContentResolver(),
                android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
                TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);