Replace some configs with CarrierConfig

Replace the following config with CarrierConfig
- config_enabled_lte
- config_support_tdscdma
- config_support_tdscdma_on_roaming_networks
- carrier settings activity package/class name

Bug: 115429501
Test: make -j40 ROBOTEST_FILTER=telephony RunSettingsRoboTests
Change-Id: I3d973f926813c01fff6fcff50b3392c4eff69eb8
This commit is contained in:
Pengquan Meng
2018-11-05 14:01:11 -08:00
parent 92792ee806
commit b8d59fc9f8
5 changed files with 22 additions and 41 deletions

View File

@@ -136,12 +136,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>

View File

@@ -10187,9 +10187,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] -->

View File

@@ -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(

View File

@@ -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) {
@@ -413,4 +404,4 @@ public class MobileNetworkUtils {
}
return false;
}
}
}

View File

@@ -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);