diff options
author | Meng Wang <mewan@google.com> | 2021-04-30 20:40:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-30 20:40:23 +0000 |
commit | 29bb818b42ea6f0ea7ff88a203476d8e4a1b9a5a (patch) | |
tree | 3e2138982cecd7057a274f1b6ddaee6622ed7681 | |
parent | b2ac9e97b001ee8fcd51d036c057b07b42ad08e4 (diff) | |
parent | 5dd439e18dafecd9336b67e758a55b6c17cf7753 (diff) | |
download | carrier_settings-29bb818b42ea6f0ea7ff88a203476d8e4a1b9a5a.tar.gz |
Align the handling of no-mcc-mnc configs in vendor.xml with carrierconfig app am: 4fc47e4a1f am: 5dd439e18d
Original change: https://android-review.googlesource.com/c/platform/tools/carrier_settings/+/1690689
Change-Id: Ie233cd0049a2cdfe83a7b62eb4fe5bd631dee80f
-rw-r--r-- | java/CarrierConfigConverterV2.java | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/java/CarrierConfigConverterV2.java b/java/CarrierConfigConverterV2.java index 58a3848..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)); @@ -695,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++) { |