16e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu/* 26e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** 36e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** Copyright (C) 2014, The Android Open Source Project 46e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** 56e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** Licensed under the Apache License, Version 2.0 (the "License"); 66e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** you may not use this file except in compliance with the License. 76e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** You may obtain a copy of the License at 86e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** 96e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** http://www.apache.org/licenses/LICENSE-2.0 106e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** 116e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** Unless required by applicable law or agreed to in writing, software 126e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** distributed under the License is distributed on an "AS IS" BASIS, 136e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 146e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** See the License for the specific language governing permissions and 156e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu** limitations under the License. 166e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu*/ 176e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 186e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu/* 196e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This class is used to create, load tables for HBPCD 206e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * HBPCD means 'Handset Based Plus Code Dialing', for CDMA network, most of network 216e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * couldn't handle international dialing number with '+', it need to be converted 226e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * to a IDD (International Direct Dialing) number, and some CDMA network won't 236e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * broadcast operator numeric, we need CDMA system ID and timezone etc. information 246e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * to get right MCC part of numeric, MNC part of numeric has no way to get in this 256e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * case, but for HBPCD, the MCC is enough. 266e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 276e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_MCC_LOOKUP_TABLE 286e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This table has country name, country code, time zones for each MCC 296e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 306e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_MCC_IDD 316e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This table has the IDDs for each MCC, some countries have multiple IDDs. 326e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 336e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_MCC_SID_RANGE 346e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This table are SIDs assigned to each MCC 356e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 366e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_MCC_SID_CONFLICT 376e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This table shows those SIDs are assigned to more than 1 MCC entry, 386e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * if the SID is here, it means the SID couldn't be matched to a single MCC, 396e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * it need to check the time zone and SID in TABLE_MCC_LOOKUP_TABLE to get 406e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * right MCC. 416e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 426e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_ARBITRARY_MCC_SID_MATCH 436e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * The SID listed in this table technically have operators in multiple MCC, 446e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * but conveniently only have *active* operators in a single MCC allowing a 456e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * unique SID->MCC lookup. Lookup by Timezone however would be complicatedi 466e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * as there will be multiple matches, and those matched entries have same 476e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * time zone, which can not tell which MCC is right. Conventionaly it is known 486e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * that SID is used only by the *active* operators in that MCC. 496e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 506e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * Table TABLE_NANP_AREA_CODE 516e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * This table has NANP(North America Number Planning) area code, this is used 526e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * to check if a dialing number is a NANP number. 536e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu */ 546e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 556e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liupackage com.android.providers.telephony; 566e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 576e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.content.ContentValues; 586e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.content.Context; 596e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.content.res.Resources; 606e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.content.res.XmlResourceParser; 616e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.database.Cursor; 626e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.database.SQLException; 636e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.database.sqlite.SQLiteDatabase; 646e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.database.sqlite.SQLiteOpenHelper; 656e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.database.sqlite.SQLiteQueryBuilder; 666e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.util.Log; 676e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport android.util.Xml; 686e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.util.XmlUtils; 696e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 706e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport org.xmlpull.v1.XmlPullParser; 716e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport org.xmlpull.v1.XmlPullParserException; 726e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 736e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport java.io.IOException; 746e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 756e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup; 766e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.MccIdd; 776e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.MccLookup; 786e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.MccSidConflicts; 796e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.MccSidRange; 806e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.ArbitraryMccSidMatch; 816e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liuimport com.android.internal.telephony.HbpcdLookup.NanpAreaCode; 826e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 836e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liupublic class HbpcdLookupDatabaseHelper extends SQLiteOpenHelper { 846e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private static final String TAG = "HbpcdLockupDatabaseHelper"; 856e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private static final boolean DBG = true; 866e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 876e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private static final String DATABASE_NAME = "HbpcdLookup.db"; 886e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private static final int DATABASE_VERSION = 1; 896e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 906e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu // Context to access resources with 916e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private Context mContext; 926e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 936e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu /** 946e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * DatabaseHelper helper class for loading apns into a database. 956e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * 966e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu * @param context of the user. 976e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu */ 986e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu public HbpcdLookupDatabaseHelper(Context context) { 996e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu super(context, DATABASE_NAME, null, DATABASE_VERSION); 1006e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1016e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu mContext = context; 1026e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1036e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1046e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu @Override 1056e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu public void onCreate(SQLiteDatabase db) { 1066e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu //set up the database schema 1076e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu // 1 MCC may has more IDDs 1086e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_MCC_IDD + 1096e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1106e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "MCC INTEGER," + 1116e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "IDD TEXT);"); 1126e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1136e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_MCC_LOOKUP_TABLE + 1146e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1156e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "MCC INTEGER," + 1166e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "Country_Code TEXT," + 1176e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "Country_Name TEXT," + 1186e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "NDD TEXT," + 1196e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "NANPS BOOLEAN," + 1206e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "GMT_Offset_Low REAL," + 1216e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "GMT_Offset_High REAL," + 1226e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "GMT_DST_Low REAL," + 1236e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "GMT_DST_High REAL);"); 1246e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1256e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_MCC_SID_CONFLICT + 1266e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1276e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "MCC INTEGER," + 1286e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "SID_Conflict INTEGER);"); 1296e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1306e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_MCC_SID_RANGE + 1316e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1326e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "MCC INTEGER," + 1336e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "SID_Range_Low INTEGER," + 1346e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "SID_Range_High INTEGER);"); 1356e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1366e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_NANP_AREA_CODE + 1376e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1386e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "AREA_CODE INTEGER UNIQUE);"); 1396e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1406e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.execSQL("CREATE TABLE " + HbpcdLookupProvider.TABLE_ARBITRARY_MCC_SID_MATCH + 1416e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "(_id INTEGER PRIMARY KEY," + 1426e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "MCC INTEGER," + 1436e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu "SID INTEGER UNIQUE);"); 1446e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1456e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu initDatabase(db); 1466e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1476e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1486e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu @Override 1496e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 1506e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu // do nothing 1516e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1526e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1536e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private void initDatabase (SQLiteDatabase db) { 1546e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu // Read internal data from xml 1556e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Resources r = mContext.getResources(); 1566e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu XmlResourceParser parser = r.getXml(R.xml.hbpcd_lookup_tables); 1576e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1586e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (parser == null) { 1596e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Log.e (TAG, "error to load the HBPCD resource"); 1606e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else { 1616e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu try { 1626e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.beginTransaction(); 1636e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu XmlUtils.beginDocument(parser, "hbpcd_info"); 1646e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1656e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 1666e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 1676e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1686e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (eventType != XmlPullParser.END_DOCUMENT) { 1696e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG 1706e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu && tagName.equalsIgnoreCase("table")) { 1716e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tableName = parser.getAttributeValue(null, "name"); 1726e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu loadTable(db, parser, tableName); 1736e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1746e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 1756e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 1766e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 1776e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1786e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.setTransactionSuccessful(); 1796e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } catch (XmlPullParserException e) { 1806e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Log.e (TAG, "Got XmlPullParserException when load hbpcd info"); 1816e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } catch (IOException e) { 1826e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Log.e (TAG, "Got IOException when load hbpcd info"); 1836e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } catch (SQLException e) { 1846e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Log.e (TAG, "Got SQLException when load hbpcd info"); 1856e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } finally { 1866e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.endTransaction(); 1876e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.close(); 1886e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1896e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1906e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 1916e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 1926e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private void loadTable(SQLiteDatabase db, XmlPullParser parser, String tableName) 1936e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 1946e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 1956e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 1966e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG 1976e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu && tagName.equalsIgnoreCase("table"))) { 1986e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = null; 1996e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tableName.equalsIgnoreCase(HbpcdLookupProvider.TABLE_MCC_IDD)) { 2006e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableMccIddRow(parser); 2016e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tableName.equalsIgnoreCase(HbpcdLookupProvider.TABLE_MCC_LOOKUP_TABLE)) { 2026e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableMccLookupTableRow(parser); 2036e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tableName.equalsIgnoreCase(HbpcdLookupProvider.TABLE_MCC_SID_CONFLICT)) { 2046e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableMccSidConflictRow(parser); 2056e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tableName.equalsIgnoreCase(HbpcdLookupProvider.TABLE_MCC_SID_RANGE)) { 2066e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableMccSidRangeRow(parser); 2076e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tableName.equalsIgnoreCase(HbpcdLookupProvider.TABLE_NANP_AREA_CODE)) { 2086e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableNanpAreaCodeRow(parser); 2096e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tableName.equalsIgnoreCase( 2106e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu HbpcdLookupProvider.TABLE_ARBITRARY_MCC_SID_MATCH)) { 2116e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row = getTableArbitraryMccSidMatch(parser); 2126e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else { 2136e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu Log.e(TAG, "unrecognized table name" + tableName); 2146e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu break; 2156e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2166e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (row != null) { 2176e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu db.insert(tableName, null, row); 2186e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2196e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 2206e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 2216e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 2226e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2236e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2246e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2256e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableMccIddRow(XmlPullParser parser) 2266e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 2276e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 2286e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 2296e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 2306e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2316e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 2326e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 2336e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(MccIdd.MCC)) { 2346e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccIdd.MCC, Integer.parseInt(parser.nextText())); 2356e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccIdd.IDD)) { 2366e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccIdd.IDD, parser.nextText()); 2376e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2386e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2396e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 2406e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 2416e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 2426e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2436e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 2446e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2456e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2466e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableMccLookupTableRow(XmlPullParser parser) 2476e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 2486e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 2496e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 2506e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 2516e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2526e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 2536e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 2546e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(MccLookup.MCC)) { 2556e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.MCC, Integer.parseInt(parser.nextText())); 2566e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.COUNTRY_CODE)) { 2576e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.COUNTRY_CODE, Integer.parseInt(parser.nextText())); 2586e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.COUNTRY_NAME)) { 2596e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.COUNTRY_NAME, parser.nextText()); 2606e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.NDD)) { 2616e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.NDD, parser.nextText()); 2626e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.NANPS)) { 2636e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.NANPS, Boolean.parseBoolean(parser.nextText())); 2646e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.GMT_OFFSET_LOW)) { 2656e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.GMT_OFFSET_LOW, Float.parseFloat(parser.nextText())); 2666e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.GMT_OFFSET_HIGH)) { 2676e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.GMT_OFFSET_HIGH, Float.parseFloat(parser.nextText())); 2686e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.GMT_DST_LOW)) { 2696e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.GMT_DST_LOW, Float.parseFloat(parser.nextText())); 2706e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccLookup.GMT_DST_HIGH)) { 2716e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccLookup.GMT_DST_HIGH, Float.parseFloat(parser.nextText())); 2726e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2736e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2746e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 2756e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 2766e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 2776e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2786e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 2796e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2806e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2816e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableMccSidConflictRow(XmlPullParser parser) 2826e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 2836e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 2846e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 2856e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 2866e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 2876e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 2886e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 2896e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(MccSidConflicts.MCC)) { 2906e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccSidConflicts.MCC, Integer.parseInt(parser.nextText())); 2916e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccSidConflicts.SID_CONFLICT)) { 2926e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccSidConflicts.SID_CONFLICT, Integer.parseInt(parser.nextText())); 2936e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2946e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2956e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 2966e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 2976e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 2986e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 2996e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 3006e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3016e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3026e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableMccSidRangeRow(XmlPullParser parser) 3036e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 3046e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 3056e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 3066e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 3076e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3086e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 3096e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 3106e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(MccSidRange.MCC)) { 3116e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccSidRange.MCC, Integer.parseInt(parser.nextText())); 3126e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccSidRange.RANGE_LOW)) { 3136e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccSidRange.RANGE_LOW, Integer.parseInt(parser.nextText())); 3146e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(MccSidRange.RANGE_HIGH)) { 3156e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(MccSidRange.RANGE_HIGH, Integer.parseInt(parser.nextText())); 3166e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3176e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3186e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 3196e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 3206e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 3216e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3226e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 3236e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3246e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3256e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableNanpAreaCodeRow(XmlPullParser parser) 3266e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 3276e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 3286e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 3296e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 3306e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3316e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 3326e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 3336e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(NanpAreaCode.AREA_CODE)) { 3346e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(NanpAreaCode.AREA_CODE, Integer.parseInt(parser.nextText())); 3356e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3366e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3376e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 3386e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 3396e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 3406e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3416e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 3426e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3436e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3446e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu private ContentValues getTableArbitraryMccSidMatch(XmlPullParser parser) 3456e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu throws XmlPullParserException, IOException { 3466e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu int eventType = parser.getEventType(); 3476e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu String tagName = parser.getName(); 3486e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu ContentValues row = new ContentValues(); 3496e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu 3506e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu while (!(eventType == XmlPullParser.END_TAG && tagName.equalsIgnoreCase("row"))) { 3516e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (eventType == XmlPullParser.START_TAG) { 3526e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu if (tagName.equalsIgnoreCase(ArbitraryMccSidMatch.MCC)) { 3536e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(ArbitraryMccSidMatch.MCC, Integer.parseInt(parser.nextText())); 3546e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } else if (tagName.equalsIgnoreCase(ArbitraryMccSidMatch.SID)) { 3556e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu row.put(ArbitraryMccSidMatch.SID, Integer.parseInt(parser.nextText())); 3566e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3576e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3586e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu parser.next(); 3596e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu eventType = parser.getEventType(); 3606e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu tagName = parser.getName(); 3616e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3626e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu return row; 3636e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu } 3646e3c0dc4e12bf48543af8df85f3452985e0043edSteven Liu} 365