AndroidQ版本中包含了定制可选网络模式的代码:
packages/apps/Settings/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
private void updatePreferenceEntries(ListPreference preference) {
..
Resources resource = SubscriptionManager.getResourcesForSubId(mContext, mSubId);
boolean carrierCustomize = resource.getBoolean(R.bool.config_carrier_customize_network);
if (carrierCustomize) {
preference.setEntries(R.array.carrier_customize_network_choices);
preference.setEntryValues(R.array.carrier_customize_network_values);
}
可以参考packages/apps/Settings/res/values-mcc724-mnc10/这个配置 1.packages/apps/Settings/res/values-mcc724-mnc10/config.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<bool name="config_carrier_customize_network" translatable="false">true</bool>
</resources>
2.packages/apps/Settings/res/values-mcc724-mnc10/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array translatable="false" name="carrier_customize_network_choices">
<item>@string/network_4g_auto</item>
<item>@string/network_3G_auto</item>
<item>@string/network_2G_only</item>
<item>@string/network_4G_only</item>
<item>@string/network_3G_only</item>
</string-array>
<string-array translatable="false" name="carrier_customize_network_values">
<item>"9"</item>
<item>"0"</item>
<item>"1"</item>
<item>"11"</item>
<item>"2"</item>
</string-array>
</resources>
对应value定义在
frameworks/base/telephony/java/com/android/internal/telephony/RILConstants.java
/** LTE only mode*/
int NETWORK_MODE_LTE_ONLY = 11;
|