aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp16
-rw-r--r--README5
-rw-r--r--java/CarrierConfigConverterV2.java36
-rw-r--r--java/GenDeviceSettings.java2
-rw-r--r--main.sh6
-rw-r--r--proto/carrier_settings.proto1
-rw-r--r--python/update_apn.py1
-rw-r--r--python/update_carrier_data.py23
8 files changed, 55 insertions, 35 deletions
diff --git a/Android.bp b/Android.bp
index 2ae42ad..350af13 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
python_binary_host {
name: "update_apn",
main: "python/update_apn.py",
@@ -62,11 +66,13 @@ java_binary_host {
canonical_path_from_root: false,
},
plugins: [
- "dagger2-auto-value",
+ "auto_value_plugin",
+ ],
+ libs: [
+ "auto_value_annotations",
],
static_libs: [
- "dagger2-auto-value",
- "guava-21.0",
+ "guava",
"jcommander",
"libprotobuf-java-full",
],
@@ -85,7 +91,7 @@ java_binary_host {
canonical_path_from_root: false,
},
static_libs: [
- "guava-21.0",
+ "guava",
"jcommander",
"libprotobuf-java-full",
],
@@ -104,7 +110,7 @@ java_binary_host {
canonical_path_from_root: false,
},
static_libs: [
- "guava-21.0",
+ "guava",
"jcommander",
"libprotobuf-java-full",
],
diff --git a/README b/README
index a189be7..60fc7ec 100644
--- a/README
+++ b/README
@@ -14,3 +14,8 @@ The commands above build the tool from source code and run them.
This tool is best supported on Android 11 code base. See additional steps
in bin/README.md run it on Android 10.
+
+Usually, if a MVNO has no APN defined in xml, the tool will use APNs of the corresponding MNO,
+based on MCC/MNC values. However, a CarrierConfig carriersettingstool.no_apn_for_mvno_bool
+can be set as true to avoid such copying in conversion tool.
+carriersettingstool.no_apn_for_mvno_bool will also be removed from final config by the tool.
diff --git a/java/CarrierConfigConverterV2.java b/java/CarrierConfigConverterV2.java
index 830bb3c..cca6462 100644
--- a/java/CarrierConfigConverterV2.java
+++ b/java/CarrierConfigConverterV2.java
@@ -102,10 +102,6 @@ public final class CarrierConfigConverterV2 {
@Parameter(names = "--version", description = "The version number for all output textpb.")
private long version = 1L;
- // For configs in vendor.xml w/o mcc/mnc, they are the default config values for all carriers.
- // In CarrierSettings, a special mcc/mnc "000000" is used to look up default config.
- private static final String MCCMNC_FOR_DEFAULT_SETTINGS = "000000";
-
// Resource file path to the AOSP carrier list file
private static final String RESOURCE_CARRIER_LIST =
"/assets/latest_carrier_id/carrier_list.textpb";
@@ -242,18 +238,11 @@ public final class CarrierConfigConverterV2 {
// Then, try to parse CarrierId
CarrierId.Builder id = parseCarrierId(element);
// A valid mccmnc is 5- or 6-digit. But vendor.xml see special cases below:
- // Case 1: a <carrier_config> element may have neither "mcc" nor "mnc".
- // Such a tag provides a base config value for all carriers. CarrierSettings uses
- // mcc/mnc 000/000 to identify that, and does the merge at run time instead of
- // build time (which is now).
- // Case 2: a <carrier_config> element may have just "mcc" and not "mnc" for
+ // <carrier_config> element may have just "mcc" and not "mnc" for
// country-wise config. Such a element doesn't make a carrier; but still keep it so
// can be used if a mccmnc appears in APNs later.
- if (id.getMccMnc().isEmpty()) {
- // special case 1
- carriers.add(id.setMccMnc(MCCMNC_FOR_DEFAULT_SETTINGS).build());
- } else if (id.getMccMnc().length() == 3) {
- // special case 2
+ if (id.getMccMnc().length() == 3) {
+ // special case
carriers.add(id.build());
} else if (id.getMccMnc().length() == 5 || id.getMccMnc().length() == 6) {
// Normal mcc+mnc
@@ -554,7 +543,7 @@ public final class CarrierConfigConverterV2 {
Document xmlDoc, CarrierIdentifier carrier) throws IOException {
HashMap<String, CarrierConfig.Config> configMap = new HashMap<>();
for (Element element : getElementsByTagName(xmlDoc, TAG_CARRIER_CONFIG)) {
- if (carrier != null && !checkFilters(false, element, carrier)) {
+ if (carrier != null && !checkFilters(element, carrier)) {
continue;
}
configMap.putAll(parseCarrierConfigToMap(element));
@@ -572,7 +561,7 @@ public final class CarrierConfigConverterV2 {
Document xmlDoc, CarrierIdentifier carrier) throws IOException {
HashMap<String, CarrierConfig.Config> configMap = new HashMap<>();
for (Element element : getElementsByTagName(xmlDoc, TAG_CARRIER_CONFIG)) {
- if (carrier != null && !checkFilters(true, element, carrier)) {
+ if (carrier != null && !checkFilters(element, carrier)) {
continue;
}
configMap.putAll(parseCarrierConfigToMap(element));
@@ -636,6 +625,9 @@ public final class CarrierConfigConverterV2 {
Element eElement = (Element) nNode;
String key = eElement.getAttribute("name");
String value = String.valueOf(eElement.getTextContent());
+ if (value.isEmpty()) {
+ value = eElement.getAttribute("value");
+ }
configMap.put(key, CarrierConfig.Config.newBuilder().setTextValue(value).build());
}
// text array
@@ -692,17 +684,7 @@ public final class CarrierConfigConverterV2 {
*
* <p>Copied from AOSP DefaultCarrierConfigService.
*/
- private static boolean checkFilters(boolean isVendorXml, Element element, CarrierIdentifier id) {
- // Special case: in vendor.xml, the <carrier_config> element w/o mcc/mnc provides a base config
- // value for all carriers. CarrierSettings uses mcc/mnc 000/000 to identify that, and does the
- // merge at run time instead of build time (which is now).
- // Hence, such an element should only match 000/000.
- if (isVendorXml
- && !element.hasAttribute("mcc")
- && !element.hasAttribute("mnc")
- && !element.hasAttribute("cid")) {
- return MCCMNC_FOR_DEFAULT_SETTINGS.equals(id.getMcc() + id.getMnc());
- }
+ private static boolean checkFilters(Element element, CarrierIdentifier id) {
boolean result = true;
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
diff --git a/java/GenDeviceSettings.java b/java/GenDeviceSettings.java
index 33d3a73..20c6458 100644
--- a/java/GenDeviceSettings.java
+++ b/java/GenDeviceSettings.java
@@ -57,7 +57,7 @@ public class GenDeviceSettings {
@Parameter(
names = "--device_setting_dir",
- description = "The path to putput <deice>_settings directory.")
+ description = "The path to output <device>_settings directory.")
private String deviceSettingDirName = "/tmp/muskie_setting";
@Parameter(
diff --git a/main.sh b/main.sh
index ed68108..0ee351c 100644
--- a/main.sh
+++ b/main.sh
@@ -53,10 +53,12 @@ cp $INPUT_APNS_XML_FILE "$TMP_DIR"/apns-full-conf.xml > /dev/null
# 2c. Convert XMLs to TEXTPB
-# DO NOT change the EPOCH date. It's used by CarrierSettings server.
EPOCH=$(date -d '2018-06-01T00:00:00Z' +%s)
NOW=$(date +%s)
TIMESTAMP="$((NOW-EPOCH))"
+# Use TIMESTAMP as version number
+# To customize the version number, assign the customized value to VERSION.
+VERSION="$TIMESTAMP"
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
UPDATE_APN=$SCRIPT_DIR/bin/update_apn
@@ -71,7 +73,7 @@ out/host/linux-x86/bin/CarrierConfigConverterV2 \
--output_dir="$TMP_DIR"/data \
--vendor_xml="$TMP_DIR"/vendor.xml \
--assets="$ASSETS_DIR"/ \
- --version=$TIMESTAMP > /dev/null
+ --version=$VERSION > /dev/null
"$UPDATE_APN" \
--apn_file="$TMP_DIR"/apns-full-conf.xml \
--data_dir="$TMP_DIR"/data \
diff --git a/proto/carrier_settings.proto b/proto/carrier_settings.proto
index e9f81cd..1a8a77f 100644
--- a/proto/carrier_settings.proto
+++ b/proto/carrier_settings.proto
@@ -79,6 +79,7 @@ message ApnItem {
EMERGENCY = 10;
XCAP = 11;
UT = 12;
+ RCS = 13;
}
repeated ApnType type = 3;
diff --git a/python/update_apn.py b/python/update_apn.py
index 67e6e0f..0ee32aa 100644
--- a/python/update_apn.py
+++ b/python/update_apn.py
@@ -140,6 +140,7 @@ APN_TYPE_MAP = {
'emergency': carrier_settings_pb2.ApnItem.EMERGENCY,
'xcap': carrier_settings_pb2.ApnItem.XCAP,
'ut': carrier_settings_pb2.ApnItem.UT,
+ 'rcs': carrier_settings_pb2.ApnItem.RCS,
}
diff --git a/python/update_carrier_data.py b/python/update_carrier_data.py
index 74eee78..631e54b 100644
--- a/python/update_carrier_data.py
+++ b/python/update_carrier_data.py
@@ -292,6 +292,9 @@ def add_apns_for_other_carriers_by_mccmnc(apns, tier1_carriers, other_carriers):
Modifies others.textpb file in-place.
+ If a carriersettingstool.no_apn_for_mvno_bool is defined as true for a MVNO,
+ the APNs from the corresponding MNO(by MCC/MNC) will not be used.
+
Args:
apns: a list of CarrierSettings message with APNs only.
tier1_carriers: parsed tier-1 carriers list; must not contain new carriers.
@@ -314,6 +317,15 @@ def add_apns_for_other_carriers_by_mccmnc(apns, tier1_carriers, other_carriers):
if not setting.HasField('apns'):
carrier_id = to_carrier_id(setting.canonical_name)
if carrier_id.HasField('mvno_data'):
+ # in case we don't need MNO APN for this MVNO
+ skip_mno_apn = False
+ if setting.HasField('configs'):
+ for conf in setting.configs.config:
+ if conf.key == 'carriersettingstool.no_apn_for_mvno_bool':
+ skip_mno_apn = conf.bool_value
+ break
+ if skip_mno_apn:
+ continue
carrier_id.ClearField('mvno_data')
carrier_id_str_of_mccmnc = to_string(carrier_id)
cname_of_mccmnc = tier1_carriers.get(
@@ -324,9 +336,20 @@ def add_apns_for_other_carriers_by_mccmnc(apns, tier1_carriers, other_carriers):
if apn:
setting.apns.CopyFrom(apn.apns)
+ sanitise_carrier_config(others.setting)
+
with open(others_textpb, 'w', encoding='utf-8') as others_textpb_file:
text_format.PrintMessage(others, others_textpb_file, as_utf8=True)
+def sanitise_carrier_config(setting):
+ """Remove temparary carrier config items that's only used for conversion tool"""
+ for carrier_setting in setting:
+ if carrier_setting.HasField('configs'):
+ configs = carrier_setting.configs.config[:]
+ del carrier_setting.configs.config[:]
+ for config in configs:
+ if not config.key.startswith('carriersettingstool.'):
+ carrier_setting.configs.config.append(config)
def add_carrierconfig_for_new_carriers(cnames, tier1_carriers, other_carriers):
"""Add carrier configs for new (non-tier-1) carriers.