mirror of https://github.com/CalyxOS/scripts
Import carriersettings-extractor
Repo: https://github.com/daradib/carriersettings-extractor Commit: 6e6217b5fc74129b8d1ba6671a48388f5f55e009 "Add license" Change-Id: Ibbbccedd5e118e66f7e681dd2f8c8d69e6484a87
This commit is contained in:
parent
c1fa3c5059
commit
5257dc3e45
|
@ -0,0 +1,9 @@
|
|||
apns-full-conf.xml
|
||||
carrier_list.pb
|
||||
CarrierSettings/*.pb
|
||||
tmp*/
|
||||
vendor.xml
|
||||
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
|
@ -0,0 +1,29 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2020, Dara Adib
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,14 @@
|
|||
TARGETS := carriersettings_pb2.py vendor/carrierId_pb2.py vendor/carrierId.proto
|
||||
|
||||
.PHONY: all clean
|
||||
all: $(TARGETS)
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
||||
|
||||
%_pb2.py: %.proto
|
||||
protoc --python_out=. $<
|
||||
|
||||
vendor/carrierId.proto:
|
||||
wget -qO- \
|
||||
https://android.googlesource.com/platform/frameworks/opt/telephony/+/refs/heads/master/proto/src/carrierId.proto?format=TEXT | \
|
||||
base64 --decode > $@
|
|
@ -0,0 +1,43 @@
|
|||
# carriersettings-extractor
|
||||
|
||||
Android Open Source Project (AOSP) [includes](https://source.android.com/devices/tech/config/update) APN settings ([`apns-full-conf.xml`](https://android.googlesource.com/device/sample/+/master/etc/apns-full-conf.xml)) and [carrier settings](https://source.android.com/devices/tech/config/carrier) ([`carrier_config_*.xml`](https://android.googlesource.com/platform/packages/apps/CarrierConfig/+/master/assets) + [`vendor.xml`](https://android.googlesource.com/platform/packages/apps/CarrierConfig/+/refs/heads/master/res/xml/vendor.xml)) in human-readable XML format. However, Google Pixel device images instead include APN and carrier settings as binary protobuf files for use by the CarrierSettings system app.
|
||||
|
||||
This script converts the CarrierSettings protobuf files (e.g., `carrier_list.pb`, `others.pb`) to XML format compatible with AOSP. This may be helpful for Android-based systems that do not bundle CarrierSettings, but wish to support carriers that are not included in AOSP.
|
||||
|
||||
For a description of each APN and carrier setting, refer to the doc comments in [`Telephony.java`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/provider/Telephony.java) and [`CarrierConfigManager.java`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/telephony/java/android/telephony/CarrierConfigManager.java), respectively.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* curl - required, for android-prepare-vendor
|
||||
* e2fsprogs (debugfs) - required, for android-prepare-vendor
|
||||
* git - required, for android-prepare-vendor
|
||||
* protobuf-compiler (protoc) - optional, see below
|
||||
* python3-protobuf - required
|
||||
|
||||
## Usage
|
||||
|
||||
Download the [carrier ID database](https://source.android.com/devices/tech/config/carrierid) from AOSP.
|
||||
|
||||
./download_carrier_list.sh
|
||||
|
||||
Download a [Pixel factory image](https://developers.google.com/android/images) and extract the CarrierSettings protobuf files. This script will download android-prepare-vendor and copy the directory `CarrierSettings` containing the protobuf files.
|
||||
|
||||
DEVICE=crosshatch BUILD=QQ3A.200605.001 ./download_factory_img.sh
|
||||
|
||||
Convert `CarrierSettings/*.pb` to `apns-full-conf.xml` and `vendor.xml`.
|
||||
|
||||
./carriersettings_extractor.py CarrierSettings
|
||||
|
||||
## Protobuf definitions
|
||||
|
||||
The definitions in [`carriersettings.proto`](carriersettings.proto) are useful for inspecting the CarrierSettings protobuf files.
|
||||
|
||||
protoc --decode=CarrierList carriersettings.proto < CarrierSettings/carrier_list.pb
|
||||
protoc --decode=CarrierSettings carriersettings.proto < CarrierSettings/verizon_us.pb
|
||||
protoc --decode=MultiCarrierSettings carriersettings.proto < CarrierSettings/others.pb
|
||||
|
||||
To check schema or otherwise inspect the protobuf files without applying definitions, use the `--decode_raw` argument.
|
||||
|
||||
protoc --decode_raw < CarrierSettings/carrier_list.pb
|
||||
protoc --decode_raw < CarrierSettings/verizon_us.pb
|
||||
protoc --decode_raw < CarrierSettings/others.pb
|
|
@ -0,0 +1,125 @@
|
|||
// For the HasField method, use proto2. proto3 does not distinguish between
|
||||
// fields that are not set and fields that are set to default values, e.g.,
|
||||
// authtype: 0.
|
||||
syntax = "proto2";
|
||||
|
||||
message CarrierList {
|
||||
message CarrierMap {
|
||||
// canonicalName is not unique in CarrierList, e.g., the same settings
|
||||
// may apply to multiple MCCMNCs or MVNOs. Use this field as the lookup
|
||||
// key in CarrierSettings.
|
||||
required string canonicalName = 1;
|
||||
message CarrierId {
|
||||
required string mccMnc = 1;
|
||||
oneof mvno {
|
||||
string spn = 2;
|
||||
string imsi = 3;
|
||||
string gid1 = 4;
|
||||
string gid2 = 5; // deprecated
|
||||
}
|
||||
}
|
||||
required CarrierId carrierId = 2;
|
||||
}
|
||||
repeated CarrierMap entry = 1;
|
||||
required int64 version = 2;
|
||||
}
|
||||
|
||||
message CarrierSettings {
|
||||
required string canonicalName = 1; // unique key
|
||||
optional int64 version = 2;
|
||||
|
||||
message CarrierApns {
|
||||
message ApnItem {
|
||||
optional string name = 1;
|
||||
required string value = 2;
|
||||
enum ApnType {
|
||||
ALL = 0;
|
||||
DEFAULT = 1;
|
||||
MMS = 2;
|
||||
SUPL = 3;
|
||||
DUN = 4;
|
||||
HIPRI = 5;
|
||||
FOTA = 6;
|
||||
IMS = 7;
|
||||
CBS = 8;
|
||||
IA = 9;
|
||||
EMERGENCY = 10;
|
||||
XCAP = 11;
|
||||
UT = 12;
|
||||
}
|
||||
repeated ApnType type = 3;
|
||||
optional string bearerBitmask = 4;
|
||||
optional string server = 5;
|
||||
optional string proxy = 6;
|
||||
optional string port = 7;
|
||||
optional string user = 8;
|
||||
optional string password = 9;
|
||||
optional int32 authtype = 10;
|
||||
optional string mmsc = 11;
|
||||
optional string mmscProxy = 12;
|
||||
optional string mmscProxyPort = 13;
|
||||
enum Protocol {
|
||||
IP = 0;
|
||||
IPV6 = 1;
|
||||
IPV4V6 = 2;
|
||||
PPP = 3;
|
||||
}
|
||||
optional Protocol protocol = 14;
|
||||
optional Protocol roamingProtocol = 15;
|
||||
optional int32 mtu = 16;
|
||||
optional int32 profileId = 17;
|
||||
optional int32 maxConns = 18;
|
||||
optional int32 waitTime = 19; // unused
|
||||
optional int32 maxConnsTime = 20;
|
||||
optional bool carrierEnabled = 21;
|
||||
optional bool modemCognitive = 22;
|
||||
optional bool userVisible = 23;
|
||||
optional bool userEditable = 24;
|
||||
optional int32 apnSetId = 25; // unused
|
||||
enum Xlat {
|
||||
SKIP_464XLAT_DEFAULT = 0;
|
||||
SKIP_464XLAT_DISABLE = 1;
|
||||
SKIP_464XLAT_ENABLE = 2;
|
||||
}
|
||||
optional Xlat skip464Xlat = 26; // unused
|
||||
}
|
||||
repeated ApnItem apn = 2;
|
||||
}
|
||||
optional CarrierApns apns = 3;
|
||||
|
||||
message CarrierConfig {
|
||||
message Config {
|
||||
required string key = 1;
|
||||
message TextArray {
|
||||
repeated string item = 1;
|
||||
}
|
||||
message IntArray {
|
||||
repeated int32 item = 1;
|
||||
}
|
||||
oneof value {
|
||||
string textValue = 2;
|
||||
int32 intValue = 3;
|
||||
int64 longValue = 4;
|
||||
bool boolValue = 5;
|
||||
TextArray textArray = 6;
|
||||
IntArray intArray = 7;
|
||||
}
|
||||
}
|
||||
repeated Config config = 2;
|
||||
}
|
||||
optional CarrierConfig configs = 4;
|
||||
|
||||
message VendorConfigs {
|
||||
message VendorConfigClient {
|
||||
required string name = 1;
|
||||
required bytes value = 2;
|
||||
}
|
||||
repeated VendorConfigClient client = 2;
|
||||
}
|
||||
optional VendorConfigs vendorConfigs = 5;
|
||||
}
|
||||
|
||||
message MultiCarrierSettings {
|
||||
required int64 version = 1;
|
||||
repeated CarrierSettings setting = 2;
|
||||
}
|
|
@ -0,0 +1,297 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from collections import OrderedDict
|
||||
from glob import glob
|
||||
from itertools import product
|
||||
import os.path
|
||||
import sys
|
||||
from xml.etree import ElementTree as ET
|
||||
from xml.sax.saxutils import escape, quoteattr
|
||||
|
||||
from carriersettings_pb2 import CarrierList, CarrierSettings, \
|
||||
MultiCarrierSettings
|
||||
from vendor.carrierId_pb2 import CarrierList as CarrierIdList
|
||||
|
||||
pb_path = sys.argv[1]
|
||||
|
||||
carrier_id_list = CarrierIdList()
|
||||
carrier_attribute_map = {}
|
||||
with open('carrier_list.pb', 'rb') as pb:
|
||||
carrier_id_list.ParseFromString(pb.read())
|
||||
for carrier_id_obj in carrier_id_list.carrier_id:
|
||||
for carrier_attribute in carrier_id_obj.carrier_attribute:
|
||||
for carrier_attributes in product(*(
|
||||
(s.lower() for s in getattr(carrier_attribute, i) or [''])
|
||||
for i in [
|
||||
'mccmnc_tuple', 'imsi_prefix_xpattern', 'spn', 'plmn',
|
||||
'gid1', 'gid2', 'preferred_apn', 'iccid_prefix',
|
||||
'privilege_access_rule',
|
||||
]
|
||||
)):
|
||||
carrier_attribute_map[carrier_attributes] = \
|
||||
carrier_id_obj.canonical_id
|
||||
|
||||
carrier_list = CarrierList()
|
||||
all_settings = {}
|
||||
for filename in glob(os.path.join(pb_path, '*.pb')):
|
||||
with open(filename, 'rb') as pb:
|
||||
if os.path.basename(filename) == 'carrier_list.pb':
|
||||
carrier_list.ParseFromString(pb.read())
|
||||
elif os.path.basename(filename) == 'others.pb':
|
||||
settings = MultiCarrierSettings()
|
||||
settings.ParseFromString(pb.read())
|
||||
for setting in settings.setting:
|
||||
assert setting.canonicalName not in all_settings
|
||||
all_settings[setting.canonicalName] = setting
|
||||
else:
|
||||
setting = CarrierSettings()
|
||||
setting.ParseFromString(pb.read())
|
||||
assert setting.canonicalName not in all_settings
|
||||
all_settings[setting.canonicalName] = setting
|
||||
|
||||
|
||||
# Unfortunately, python processors like xml and lxml, as well as command-line
|
||||
# utilities like tidy, do not support the exact style used by AOSP for
|
||||
# apns-full-conf.xml:
|
||||
#
|
||||
# * indent: 2 spaces
|
||||
# * attribute indent: 4 spaces
|
||||
# * blank lines between elements
|
||||
# * attributes after first indented on separate lines
|
||||
# * closing tags of multi-line elements on separate, unindented lines
|
||||
#
|
||||
# Therefore, we build the file without using an XML processor.
|
||||
|
||||
|
||||
class ApnElement:
|
||||
def __init__(self, apn, carrier_id):
|
||||
self.apn = apn
|
||||
self.carrier_id = carrier_id
|
||||
self.attributes = OrderedDict()
|
||||
self.add_attributes()
|
||||
|
||||
def add_attribute(self, key, field=None, value=None):
|
||||
if value is not None:
|
||||
self.attributes[key] = value
|
||||
else:
|
||||
if field is None:
|
||||
field = key
|
||||
if self.apn.HasField(field):
|
||||
enum_type = self.apn.DESCRIPTOR.fields_by_name[field].enum_type
|
||||
value = getattr(self.apn, field)
|
||||
if enum_type is None:
|
||||
if isinstance(value, bool):
|
||||
self.attributes[key] = str(value).lower()
|
||||
else:
|
||||
self.attributes[key] = str(value)
|
||||
else:
|
||||
self.attributes[key] = \
|
||||
enum_type.values_by_number[value].name
|
||||
|
||||
def add_attributes(self):
|
||||
try:
|
||||
self.add_attribute(
|
||||
'carrier_id',
|
||||
value=str(carrier_attribute_map[(
|
||||
self.carrier_id.mccMnc,
|
||||
self.carrier_id.imsi,
|
||||
self.carrier_id.spn.lower(),
|
||||
'',
|
||||
self.carrier_id.gid1.lower(),
|
||||
self.carrier_id.gid2.lower(),
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
)])
|
||||
)
|
||||
except KeyError:
|
||||
pass
|
||||
self.add_attribute('mcc', value=self.carrier_id.mccMnc[:3])
|
||||
self.add_attribute('mnc', value=self.carrier_id.mccMnc[3:])
|
||||
self.add_attribute('apn', 'value')
|
||||
self.add_attribute('proxy')
|
||||
self.add_attribute('port')
|
||||
self.add_attribute('mmsc')
|
||||
self.add_attribute('mmsproxy', 'mmscProxy')
|
||||
self.add_attribute('mmsport', 'mmscProxyPort')
|
||||
self.add_attribute('user')
|
||||
self.add_attribute('password')
|
||||
self.add_attribute('server')
|
||||
self.add_attribute('authtype')
|
||||
self.add_attribute(
|
||||
'type',
|
||||
value=','.join(
|
||||
apn.DESCRIPTOR.fields_by_name[
|
||||
'type'
|
||||
].enum_type.values_by_number[i].name
|
||||
for i in self.apn.type
|
||||
).lower(),
|
||||
)
|
||||
self.add_attribute('protocol')
|
||||
self.add_attribute('roaming_protocol', 'roamingProtocol')
|
||||
self.add_attribute('carrier_enabled', 'carrierEnabled')
|
||||
self.add_attribute('bearer_bitmask', 'bearerBitmask')
|
||||
self.add_attribute('profile_id', 'profileId')
|
||||
self.add_attribute('modem_cognitive', 'modemCognitive')
|
||||
self.add_attribute('max_conns', 'maxConns')
|
||||
self.add_attribute('wait_time', 'waitTime')
|
||||
self.add_attribute('max_conns_time', 'maxConnsTime')
|
||||
self.add_attribute('mtu')
|
||||
mvno = self.carrier_id.WhichOneof('mvno')
|
||||
if mvno:
|
||||
self.add_attribute(
|
||||
'mvno_type',
|
||||
value='gid' if mvno.startswith('gid') else mvno,
|
||||
)
|
||||
self.add_attribute(
|
||||
'mvno_match_data',
|
||||
value=getattr(self.carrier_id, mvno),
|
||||
)
|
||||
self.add_attribute('apn_set_id', 'apnSetId')
|
||||
# No source for integer carrier_id?
|
||||
self.add_attribute('skip_464xlat', 'skip464Xlat')
|
||||
self.add_attribute('user_visible', 'userVisible')
|
||||
self.add_attribute('user_editable', 'userEditable')
|
||||
|
||||
|
||||
def indent(elem, level=0):
|
||||
"""Based on https://effbot.org/zone/element-lib.htm#prettyprint"""
|
||||
i = "\n" + level * " "
|
||||
if len(elem):
|
||||
if not elem.text or not elem.text.strip():
|
||||
elem.text = i + " "
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
for elem in elem:
|
||||
indent(elem, level + 1)
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
else:
|
||||
if level and (not elem.tail or not elem.tail.strip()):
|
||||
elem.tail = i
|
||||
|
||||
|
||||
carrier_config_root = ET.Element('carrier_config_list')
|
||||
|
||||
with open('apns-full-conf.xml', 'w', encoding='utf-8') as f:
|
||||
f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n\n')
|
||||
f.write('<apns version="8">\n\n')
|
||||
|
||||
version_suffix = all_settings['default'].version % 1000000000
|
||||
for entry in carrier_list.entry:
|
||||
setting = all_settings[entry.canonicalName]
|
||||
for apn in setting.apns.apn:
|
||||
f.write(' <apn carrier={}\n'.format(quoteattr(apn.name)))
|
||||
apn_element = ApnElement(apn, entry.carrierId)
|
||||
for (key, value) in apn_element.attributes.items():
|
||||
f.write(' {}={}\n'.format(escape(key), quoteattr(value)))
|
||||
f.write(' />\n\n')
|
||||
|
||||
carrier_config_element = ET.SubElement(
|
||||
carrier_config_root,
|
||||
'carrier_config',
|
||||
)
|
||||
carrier_config_element.set('mcc', entry.carrierId.mccMnc[:3])
|
||||
carrier_config_element.set('mnc', entry.carrierId.mccMnc[3:])
|
||||
for field in ['spn', 'imsi', 'gid1', 'gid2']:
|
||||
if entry.carrierId.HasField(field):
|
||||
carrier_config_element.set(
|
||||
field,
|
||||
getattr(entry.carrierId, field),
|
||||
)
|
||||
|
||||
# Add version key composed of canonical name and versions
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'string'
|
||||
)
|
||||
carrier_config_subelement.set('name', 'carrier_config_version_string')
|
||||
carrier_config_subelement.text = '{}-{}.{}'.format(
|
||||
setting.canonicalName,
|
||||
setting.version,
|
||||
version_suffix
|
||||
)
|
||||
|
||||
for config in setting.configs.config:
|
||||
value_type = config.WhichOneof('value')
|
||||
if value_type == 'textValue':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'string',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.text = getattr(config, value_type)
|
||||
elif value_type == 'intValue':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'int',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.set(
|
||||
'value',
|
||||
str(getattr(config, value_type)),
|
||||
)
|
||||
elif value_type == 'longValue':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'long',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.set(
|
||||
'value',
|
||||
str(getattr(config, value_type)),
|
||||
)
|
||||
elif value_type == 'boolValue':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'boolean',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.set(
|
||||
'value',
|
||||
str(getattr(config, value_type)).lower(),
|
||||
)
|
||||
elif value_type == 'textArray':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'string-array',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.set(
|
||||
'num',
|
||||
str(len(getattr(config, value_type).item)),
|
||||
)
|
||||
for value in getattr(config, value_type).item:
|
||||
carrier_config_item = ET.SubElement(
|
||||
carrier_config_subelement,
|
||||
'item',
|
||||
)
|
||||
carrier_config_item.set('value', value)
|
||||
elif value_type == 'intArray':
|
||||
carrier_config_subelement = ET.SubElement(
|
||||
carrier_config_element,
|
||||
'int-array',
|
||||
)
|
||||
carrier_config_subelement.set('name', config.key)
|
||||
carrier_config_subelement.set(
|
||||
'num',
|
||||
str(len(getattr(config, value_type).item)),
|
||||
)
|
||||
for value in getattr(config, value_type).item:
|
||||
carrier_config_item = ET.SubElement(
|
||||
carrier_config_subelement,
|
||||
'item',
|
||||
)
|
||||
carrier_config_item.set('value', str(value))
|
||||
else:
|
||||
raise TypeError("Unknown value type: {}".format(value_type))
|
||||
|
||||
f.write('</apns>\n')
|
||||
|
||||
indent(carrier_config_root)
|
||||
carrier_config_tree = ET.ElementTree(carrier_config_root)
|
||||
carrier_config_tree.write('vendor.xml', encoding='utf-8', xml_declaration=True)
|
||||
|
||||
# Test XML parsing.
|
||||
ET.parse('apns-full-conf.xml')
|
||||
ET.parse('vendor.xml')
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
curl -fS \
|
||||
'https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.pb?format=TEXT' | \
|
||||
base64 --decode > carrier_list.pb
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TMPDIR="$(mktemp -d "${TMPDIR:-tmp}.XXXXXX")"
|
||||
trap "rm -rf '${TMPDIR}'" EXIT
|
||||
export TMPDIR
|
||||
|
||||
git clone https://github.com/GrapheneOS/android-prepare-vendor --branch=11 ${TMPDIR}/android-prepare-vendor-11 --depth=1 --single-branch
|
||||
"${TMPDIR}/android-prepare-vendor-11/scripts/download-nexus-image.sh" \
|
||||
--device "$DEVICE" --buildID "$BUILD" --output "$TMPDIR" --yes
|
||||
factory_image="$(find "$TMPDIR" -iname "*$DEVICE*$BUILD-factory*.tgz" -or \
|
||||
-iname "*$DEVICE*$BUILD-factory*.zip" | head -1)"
|
||||
PATH="$PATH:/sbin:${TMPDIR}/android-prepare-vendor-11/hostTools/$(uname -s)/bin" \
|
||||
"${TMPDIR}/android-prepare-vendor-11/scripts/extract-factory-images.sh" \
|
||||
--input "$factory_image" --output "$TMPDIR" \
|
||||
--conf-file "${TMPDIR}/android-prepare-vendor-11/${DEVICE}/config.json" \
|
||||
--debugfs
|
||||
mv "$(dirname "$(find "${TMPDIR}" -name carrier_list.pb | head -1)")" .
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
[ -f carrier_list.pb ] || ./download_carrier_list.sh
|
||||
|
||||
for DEVICE in walleye taimen crosshatch bonito coral; do
|
||||
if [ "$DEVICE" = sunfish ]; then
|
||||
BUILD=RP1A.200720.011
|
||||
else
|
||||
BUILD=RP1A.200720.009
|
||||
fi
|
||||
|
||||
if [ "$DEVICE" = walleye ]; then
|
||||
repo_dir="../device_google_muskie"
|
||||
else
|
||||
repo_dir="../device_google_${DEVICE}"
|
||||
fi
|
||||
[ -d "$repo_dir" ]
|
||||
|
||||
DEVICE="$DEVICE" BUILD="$BUILD" ./download_factory_img.sh
|
||||
./carriersettings_extractor.py CarrierSettings
|
||||
mv apns-full-conf.xml "${repo_dir}/apns-full-conf.xml"
|
||||
rm -r CarrierSettings
|
||||
rm vendor.xml
|
||||
|
||||
(
|
||||
cd "$repo_dir"
|
||||
git checkout -b apns 2> /dev/null || git checkout apns
|
||||
git fetch origin
|
||||
git reset origin/11
|
||||
git add apns-full-conf.xml '*.mk'
|
||||
git commit -m "Include APNs from CarrierSettings
|
||||
|
||||
Generated by carriersettings-extractor from ${DEVICE}-${BUILD}"
|
||||
)
|
||||
done
|
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// Copyright (C) 2017 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package carrierIdentification;
|
||||
|
||||
option java_package = "com.android.internal.telephony";
|
||||
option java_outer_classname = "CarrierIdProto";
|
||||
|
||||
// A complete list of carriers
|
||||
message CarrierList {
|
||||
// A collection of carriers. one entry for one carrier.
|
||||
repeated CarrierId carrier_id = 1;
|
||||
// Version number of current carrier list
|
||||
optional int32 version = 2;
|
||||
};
|
||||
|
||||
// CarrierId is the unique representation of a carrier in CID table.
|
||||
message CarrierId {
|
||||
// [Optional] A unique canonical number designated to a carrier.
|
||||
optional int32 canonical_id = 1;
|
||||
|
||||
// [Optional] A user-friendly carrier name (not localized).
|
||||
optional string carrier_name = 2;
|
||||
|
||||
// [Optional] Carrier attributes to match a carrier. At least one value is required.
|
||||
repeated CarrierAttribute carrier_attribute = 3;
|
||||
|
||||
// [Optional] A unique canonical number to represent its parent carrier. The parent-child
|
||||
// relationship can be used to differentiate a single carrier by different networks,
|
||||
// by prepaid v.s. postpaid or even by 4G v.s. 3G plan.
|
||||
optional int32 parent_canonical_id = 4;
|
||||
};
|
||||
|
||||
// Attributes used to match a carrier.
|
||||
// For each field within this message:
|
||||
// - if not set, the attribute is ignored;
|
||||
// - if set, the device must have one of the specified values to match.
|
||||
// Match is based on AND between any field that is set and OR for values within a repeated field.
|
||||
message CarrierAttribute {
|
||||
// [Optional] The MCC and MNC that map to this carrier. At least one value is required.
|
||||
repeated string mccmnc_tuple = 1;
|
||||
|
||||
// [Optional] Prefix of IMSI (International Mobile Subscriber Identity) in
|
||||
// decimal format. Some digits can be replaced with "x" symbols matching any digit.
|
||||
// Sample values: 20404794, 21670xx2xxx.
|
||||
repeated string imsi_prefix_xpattern = 2;
|
||||
|
||||
// [Optional] The Service Provider Name. Read from subscription EF_SPN.
|
||||
// Sample values: C Spire, LeclercMobile
|
||||
repeated string spn = 3;
|
||||
|
||||
// [Optional] PLMN network name. Read from subscription EF_PNN.
|
||||
// Sample values:
|
||||
repeated string plmn = 4;
|
||||
|
||||
// [Optional] Group Identifier Level1 for a GSM phone. Read from subscription EF_GID1.
|
||||
// Sample values: 6D, BAE0000000000000
|
||||
repeated string gid1 = 5;
|
||||
|
||||
// [Optional] Group Identifier Level2 for a GSM phone. Read from subscription EF_GID2.
|
||||
// Sample values: 6D, BAE0000000000000
|
||||
repeated string gid2 = 6;
|
||||
|
||||
// [Optional] The Access Point Name, corresponding to "apn" field returned by
|
||||
// "content://telephony/carriers/preferapn" on device.
|
||||
// Sample values: fast.t-mobile.com, internet
|
||||
repeated string preferred_apn = 7;
|
||||
|
||||
// [Optional] Prefix of Integrated Circuit Card Identifier. Read from subscription EF_ICCID.
|
||||
// Sample values: 894430, 894410
|
||||
repeated string iccid_prefix = 8;
|
||||
|
||||
// [Optional] Carrier Privilege Access Rule in hex string.
|
||||
// Sample values: 61ed377e85d386a8dfee6b864bd85b0bfaa5af88
|
||||
repeated string privilege_access_rule = 9;
|
||||
};
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: vendor/carrierId.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='vendor/carrierId.proto',
|
||||
package='carrierIdentification',
|
||||
syntax='proto2',
|
||||
serialized_options=_b('\n\036com.android.internal.telephonyB\016CarrierIdProto'),
|
||||
serialized_pb=_b('\n\x16vendor/carrierId.proto\x12\x15\x63\x61rrierIdentification\"T\n\x0b\x43\x61rrierList\x12\x34\n\ncarrier_id\x18\x01 \x03(\x0b\x32 .carrierIdentification.CarrierId\x12\x0f\n\x07version\x18\x02 \x01(\x05\"\x98\x01\n\tCarrierId\x12\x14\n\x0c\x63\x61nonical_id\x18\x01 \x01(\x05\x12\x14\n\x0c\x63\x61rrier_name\x18\x02 \x01(\t\x12\x42\n\x11\x63\x61rrier_attribute\x18\x03 \x03(\x0b\x32\'.carrierIdentification.CarrierAttribute\x12\x1b\n\x13parent_canonical_id\x18\x04 \x01(\x05\"\xc9\x01\n\x10\x43\x61rrierAttribute\x12\x14\n\x0cmccmnc_tuple\x18\x01 \x03(\t\x12\x1c\n\x14imsi_prefix_xpattern\x18\x02 \x03(\t\x12\x0b\n\x03spn\x18\x03 \x03(\t\x12\x0c\n\x04plmn\x18\x04 \x03(\t\x12\x0c\n\x04gid1\x18\x05 \x03(\t\x12\x0c\n\x04gid2\x18\x06 \x03(\t\x12\x15\n\rpreferred_apn\x18\x07 \x03(\t\x12\x14\n\x0ciccid_prefix\x18\x08 \x03(\t\x12\x1d\n\x15privilege_access_rule\x18\t \x03(\tB0\n\x1e\x63om.android.internal.telephonyB\x0e\x43\x61rrierIdProto')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
_CARRIERLIST = _descriptor.Descriptor(
|
||||
name='CarrierList',
|
||||
full_name='carrierIdentification.CarrierList',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='carrier_id', full_name='carrierIdentification.CarrierList.carrier_id', index=0,
|
||||
number=1, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='version', full_name='carrierIdentification.CarrierList.version', index=1,
|
||||
number=2, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=49,
|
||||
serialized_end=133,
|
||||
)
|
||||
|
||||
|
||||
_CARRIERID = _descriptor.Descriptor(
|
||||
name='CarrierId',
|
||||
full_name='carrierIdentification.CarrierId',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='canonical_id', full_name='carrierIdentification.CarrierId.canonical_id', index=0,
|
||||
number=1, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='carrier_name', full_name='carrierIdentification.CarrierId.carrier_name', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='carrier_attribute', full_name='carrierIdentification.CarrierId.carrier_attribute', index=2,
|
||||
number=3, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='parent_canonical_id', full_name='carrierIdentification.CarrierId.parent_canonical_id', index=3,
|
||||
number=4, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=136,
|
||||
serialized_end=288,
|
||||
)
|
||||
|
||||
|
||||
_CARRIERATTRIBUTE = _descriptor.Descriptor(
|
||||
name='CarrierAttribute',
|
||||
full_name='carrierIdentification.CarrierAttribute',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='mccmnc_tuple', full_name='carrierIdentification.CarrierAttribute.mccmnc_tuple', index=0,
|
||||
number=1, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='imsi_prefix_xpattern', full_name='carrierIdentification.CarrierAttribute.imsi_prefix_xpattern', index=1,
|
||||
number=2, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='spn', full_name='carrierIdentification.CarrierAttribute.spn', index=2,
|
||||
number=3, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='plmn', full_name='carrierIdentification.CarrierAttribute.plmn', index=3,
|
||||
number=4, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='gid1', full_name='carrierIdentification.CarrierAttribute.gid1', index=4,
|
||||
number=5, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='gid2', full_name='carrierIdentification.CarrierAttribute.gid2', index=5,
|
||||
number=6, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='preferred_apn', full_name='carrierIdentification.CarrierAttribute.preferred_apn', index=6,
|
||||
number=7, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='iccid_prefix', full_name='carrierIdentification.CarrierAttribute.iccid_prefix', index=7,
|
||||
number=8, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='privilege_access_rule', full_name='carrierIdentification.CarrierAttribute.privilege_access_rule', index=8,
|
||||
number=9, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=291,
|
||||
serialized_end=492,
|
||||
)
|
||||
|
||||
_CARRIERLIST.fields_by_name['carrier_id'].message_type = _CARRIERID
|
||||
_CARRIERID.fields_by_name['carrier_attribute'].message_type = _CARRIERATTRIBUTE
|
||||
DESCRIPTOR.message_types_by_name['CarrierList'] = _CARRIERLIST
|
||||
DESCRIPTOR.message_types_by_name['CarrierId'] = _CARRIERID
|
||||
DESCRIPTOR.message_types_by_name['CarrierAttribute'] = _CARRIERATTRIBUTE
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
CarrierList = _reflection.GeneratedProtocolMessageType('CarrierList', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CARRIERLIST,
|
||||
__module__ = 'vendor.carrierId_pb2'
|
||||
# @@protoc_insertion_point(class_scope:carrierIdentification.CarrierList)
|
||||
))
|
||||
_sym_db.RegisterMessage(CarrierList)
|
||||
|
||||
CarrierId = _reflection.GeneratedProtocolMessageType('CarrierId', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CARRIERID,
|
||||
__module__ = 'vendor.carrierId_pb2'
|
||||
# @@protoc_insertion_point(class_scope:carrierIdentification.CarrierId)
|
||||
))
|
||||
_sym_db.RegisterMessage(CarrierId)
|
||||
|
||||
CarrierAttribute = _reflection.GeneratedProtocolMessageType('CarrierAttribute', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CARRIERATTRIBUTE,
|
||||
__module__ = 'vendor.carrierId_pb2'
|
||||
# @@protoc_insertion_point(class_scope:carrierIdentification.CarrierAttribute)
|
||||
))
|
||||
_sym_db.RegisterMessage(CarrierAttribute)
|
||||
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
# @@protoc_insertion_point(module_scope)
|
Loading…
Reference in New Issue