aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJing Zhao <zhaojing@motorola.com>2021-03-15 18:16:51 -0500
committerJing Zhao <zhaojing@motorola.com>2021-03-18 14:01:55 -0500
commit015de26ab25aa8bd96e51fb050dd93d4c9319fa5 (patch)
treeef5bfe2c73b41660d1719679d5c43e54223d4fb2
parent0a2c3b9ec4337283b67391971613cd06690a2d34 (diff)
downloadplatform_tools_carrier_settings-015de26ab25aa8bd96e51fb050dd93d4c9319fa5.tar.gz
platform_tools_carrier_settings-015de26ab25aa8bd96e51fb050dd93d4c9319fa5.tar.bz2
platform_tools_carrier_settings-015de26ab25aa8bd96e51fb050dd93d4c9319fa5.zip
Add carrier config for not reusing MNO APNs for MVNOs
In case we do not need any APN for a MVNO, config carriersettingstool.no_apn_for_mvno_bool to change the default tool behavior Change-Id: Ib42e577ac8695206c345883e0a7b3f24d7a4e028
-rw-r--r--README5
-rw-r--r--python/update_carrier_data.py23
2 files changed, 28 insertions, 0 deletions
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/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.