diff --git a/apntool/apnlists/cyanogenmod.xml b/apntool/apnlists/cyanogenmod.xml
index d778206d44..2b7719b707 100644
--- a/apntool/apnlists/cyanogenmod.xml
+++ b/apntool/apnlists/cyanogenmod.xml
@@ -122,10 +122,13 @@
+
+
+
-
-
-
+
+
+
@@ -141,6 +144,7 @@
+
@@ -169,7 +173,8 @@
-
+
+
@@ -181,6 +186,7 @@
+
@@ -245,7 +251,7 @@
-
+
@@ -282,26 +288,24 @@
-
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
@@ -329,7 +333,7 @@
-
+
@@ -367,10 +371,8 @@
-
-
-
-
+
+
@@ -576,8 +578,9 @@
-
-
+
+
+
@@ -600,10 +603,10 @@
-
+
-
-
+
+
@@ -683,12 +686,11 @@
-
-
-
-
-
-
+
+
+
+
+
@@ -706,6 +708,7 @@
+
@@ -830,7 +833,7 @@
-
+
@@ -841,6 +844,7 @@
+
@@ -850,17 +854,27 @@
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
@@ -874,11 +888,14 @@
-
+
+
+
-
-
+
+
+
@@ -890,49 +907,60 @@
-
+
-
+
-
+
-
+
+
+
-
+
-
-
+
+
+
-
+
-
+
+
+
-
+
-
+
-
+
+
+
-
-
+
+
+
+
+
-
+
+
@@ -949,19 +977,25 @@
+
+
+
-
+
+
-
+
+
+
@@ -984,13 +1018,14 @@
-
+
+
-
+
-
+
@@ -999,57 +1034,92 @@
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
+
@@ -1094,12 +1164,24 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1122,29 +1204,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1193,11 +1277,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1256,7 +1353,7 @@
-
+
@@ -1281,20 +1378,29 @@
+
+
+
+
+
+
-
+
+
-
+
+
-
+
+
-
+
@@ -1310,9 +1416,11 @@
-
+
+
+
@@ -1321,6 +1429,7 @@
+
@@ -1428,11 +1537,20 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1569,6 +1687,8 @@
+
+
@@ -1592,7 +1712,8 @@
-
+
+
@@ -1662,6 +1783,10 @@
+
+
+
+
diff --git a/apntool/apnlists/hangouts.xml b/apntool/apnlists/hangouts.xml
index 216acb10ab..2d3ce5b6c6 100644
--- a/apntool/apnlists/hangouts.xml
+++ b/apntool/apnlists/hangouts.xml
@@ -562,6 +562,7 @@
+
@@ -1717,8 +1718,6 @@
-
-
diff --git a/apntool/apntool.py b/apntool/apntool.py
index 0c0c558ab5..2c6e6cacf9 100644
--- a/apntool/apntool.py
+++ b/apntool/apntool.py
@@ -1,19 +1,31 @@
import sys
+import re
import argparse
import sqlite3
import gzip
from progressbar import ProgressBar, Counter, Timer
from lxml import etree
-parser = argparse.ArgumentParser(prog='apntool', description="""Process Android's apn xml files and drop them into an easily
- queryable SQLite db. Tested up to version 9 of their APN file.""")
-parser.add_argument('-v', '--version', action='version', version='%(prog)s v1.0')
+parser = argparse.ArgumentParser(prog='apntool', description="""Process Android's apn xml files and drop them into an
+ easily queryable SQLite db. Tested up to version 9 of
+ their APN file.""")
+parser.add_argument('-v', '--version', action='version', version='%(prog)s v1.1')
parser.add_argument('-i', '--input', help='the xml file to parse', default='apns.xml', required=False)
parser.add_argument('-o', '--output', help='the sqlite db output file', default='apns.db', required=False)
parser.add_argument('--quiet', help='do not show progress or verbose instructions', action='store_true', required=False)
parser.add_argument('--no-gzip', help="do not gzip after creation", action='store_true', required=False)
args = parser.parse_args()
+
+def normalized(target):
+ o2_typo = re.compile(r"02\.co\.uk")
+ port_typo = re.compile(r"(\d+\.\d+\.\d+\.\d+)\.(\d+)")
+ leading_zeros = re.compile(r"(/|\.|^)0+(\d+)")
+ subbed = o2_typo.sub(r'o2.co.uk', target)
+ subbed = port_typo.sub(r'\1:\2', subbed)
+ subbed = leading_zeros.sub(r'\1\2', subbed)
+ return subbed
+
try:
connection = sqlite3.connect(args.output)
cursor = connection.cursor()
@@ -28,26 +40,39 @@ try:
cursor.execute("PRAGMA page_size=32768")
cursor.execute("VACUUM")
cursor.execute("DROP TABLE IF EXISTS apns")
- cursor.execute("""CREATE TABLE apns(_id INTEGER PRIMARY KEY, mccmnc TEXT, mcc TEXT, mnc TEXT, carrier TEXT, apn TEXT,
- mmsc TEXT, port INTEGER, type TEXT, protocol TEXT, bearer TEXT, roaming_protocol TEXT,
+ cursor.execute("""CREATE TABLE apns(_id INTEGER PRIMARY KEY, mccmnc TEXT, mcc TEXT, mnc TEXT, carrier TEXT,
+ apn TEXT, mmsc TEXT, port INTEGER, type TEXT, protocol TEXT, bearer TEXT, roaming_protocol TEXT,
carrier_enabled INTEGER, mmsproxy TEXT, mmsport INTEGER, proxy TEXT, mvno_match_data TEXT,
mvno_type TEXT, authtype INTEGER, user TEXT, password TEXT, server TEXT)""")
apns = etree.parse(args.input)
root = apns.getroot()
- pbar = ProgressBar(widgets=['Processed: ', Counter(), ' apns (', Timer(), ')'], maxval=len(list(root))).start() if not args.quiet else None
+ pbar = None
+ if not args.quiet:
+ pbar = ProgressBar(widgets=['Processed: ', Counter(), ' apns (', Timer(), ')'], maxval=len(list(root))).start()
count = 0
for apn in root.iter("apn"):
- if apn.get("mmsc") == None:
+ if apn.get("mmsc") is None:
continue
sqlvars = ["?" for x in apn.attrib.keys()] + ["?"]
- mccmnc = "%s%s" % (apn.get("mcc"), apn.get("mnc"))
- values = [apn.get(attrib) for attrib in apn.attrib.keys()] + [mccmnc]
- keys = apn.attrib.keys() + ["mccmnc"]
+ mccmnc = "%s%s" % (apn.get("mcc"), apn.get("mnc"))
+ normalized_mmsc = normalized(apn.get("mmsc"))
+ if normalized_mmsc != apn.get("mmsc"):
+ print("normalize MMSC: %s => %s" % (apn.get("mmsc"), normalized_mmsc))
+ apn.set("mmsc", normalized_mmsc)
+
+ if not apn.get("mmsproxy") is None:
+ normalized_mmsproxy = normalized(apn.get("mmsproxy"))
+ if normalized_mmsproxy != apn.get("mmsproxy"):
+ print("normalize proxy: %s => %s" % (apn.get("mmsproxy"), normalized_mmsproxy))
+ apn.set("mmsproxy", normalized_mmsproxy)
+
+ values = [apn.get(attrib) for attrib in apn.attrib.keys()] + [mccmnc]
+ keys = apn.attrib.keys() + ["mccmnc"]
cursor.execute("SELECT 1 FROM apns WHERE mccmnc = ? AND apn = ?", [mccmnc, apn.get("apn")])
- if cursor.fetchone() == None:
+ if cursor.fetchone() is None:
statement = "INSERT INTO apns (%s) VALUES (%s)" % (", ".join(keys), ", ".join(sqlvars))
cursor.execute(statement, values)
diff --git a/assets/databases/apns.db b/assets/databases/apns.db
index 66b46298b7..a1ce2f0b48 100644
Binary files a/assets/databases/apns.db and b/assets/databases/apns.db differ