summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tammo Spalink <tammo@google.com> 2009-07-23 10:50:57 +0800
committer Tammo Spalink <tammo@google.com> 2009-08-28 14:05:04 +0800
commitc18776d5bcd3a1ceadf676df778ccb4bdd521573 (patch)
treea9cae2979f9183c2c3f6e8c40128f303c531df6c
parent1005569fbb459007ff9d9fddbfa6e49947166166 (diff)
optimize MCC table
Replace a table of objects that was created at boot in a costly manner, with a pre-generated table of more densely formatted numerical data. Based on data from runhat on the phone process, this looks to shrink the memory footprint from about 16kB to less then 2kB. Addresses http://buganizer/issue?id=874072 Change-Id: I5a7b9d7de4c9b9a0360e8370252582969fbd8d4f
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/MccTable.java859
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/MccTableTest.java87
2 files changed, 580 insertions, 366 deletions
diff --git a/telephony/java/com/android/internal/telephony/gsm/MccTable.java b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
index 22b1f4ff26bf..9343f447d851 100644
--- a/telephony/java/com/android/internal/telephony/gsm/MccTable.java
+++ b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
@@ -16,8 +16,342 @@
package com.android.internal.telephony.gsm;
-import java.util.ArrayList;
-import java.util.Collections;
+import java.util.Arrays;
+
+/**
+ * The table below is built from two resources:
+ *
+ * 1) ITU "Mobile Network Code (MNC) for the international
+ * identification plan for mobile terminals and mobile users"
+ * which is available as an annex to the ITU operational bulletin
+ * available here: http://www.itu.int/itu-t/bulletin/annex.html
+ *
+ * 2) The ISO 3166 country codes list, available here:
+ * http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html
+ *
+ * This table was verified (28 Aug 2009) against
+ * http://en.wikipedia.org/wiki/List_of_mobile_country_codes with the
+ * only unresolved discrepancy being that this list has an extra entry
+ * (461) for China.
+ *
+ * TODO: Complete the mappings for timezones and language/locale codes.
+ *
+ * The actual table data used in the Java code is generated from the
+ * below Python code for efficiency. The information is expected to
+ * be static, but if changes are required, the table in the python
+ * code can be modified and the trailing code run to re-generate the
+ * tables that are to be used by Java.
+
+mcc_table = [
+ (202, 'gr', 2, 'Greece'),
+ (204, 'nl', 2, 'Europe/Amsterdam', 'nl', 13, 'Netherlands (Kingdom of the)'),
+ (206, 'be', 2, 'Belgium'),
+ (208, 'fr', 2, 'Europe/Paris', 'fr', 'France'),
+ (212, 'mc', 2, 'Monaco (Principality of)'),
+ (213, 'ad', 2, 'Andorra (Principality of)'),
+ (214, 'es', 2, 'Europe/Madrid', 'es', 'Spain'),
+ (216, 'hu', 2, 'Hungary (Republic of)'),
+ (218, 'ba', 2, 'Bosnia and Herzegovina'),
+ (219, 'hr', 2, 'Croatia (Republic of)'),
+ (220, 'rs', 2, 'Serbia and Montenegro'),
+ (222, 'it', 2, 'Europe/Rome', 'it', 'Italy'),
+ (225, 'va', 2, 'Europe/Rome', 'it', 'Vatican City State'),
+ (226, 'ro', 2, 'Romania'),
+ (228, 'ch', 2, 'Europe/Zurich', 'de', 'Switzerland (Confederation of)'),
+ (230, 'cz', 2, 'Europe/Prague', 'cs', 13, 'Czech Republic'),
+ (231, 'sk', 2, 'Slovak Republic'),
+ (232, 'at', 2, 'Europe/Vienna', 'de', 13, 'Austria'),
+ (234, 'gb', 2, 'Europe/London', 'en', 13, 'United Kingdom of Great Britain and Northern Ireland'),
+ (235, 'gb', 2, 'Europe/London', 'en', 13, 'United Kingdom of Great Britain and Northern Ireland'),
+ (238, 'dk', 2, 'Denmark'),
+ (240, 'se', 2, 'Sweden'),
+ (242, 'no', 2, 'Norway'),
+ (244, 'fi', 2, 'Finland'),
+ (246, 'lt', 2, 'Lithuania (Republic of)'),
+ (247, 'lv', 2, 'Latvia (Republic of)'),
+ (248, 'ee', 2, 'Estonia (Republic of)'),
+ (250, 'ru', 2, 'Russian Federation'),
+ (255, 'ua', 2, 'Ukraine'),
+ (257, 'by', 2, 'Belarus (Republic of)'),
+ (259, 'md', 2, 'Moldova (Republic of)'),
+ (260, 'pl', 2, 'Europe/Warsaw', 'Poland (Republic of)'),
+ (262, 'de', 2, 'Europe/Berlin', 'de', 13, 'Germany (Federal Republic of)'),
+ (266, 'gi', 2, 'Gibraltar'),
+ (268, 'pt', 2, 'Portugal'),
+ (270, 'lu', 2, 'Luxembourg'),
+ (272, 'ie', 2, 'Europe/Dublin', 'en', 'Ireland'),
+ (274, 'is', 2, 'Iceland'),
+ (276, 'al', 2, 'Albania (Republic of)'),
+ (278, 'mt', 2, 'Malta'),
+ (280, 'cy', 2, 'Cyprus (Republic of)'),
+ (282, 'ge', 2, 'Georgia'),
+ (283, 'am', 2, 'Armenia (Republic of)'),
+ (284, 'bg', 2, 'Bulgaria (Republic of)'),
+ (286, 'tr', 2, 'Turkey'),
+ (288, 'fo', 2, 'Faroe Islands'),
+ (289, 'ge', 2, 'Abkhazia (Georgia)'),
+ (290, 'gl', 2, 'Greenland (Denmark)'),
+ (292, 'sm', 2, 'San Marino (Republic of)'),
+ (293, 'sl', 2, 'Slovenia (Republic of)'),
+ (294, 'mk', 2, 'The Former Yugoslav Republic of Macedonia'),
+ (295, 'li', 2, 'Liechtenstein (Principality of)'),
+ (297, 'me', 2, 'Montenegro (Republic of)'),
+ (302, 'ca', 2, '', '', 11, 'Canada'),
+ (308, 'pm', 2, 'Saint Pierre and Miquelon (Collectivit territoriale de la Rpublique franaise)'),
+ (310, 'us', 3, '', 'en', 11, 'United States of America'),
+ (311, 'us', 3, '', 'en', 11, 'United States of America'),
+ (312, 'us', 3, '', 'en', 11, 'United States of America'),
+ (313, 'us', 3, '', 'en', 11, 'United States of America'),
+ (314, 'us', 3, '', 'en', 11, 'United States of America'),
+ (315, 'us', 3, '', 'en', 11, 'United States of America'),
+ (316, 'us', 3, '', 'en', 11, 'United States of America'),
+ (330, 'pr', 2, 'Puerto Rico'),
+ (332, 'vi', 2, 'United States Virgin Islands'),
+ (334, 'mx', 3, 'Mexico'),
+ (338, 'jm', 3, 'Jamaica'),
+ (340, 'gp', 2, 'Guadeloupe (French Department of)'),
+ (342, 'bb', 3, 'Barbados'),
+ (344, 'ag', 3, 'Antigua and Barbuda'),
+ (346, 'ky', 3, 'Cayman Islands'),
+ (348, 'vg', 3, 'British Virgin Islands'),
+ (350, 'bm', 2, 'Bermuda'),
+ (352, 'gd', 2, 'Grenada'),
+ (354, 'ms', 2, 'Montserrat'),
+ (356, 'kn', 2, 'Saint Kitts and Nevis'),
+ (358, 'lc', 2, 'Saint Lucia'),
+ (360, 'vc', 2, 'Saint Vincent and the Grenadines'),
+ (362, 'nl', 2, 'Netherlands Antilles'),
+ (363, 'aw', 2, 'Aruba'),
+ (364, 'bs', 2, 'Bahamas (Commonwealth of the)'),
+ (365, 'ai', 3, 'Anguilla'),
+ (366, 'dm', 2, 'Dominica (Commonwealth of)'),
+ (368, 'cu', 2, 'Cuba'),
+ (370, 'do', 2, 'Dominican Republic'),
+ (372, 'ht', 2, 'Haiti (Republic of)'),
+ (374, 'tt', 2, 'Trinidad and Tobago'),
+ (376, 'tc', 2, 'Turks and Caicos Islands'),
+ (400, 'az', 2, 'Azerbaijani Republic'),
+ (401, 'kz', 2, 'Kazakhstan (Republic of)'),
+ (402, 'bt', 2, 'Bhutan (Kingdom of)'),
+ (404, 'in', 2, 'India (Republic of)'),
+ (405, 'in', 2, 'India (Republic of)'),
+ (410, 'pk', 2, 'Pakistan (Islamic Republic of)'),
+ (412, 'af', 2, 'Afghanistan'),
+ (413, 'lk', 2, 'Sri Lanka (Democratic Socialist Republic of)'),
+ (414, 'mm', 2, 'Myanmar (Union of)'),
+ (415, 'lb', 2, 'Lebanon'),
+ (416, 'jo', 2, 'Jordan (Hashemite Kingdom of)'),
+ (417, 'sy', 2, 'Syrian Arab Republic'),
+ (418, 'iq', 2, 'Iraq (Republic of)'),
+ (419, 'kw', 2, 'Kuwait (State of)'),
+ (420, 'sa', 2, 'Saudi Arabia (Kingdom of)'),
+ (421, 'ye', 2, 'Yemen (Republic of)'),
+ (422, 'om', 2, 'Oman (Sultanate of)'),
+ (423, 'ps', 2, 'Palestine'),
+ (424, 'ae', 2, 'United Arab Emirates'),
+ (425, 'il', 2, 'Israel (State of)'),
+ (426, 'bh', 2, 'Bahrain (Kingdom of)'),
+ (427, 'qa', 2, 'Qatar (State of)'),
+ (428, 'mn', 2, 'Mongolia'),
+ (429, 'np', 2, 'Nepal'),
+ (430, 'ae', 2, 'United Arab Emirates'),
+ (431, 'ae', 2, 'United Arab Emirates'),
+ (432, 'ir', 2, 'Iran (Islamic Republic of)'),
+ (434, 'uz', 2, 'Uzbekistan (Republic of)'),
+ (436, 'tj', 2, 'Tajikistan (Republic of)'),
+ (437, 'kg', 2, 'Kyrgyz Republic'),
+ (438, 'tm', 2, 'Turkmenistan'),
+ (440, 'jp', 2, 'Asia/Tokyo', 'ja', 14, 'Japan'),
+ (441, 'jp', 2, 'Asia/Tokyo', 'ja', 14, 'Japan'),
+ (450, 'kr', 2, 'Korea (Republic of)'),
+ (452, 'vn', 2, 'Viet Nam (Socialist Republic of)'),
+ (454, 'hk', 2, '"Hong Kong, China"'),
+ (455, 'mo', 2, '"Macao, China"'),
+ (456, 'kh', 2, 'Cambodia (Kingdom of)'),
+ (457, 'la', 2, "Lao People's Democratic Republic"),
+ (460, 'cn', 2, "China (People's Republic of)"),
+ (461, 'cn', 2, "China (People's Republic of)"),
+ (466, 'tw', 2, "Taiwan (Republic of China)"),
+ (467, 'kp', 2, "Democratic People's Republic of Korea"),
+ (470, 'bd', 2, "Bangladesh (People's Republic of)"),
+ (472, 'mv', 2, 'Maldives (Republic of)'),
+ (502, 'my', 2, 'Malaysia'),
+ (505, 'au', 2, 'Australia/Sydney', 'en', 11, 'Australia'),
+ (510, 'id', 2, 'Indonesia (Republic of)'),
+ (514, 'tl', 2, 'Democratic Republic of Timor-Leste'),
+ (515, 'ph', 2, 'Philippines (Republic of the)'),
+ (520, 'th', 2, 'Thailand'),
+ (525, 'sg', 2, 'Singapore', 'en', 11, 'Singapore (Republic of)'),
+ (528, 'bn', 2, 'Brunei Darussalam'),
+ (530, 'nz', 2, 'Pacific/Auckland', 'en', 'New Zealand'),
+ (534, 'mp', 2, 'Northern Mariana Islands (Commonwealth of the)'),
+ (535, 'gu', 2, 'Guam'),
+ (536, 'nr', 2, 'Nauru (Republic of)'),
+ (537, 'pg', 2, 'Papua New Guinea'),
+ (539, 'to', 2, 'Tonga (Kingdom of)'),
+ (540, 'sb', 2, 'Solomon Islands'),
+ (541, 'vu', 2, 'Vanuatu (Republic of)'),
+ (542, 'fj', 2, 'Fiji (Republic of)'),
+ (543, 'wf', 2, "Wallis and Futuna (Territoire franais d'outre-mer)"),
+ (544, 'as', 2, 'American Samoa'),
+ (545, 'ki', 2, 'Kiribati (Republic of)'),
+ (546, 'nc', 2, "New Caledonia (Territoire franais d'outre-mer)"),
+ (547, 'pf', 2, "French Polynesia (Territoire franais d'outre-mer)"),
+ (548, 'ck', 2, 'Cook Islands'),
+ (549, 'ws', 2, 'Samoa (Independent State of)'),
+ (550, 'fm', 2, 'Micronesia (Federated States of)'),
+ (551, 'mh', 2, 'Marshall Islands (Republic of the)'),
+ (552, 'pw', 2, 'Palau (Republic of)'),
+ (602, 'eg', 2, 'Egypt (Arab Republic of)'),
+ (603, 'dz', 2, "Algeria (People's Democratic Republic of)"),
+ (604, 'ma', 2, 'Morocco (Kingdom of)'),
+ (605, 'tn', 2, 'Tunisia'),
+ (606, 'ly', 2, "Libya (Socialist People's Libyan Arab Jamahiriya)"),
+ (607, 'gm', 2, 'Gambia (Republic of the)'),
+ (608, 'sn', 2, 'Senegal (Republic of)'),
+ (609, 'mr', 2, 'Mauritania (Islamic Republic of)'),
+ (610, 'ml', 2, 'Mali (Republic of)'),
+ (611, 'gn', 2, 'Guinea (Republic of)'),
+ (612, 'ci', 2, "Cte d'Ivoire (Republic of)"),
+ (613, 'bf', 2, 'Burkina Faso'),
+ (614, 'ne', 2, 'Niger (Republic of the)'),
+ (615, 'tg', 2, 'Togolese Republic'),
+ (616, 'bj', 2, 'Benin (Republic of)'),
+ (617, 'mu', 2, 'Mauritius (Republic of)'),
+ (618, 'lr', 2, 'Liberia (Republic of)'),
+ (619, 'sl', 2, 'Sierra Leone'),
+ (620, 'gh', 2, 'Ghana'),
+ (621, 'ng', 2, 'Nigeria (Federal Republic of)'),
+ (622, 'td', 2, 'Chad (Republic of)'),
+ (623, 'cf', 2, 'Central African Republic'),
+ (624, 'cm', 2, 'Cameroon (Republic of)'),
+ (625, 'cv', 2, 'Cape Verde (Republic of)'),
+ (626, 'st', 2, 'Sao Tome and Principe (Democratic Republic of)'),
+ (627, 'gq', 2, 'Equatorial Guinea (Republic of)'),
+ (628, 'ga', 2, 'Gabonese Republic'),
+ (629, 'cg', 2, 'Congo (Republic of the)'),
+ (630, 'cg', 2, 'Democratic Republic of the Congo'),
+ (631, 'ao', 2, 'Angola (Republic of)'),
+ (632, 'gw', 2, 'Guinea-Bissau (Republic of)'),
+ (633, 'sc', 2, 'Seychelles (Republic of)'),
+ (634, 'sd', 2, 'Sudan (Republic of the)'),
+ (635, 'rw', 2, 'Rwanda (Republic of)'),
+ (636, 'et', 2, 'Ethiopia (Federal Democratic Republic of)'),
+ (637, 'so', 2, 'Somali Democratic Republic'),
+ (638, 'dj', 2, 'Djibouti (Republic of)'),
+ (639, 'ke', 2, 'Kenya (Republic of)'),
+ (640, 'tz', 2, 'Tanzania (United Republic of)'),
+ (641, 'ug', 2, 'Uganda (Republic of)'),
+ (642, 'bi', 2, 'Burundi (Republic of)'),
+ (643, 'mz', 2, 'Mozambique (Republic of)'),
+ (645, 'zm', 2, 'Zambia (Republic of)'),
+ (646, 'mg', 2, 'Madagascar (Republic of)'),
+ (647, 're', 2, 'Reunion (French Department of)'),
+ (648, 'zw', 2, 'Zimbabwe (Republic of)'),
+ (649, 'na', 2, 'Namibia (Republic of)'),
+ (650, 'mw', 2, 'Malawi'),
+ (651, 'ls', 2, 'Lesotho (Kingdom of)'),
+ (652, 'bw', 2, 'Botswana (Republic of)'),
+ (653, 'sz', 2, 'Swaziland (Kingdom of)'),
+ (654, 'km', 2, 'Comoros (Union of the)'),
+ (655, 'za', 2, 'Africa/Johannesburg', 'en', 'South Africa (Republic of)'),
+ (657, 'er', 2, 'Eritrea'),
+ (702, 'bz', 2, 'Belize'),
+ (704, 'gt', 2, 'Guatemala (Republic of)'),
+ (706, 'sv', 2, 'El Salvador (Republic of)'),
+ (708, 'hn', 3, 'Honduras (Republic of)'),
+ (710, 'ni', 2, 'Nicaragua'),
+ (712, 'cr', 2, 'Costa Rica'),
+ (714, 'pa', 2, 'Panama (Republic of)'),
+ (716, 'pe', 2, 'Peru'),
+ (722, 'ar', 3, 'Argentine Republic'),
+ (724, 'br', 2, 'Brazil (Federative Republic of)'),
+ (730, 'cl', 2, 'Chile'),
+ (732, 'co', 3, 'Colombia (Republic of)'),
+ (734, 've', 2, 'Venezuela (Bolivarian Republic of)'),
+ (736, 'bo', 2, 'Bolivia (Republic of)'),
+ (738, 'gy', 2, 'Guyana'),
+ (740, 'ec', 2, 'Ecuador'),
+ (742, 'gf', 2, 'French Guiana (French Department of)'),
+ (744, 'py', 2, 'Paraguay (Republic of)'),
+ (746, 'sr', 2, 'Suriname (Republic of)'),
+ (748, 'uy', 2, 'Uruguay (Eastern Republic of)'),
+ (750, 'fk', 2, 'Falkland Islands (Malvinas)')]
+
+get_mcc = lambda elt: elt[0]
+get_iso = lambda elt: elt[1]
+get_sd = lambda elt: elt[2]
+get_tz = lambda elt: len(elt) > 4 and elt[3] or ''
+get_lang = lambda elt: len(elt) > 5 and elt[4] or ''
+get_wifi = lambda elt: len(elt) > 6 and elt[5] or 0
+
+mcc_codes = ['0x%04x' % get_mcc(elt) for elt in mcc_table]
+tz_set = sorted(x for x in set(get_tz(elt) for elt in mcc_table))
+lang_set = sorted(x for x in set(get_lang(elt) for elt in mcc_table))
+
+def mk_ind_code(elt):
+ iso = get_iso(elt)
+ iso_code = ((ord(iso[0]) << 8) | ord(iso[1])) & 0xFFFF # 16 bits
+ wifi = get_wifi(elt) & 0x000F # 4 bits
+ sd = get_sd(elt) & 0x0003 # 2 bits
+ tz_ind = tz_set.index(get_tz(elt)) & 0x001F # 5 bits
+ lang_ind = lang_set.index(get_lang(elt)) & 0x000F # 4 bits
+ return (iso_code << 16) | (wifi << 11) | (sd << 9) | (tz_ind << 4) | lang_ind
+
+ind_codes = ['0x%08x' % mk_ind_code(elt) for elt in mcc_table]
+
+def fmt_list(title, l, batch_sz):
+ sl = []
+ for i in range(len(l) / batch_sz + (len(l) % batch_sz and 1 or 0)):
+ j = i * batch_sz
+ sl.append((' ' * 8) + ', '.join(l[j:j + batch_sz]))
+ return ' private static final %s = {\n' % title + ',\n'.join(sl) + '\n };\n'
+
+def do_autogen_comment(extra_desc=[]):
+ print ' /' + '**\n * AUTO GENERATED (by the Python code above)'
+ for line in extra_desc:
+ print ' * %s' % line
+ print ' *' + '/'
+
+do_autogen_comment()
+print fmt_list('String[] TZ_STRINGS', ['"%s"' % x for x in tz_set], 1)
+do_autogen_comment()
+print fmt_list('String[] LANG_STRINGS', ['"%s"' % x for x in lang_set], 10)
+do_autogen_comment(['This table is a list of MCC codes. The index in this table',
+ 'of a given MCC code is the index of extra information about',
+ 'that MCC in the IND_CODES table.'])
+print fmt_list('short[] MCC_CODES', mcc_codes, 10)
+do_autogen_comment(['The values in this table are broken down as follows (msb to lsb):',
+ ' iso country code 16 bits',
+ ' (unused) 1 bit',
+ ' wifi channel 4 bits',
+ ' smalled digit 2 bits',
+ ' default timezone 5 bits',
+ ' default language 4 bits'])
+print fmt_list('int[] IND_CODES', ind_codes, 6)
+
+def parse_ind_code(ind):
+ mcc = eval(mcc_codes[ind])
+ code = eval(ind_codes[ind])
+ iso_lsb = int((code >> 16) & 0x00FF)
+ iso_msb = int((code >> 24) & 0x00FF)
+ iso = '%s%s' % (chr(iso_msb), chr(iso_lsb))
+ wifi = int((code >> 11) & 0x000F)
+ sd = int((code >> 9) & 0x0003)
+ tz_ind = (code >> 4) & 0x001F
+ lang_ind = (code >> 0) & 0x000F
+ return (mcc, iso, sd, tz_set[tz_ind], lang_set[lang_ind], wifi)
+
+fmt_str = 'mcc = %s, iso = %s, sd = %s, tz = %s, lang = %s, wifi = %s'
+orig_table = [fmt_str % (get_mcc(elt), get_iso(elt), get_sd(elt),
+ get_tz(elt), get_lang(elt), get_wifi(elt))
+ for elt in mcc_table]
+derived_table = [fmt_str % parse_ind_code(i) for i in range(len(ind_codes))]
+for i in range(len(orig_table)):
+ if orig_table[i] == derived_table[i]: continue
+ print 'MISMATCH ERROR : ', orig_table[i], " != ", derived_table[i]
+
+*/
/**
* Mobile Country Code
@@ -26,404 +360,197 @@ import java.util.Collections;
*/
public final class MccTable
{
- static ArrayList<MccEntry> table;
-
- static class MccEntry implements Comparable<MccEntry>
- {
- int mcc;
- String iso;
- int smallestDigitsMnc;
- String timezone;
- String language;
- int wifiChannelsAllowed;
-
- MccEntry(int mnc, String iso, int smallestDigitsMCC) {
- this(mnc, iso, smallestDigitsMCC, null);
- }
-
- MccEntry(int mnc, String iso, int smallestDigitsMCC, String timezone) {
- this(mnc, iso, smallestDigitsMCC, timezone, null);
- }
-
- MccEntry(int mnc, String iso, int smallestDigitsMCC, String timezone, String language) {
- this(mnc, iso, smallestDigitsMCC, timezone, language, 0);
- }
-
- MccEntry(int mnc, String iso, int smallestDigitsMCC, String timezone, String language, int wifiChannels) {
- this.mcc = mnc;
- this.iso = iso;
- this.smallestDigitsMnc = smallestDigitsMCC;
- this.timezone = timezone;
- this.language = language;
- this.wifiChannelsAllowed = wifiChannels;
- }
-
- public int compareTo(MccEntry o)
- {
- return mcc - o.mcc;
- }
- }
-
- private static MccEntry
- entryForMcc(int mcc)
- {
- int index;
+ /**
+ * AUTO GENERATED (by the Python code above)
+ */
+ private static final String[] TZ_STRINGS = {
+ "",
+ "Africa/Johannesburg",
+ "Asia/Tokyo",
+ "Australia/Sydney",
+ "Europe/Amsterdam",
+ "Europe/Berlin",
+ "Europe/Dublin",
+ "Europe/London",
+ "Europe/Madrid",
+ "Europe/Paris",
+ "Europe/Prague",
+ "Europe/Rome",
+ "Europe/Vienna",
+ "Europe/Warsaw",
+ "Europe/Zurich",
+ "Pacific/Auckland",
+ "Singapore"
+ };
- MccEntry m;
+ /**
+ * AUTO GENERATED (by the Python code above)
+ */
+ private static final String[] LANG_STRINGS = {
+ "", "cs", "de", "en", "es", "fr", "it", "ja", "nl"
+ };
- m = new MccEntry(mcc, null, 0);
+ /**
+ * AUTO GENERATED (by the Python code above)
+ * This table is a list of MCC codes. The index in this table
+ * of a given MCC code is the index of extra information about
+ * that MCC in the IND_CODES table.
+ */
+ private static final short[] MCC_CODES = {
+ 0x00ca, 0x00cc, 0x00ce, 0x00d0, 0x00d4, 0x00d5, 0x00d6, 0x00d8, 0x00da, 0x00db,
+ 0x00dc, 0x00de, 0x00e1, 0x00e2, 0x00e4, 0x00e6, 0x00e7, 0x00e8, 0x00ea, 0x00eb,
+ 0x00ee, 0x00f0, 0x00f2, 0x00f4, 0x00f6, 0x00f7, 0x00f8, 0x00fa, 0x00ff, 0x0101,
+ 0x0103, 0x0104, 0x0106, 0x010a, 0x010c, 0x010e, 0x0110, 0x0112, 0x0114, 0x0116,
+ 0x0118, 0x011a, 0x011b, 0x011c, 0x011e, 0x0120, 0x0121, 0x0122, 0x0124, 0x0125,
+ 0x0126, 0x0127, 0x0129, 0x012e, 0x0134, 0x0136, 0x0137, 0x0138, 0x0139, 0x013a,
+ 0x013b, 0x013c, 0x014a, 0x014c, 0x014e, 0x0152, 0x0154, 0x0156, 0x0158, 0x015a,
+ 0x015c, 0x015e, 0x0160, 0x0162, 0x0164, 0x0166, 0x0168, 0x016a, 0x016b, 0x016c,
+ 0x016d, 0x016e, 0x0170, 0x0172, 0x0174, 0x0176, 0x0178, 0x0190, 0x0191, 0x0192,
+ 0x0194, 0x0195, 0x019a, 0x019c, 0x019d, 0x019e, 0x019f, 0x01a0, 0x01a1, 0x01a2,
+ 0x01a3, 0x01a4, 0x01a5, 0x01a6, 0x01a7, 0x01a8, 0x01a9, 0x01aa, 0x01ab, 0x01ac,
+ 0x01ad, 0x01ae, 0x01af, 0x01b0, 0x01b2, 0x01b4, 0x01b5, 0x01b6, 0x01b8, 0x01b9,
+ 0x01c2, 0x01c4, 0x01c6, 0x01c7, 0x01c8, 0x01c9, 0x01cc, 0x01cd, 0x01d2, 0x01d3,
+ 0x01d6, 0x01d8, 0x01f6, 0x01f9, 0x01fe, 0x0202, 0x0203, 0x0208, 0x020d, 0x0210,
+ 0x0212, 0x0216, 0x0217, 0x0218, 0x0219, 0x021b, 0x021c, 0x021d, 0x021e, 0x021f,
+ 0x0220, 0x0221, 0x0222, 0x0223, 0x0224, 0x0225, 0x0226, 0x0227, 0x0228, 0x025a,
+ 0x025b, 0x025c, 0x025d, 0x025e, 0x025f, 0x0260, 0x0261, 0x0262, 0x0263, 0x0264,
+ 0x0265, 0x0266, 0x0267, 0x0268, 0x0269, 0x026a, 0x026b, 0x026c, 0x026d, 0x026e,
+ 0x026f, 0x0270, 0x0271, 0x0272, 0x0273, 0x0274, 0x0275, 0x0276, 0x0277, 0x0278,
+ 0x0279, 0x027a, 0x027b, 0x027c, 0x027d, 0x027e, 0x027f, 0x0280, 0x0281, 0x0282,
+ 0x0283, 0x0285, 0x0286, 0x0287, 0x0288, 0x0289, 0x028a, 0x028b, 0x028c, 0x028d,
+ 0x028e, 0x028f, 0x0291, 0x02be, 0x02c0, 0x02c2, 0x02c4, 0x02c6, 0x02c8, 0x02ca,
+ 0x02cc, 0x02d2, 0x02d4, 0x02da, 0x02dc, 0x02de, 0x02e0, 0x02e2, 0x02e4, 0x02e6,
+ 0x02e8, 0x02ea, 0x02ec, 0x02ee
+ };
- index = Collections.binarySearch(table, m);
+ /**
+ * AUTO GENERATED (by the Python code above)
+ * The values in this table are broken down as follows (msb to lsb):
+ * iso country code 16 bits
+ * (unused) 1 bit
+ * wifi channel 4 bits
+ * smalled digit 2 bits
+ * default timezone 5 bits
+ * default language 4 bits
+ */
+ private static final int[] IND_CODES = {
+ 0x67720400, 0x6e6c6c48, 0x62650400, 0x66720495, 0x6d630400, 0x61640400,
+ 0x65730484, 0x68750400, 0x62610400, 0x68720400, 0x72730400, 0x697404b6,
+ 0x766104b6, 0x726f0400, 0x636804e2, 0x637a6ca1, 0x736b0400, 0x61746cc2,
+ 0x67626c73, 0x67626c73, 0x646b0400, 0x73650400, 0x6e6f0400, 0x66690400,
+ 0x6c740400, 0x6c760400, 0x65650400, 0x72750400, 0x75610400, 0x62790400,
+ 0x6d640400, 0x706c04d0, 0x64656c52, 0x67690400, 0x70740400, 0x6c750400,
+ 0x69650463, 0x69730400, 0x616c0400, 0x6d740400, 0x63790400, 0x67650400,
+ 0x616d0400, 0x62670400, 0x74720400, 0x666f0400, 0x67650400, 0x676c0400,
+ 0x736d0400, 0x736c0400, 0x6d6b0400, 0x6c690400, 0x6d650400, 0x63615c00,
+ 0x706d0400, 0x75735e03, 0x75735e03, 0x75735e03, 0x75735e03, 0x75735e03,
+ 0x75735e03, 0x75735e03, 0x70720400, 0x76690400, 0x6d780600, 0x6a6d0600,
+ 0x67700400, 0x62620600, 0x61670600, 0x6b790600, 0x76670600, 0x626d0400,
+ 0x67640400, 0x6d730400, 0x6b6e0400, 0x6c630400, 0x76630400, 0x6e6c0400,
+ 0x61770400, 0x62730400, 0x61690600, 0x646d0400, 0x63750400, 0x646f0400,
+ 0x68740400, 0x74740400, 0x74630400, 0x617a0400, 0x6b7a0400, 0x62740400,
+ 0x696e0400, 0x696e0400, 0x706b0400, 0x61660400, 0x6c6b0400, 0x6d6d0400,
+ 0x6c620400, 0x6a6f0400, 0x73790400, 0x69710400, 0x6b770400, 0x73610400,
+ 0x79650400, 0x6f6d0400, 0x70730400, 0x61650400, 0x696c0400, 0x62680400,
+ 0x71610400, 0x6d6e0400, 0x6e700400, 0x61650400, 0x61650400, 0x69720400,
+ 0x757a0400, 0x746a0400, 0x6b670400, 0x746d0400, 0x6a707427, 0x6a707427,
+ 0x6b720400, 0x766e0400, 0x686b0400, 0x6d6f0400, 0x6b680400, 0x6c610400,
+ 0x636e0400, 0x636e0400, 0x74770400, 0x6b700400, 0x62640400, 0x6d760400,
+ 0x6d790400, 0x61755c33, 0x69640400, 0x746c0400, 0x70680400, 0x74680400,
+ 0x73675d03, 0x626e0400, 0x6e7a04f3, 0x6d700400, 0x67750400, 0x6e720400,
+ 0x70670400, 0x746f0400, 0x73620400, 0x76750400, 0x666a0400, 0x77660400,
+ 0x61730400, 0x6b690400, 0x6e630400, 0x70660400, 0x636b0400, 0x77730400,
+ 0x666d0400, 0x6d680400, 0x70770400, 0x65670400, 0x647a0400, 0x6d610400,
+ 0x746e0400, 0x6c790400, 0x676d0400, 0x736e0400, 0x6d720400, 0x6d6c0400,
+ 0x676e0400, 0x63690400, 0x62660400, 0x6e650400, 0x74670400, 0x626a0400,
+ 0x6d750400, 0x6c720400, 0x736c0400, 0x67680400, 0x6e670400, 0x74640400,
+ 0x63660400, 0x636d0400, 0x63760400, 0x73740400, 0x67710400, 0x67610400,
+ 0x63670400, 0x63670400, 0x616f0400, 0x67770400, 0x73630400, 0x73640400,
+ 0x72770400, 0x65740400, 0x736f0400, 0x646a0400, 0x6b650400, 0x747a0400,
+ 0x75670400, 0x62690400, 0x6d7a0400, 0x7a6d0400, 0x6d670400, 0x72650400,
+ 0x7a770400, 0x6e610400, 0x6d770400, 0x6c730400, 0x62770400, 0x737a0400,
+ 0x6b6d0400, 0x7a610413, 0x65720400, 0x627a0400, 0x67740400, 0x73760400,
+ 0x686e0600, 0x6e690400, 0x63720400, 0x70610400, 0x70650400, 0x61720600,
+ 0x62720400, 0x636c0400, 0x636f0600, 0x76650400, 0x626f0400, 0x67790400,
+ 0x65630400, 0x67660400, 0x70790400, 0x73720400, 0x75790400, 0x666b0400
+ };
+ /**
+ * Given a GSM Mobile Country Code, returns a default time zone ID
+ * if available. Returns null if unavailable.
+ */
+ public static String defaultTimeZoneForMcc(int mcc) {
+ int index = Arrays.binarySearch(MCC_CODES, (short)mcc);
if (index < 0) {
return null;
- } else {
- return table.get(index);
}
- }
-
- /**
- * Returns a default time zone ID for the given MCC.
- * @param mcc Mobile Country Code
- * @return default TimeZone ID, or null if not specified
- */
- /* package */ static String defaultTimeZoneForMcc(int mcc) {
- MccEntry entry;
-
- entry = entryForMcc(mcc);
-
- if (entry == null) {
+ int indCode = IND_CODES[index];
+ int tzInd = (indCode >>> 4) & 0x001F;
+ String tz = TZ_STRINGS[tzInd];
+ if (tz == "") {
return null;
- } else {
- return entry.timezone;
}
+ return tz;
}
/**
- * Given a GSM Mobile Country Code, returns
- * an ISO two-character country code if available.
- * Returns "" if unavailable.
+ * Given a GSM Mobile Country Code, returns an ISO two-character
+ * country code if available. Returns "" if unavailable.
*/
- public static String
- countryCodeForMcc(int mcc)
- {
- MccEntry entry;
-
- entry = entryForMcc(mcc);
-
- if (entry == null) {
+ public static String countryCodeForMcc(int mcc) {
+ int index = Arrays.binarySearch(MCC_CODES, (short)mcc);
+ if (index < 0) {
return "";
- } else {
- return entry.iso;
}
+ int indCode = IND_CODES[index];
+ byte[] iso = {(byte)((indCode >>> 24) & 0x00FF), (byte)((indCode >>> 16) & 0x00FF)};
+ return new String(iso);
}
/**
- * Given a GSM Mobile Country Code, returns
- * an ISO 2-3 character language code if available.
- * Returns null if unavailable.
+ * Given a GSM Mobile Country Code, returns an ISO 2-3 character
+ * language code if available. Returns null if unavailable.
*/
- /* package */ static String defaultLanguageForMcc(int mcc) {
- MccEntry entry;
-
- entry = entryForMcc(mcc);
-
- if (entry == null) {
+ public static String defaultLanguageForMcc(int mcc) {
+ int index = Arrays.binarySearch(MCC_CODES, (short)mcc);
+ if (index < 0) {
return null;
- } else {
- return entry.language;
}
+ int indCode = IND_CODES[index];
+ int langInd = indCode & 0x000F;
+ String lang = LANG_STRINGS[langInd];
+ if (lang == "") {
+ return null;
+ }
+ return lang;
}
/**
- * Given a GSM Mobile Country Code, returns
- * the smallest number of digits that M if available.
- * Returns "" if unavailable.
+ * Given a GSM Mobile Country Code, returns the corresponding
+ * smallest number of digits field. Returns 2 if unavailable.
*/
- public static int
- smallestDigitsMccForMnc(int mcc)
- {
- MccEntry entry;
-
- entry = entryForMcc(mcc);
-
- if (entry == null) {
+ public static int smallestDigitsMccForMnc(int mcc) {
+ int index = Arrays.binarySearch(MCC_CODES, (short)mcc);
+ if (index < 0) {
return 2;
- } else {
- return entry.smallestDigitsMnc;
}
+ int indCode = IND_CODES[index];
+ int smDig = (indCode >>> 9) & 0x0003;
+ return smDig;
}
/**
- * Given a GSM Mobile Country Code, returns
- * the number of wifi channels allowed in that country.
- * Returns 0 if unavailable
+ * Given a GSM Mobile Country Code, returns the number of wifi
+ * channels allowed in that country. Returns 0 if unavailable.
*/
public static int wifiChannelsForMcc(int mcc) {
- MccEntry entry;
-
- entry = entryForMcc(mcc);
-
- if (entry == null) {
+ int index = Arrays.binarySearch(MCC_CODES, (short)mcc);
+ if (index < 0) {
return 0;
- } else {
- return entry.wifiChannelsAllowed;
}
+ int indCode = IND_CODES[index];
+ int wifi = (indCode >>> 11) & 0x000F;
+ return wifi;
}
- static {
- table = new ArrayList<MccEntry>(240);
-
-
- /*
- * The table below is built from two resources:
- *
- * 1) ITU "Mobile Network Code (MNC) for the international
- * identification plan for mobile terminals and mobile users"
- * which is available as an annex to the ITU operational bulletin
- * available here: http://www.itu.int/itu-t/bulletin/annex.html
- *
- * 2) The ISO 3166 country codes list, available here:
- * http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html
- *
- * This table has not been verified.
- *
- * FIXME(mkf) this should be stored in a more efficient representation
- */
-
- table.add(new MccEntry(202,"gr",2)); //Greece
- table.add(new MccEntry(204,"nl",2,"Europe/Amsterdam","nl",13)); //Netherlands (Kingdom of the)
- table.add(new MccEntry(206,"be",2)); //Belgium
- table.add(new MccEntry(208,"fr",2,"Europe/Paris","fr")); //France
- table.add(new MccEntry(212,"mc",2)); //Monaco (Principality of)
- table.add(new MccEntry(213,"ad",2)); //Andorra (Principality of)
- table.add(new MccEntry(214,"es",2,"Europe/Madrid","es")); //Spain
- table.add(new MccEntry(216,"hu",2)); //Hungary (Republic of)
- table.add(new MccEntry(218,"ba",2)); //Bosnia and Herzegovina
- table.add(new MccEntry(219,"hr",2)); //Croatia (Republic of)
- table.add(new MccEntry(220,"rs",2)); //Serbia and Montenegro
- table.add(new MccEntry(222,"it",2,"Europe/Rome","it")); //Italy
- table.add(new MccEntry(225,"va",2,"Europe/Rome","it")); //Vatican City State
- table.add(new MccEntry(226,"ro",2)); //Romania
- table.add(new MccEntry(228,"ch",2,"Europe/Zurich","de")); //Switzerland (Confederation of)
- table.add(new MccEntry(230,"cz",2,"Europe/Prague","cs", 13)); //Czech Republic
- table.add(new MccEntry(231,"sk",2)); //Slovak Republic
- table.add(new MccEntry(232,"at",2,"Europe/Vienna","de", 13)); //Austria
- table.add(new MccEntry(234,"gb",2,"Europe/London","en", 13)); //United Kingdom of Great Britain and Northern Ireland
- table.add(new MccEntry(235,"gb",2,"Europe/London","en", 13)); //United Kingdom of Great Britain and Northern Ireland
- table.add(new MccEntry(238,"dk",2)); //Denmark
- table.add(new MccEntry(240,"se",2)); //Sweden
- table.add(new MccEntry(242,"no",2)); //Norway
- table.add(new MccEntry(244,"fi",2)); //Finland
- table.add(new MccEntry(246,"lt",2)); //Lithuania (Republic of)
- table.add(new MccEntry(247,"lv",2)); //Latvia (Republic of)
- table.add(new MccEntry(248,"ee",2)); //Estonia (Republic of)
- table.add(new MccEntry(250,"ru",2)); //Russian Federation
- table.add(new MccEntry(255,"ua",2)); //Ukraine
- table.add(new MccEntry(257,"by",2)); //Belarus (Republic of)
- table.add(new MccEntry(259,"md",2)); //Moldova (Republic of)
- table.add(new MccEntry(260,"pl",2,"Europe/Warsaw")); //Poland (Republic of)
- table.add(new MccEntry(262,"de",2,"Europe/Berlin","de", 13)); //Germany (Federal Republic of)
- table.add(new MccEntry(266,"gi",2)); //Gibraltar
- table.add(new MccEntry(268,"pt",2)); //Portugal
- table.add(new MccEntry(270,"lu",2)); //Luxembourg
- table.add(new MccEntry(272,"ie",2,"Europe/Dublin","en")); //Ireland
- table.add(new MccEntry(274,"is",2)); //Iceland
- table.add(new MccEntry(276,"al",2)); //Albania (Republic of)
- table.add(new MccEntry(278,"mt",2)); //Malta
- table.add(new MccEntry(280,"cy",2)); //Cyprus (Republic of)
- table.add(new MccEntry(282,"ge",2)); //Georgia
- table.add(new MccEntry(283,"am",2)); //Armenia (Republic of)
- table.add(new MccEntry(284,"bg",2)); //Bulgaria (Republic of)
- table.add(new MccEntry(286,"tr",2)); //Turkey
- table.add(new MccEntry(288,"fo",2)); //Faroe Islands
- table.add(new MccEntry(290,"gl",2)); //Greenland (Denmark)
- table.add(new MccEntry(292,"sm",2)); //San Marino (Republic of)
- table.add(new MccEntry(293,"sl",2)); //Slovenia (Republic of)
- table.add(new MccEntry(294,"mk",2)); //The Former Yugoslav Republic of Macedonia
- table.add(new MccEntry(295,"li",2)); //Liechtenstein (Principality of)
- table.add(new MccEntry(302,"ca",2, "", "", 11)); //Canada
- table.add(new MccEntry(308,"pm",2)); //Saint Pierre and Miquelon (Collectivit territoriale de la Rpublique franaise)
- table.add(new MccEntry(310,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(311,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(312,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(313,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(314,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(315,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(316,"us",3,"","en", 11)); //United States of America
- table.add(new MccEntry(330,"pr",2)); //Puerto Rico
- table.add(new MccEntry(332,"vi",2)); //United States Virgin Islands
- table.add(new MccEntry(334,"mx",3)); //Mexico
- table.add(new MccEntry(338,"jm",3)); //Jamaica
- table.add(new MccEntry(340,"gp",2)); //Guadeloupe (French Department of)
- table.add(new MccEntry(342,"bb",3)); //Barbados
- table.add(new MccEntry(344,"ag",3)); //Antigua and Barbuda
- table.add(new MccEntry(346,"ky",3)); //Cayman Islands
- table.add(new MccEntry(348,"vg",3)); //British Virgin Islands
- table.add(new MccEntry(350,"bm",2)); //Bermuda
- table.add(new MccEntry(352,"gd",2)); //Grenada
- table.add(new MccEntry(354,"ms",2)); //Montserrat
- table.add(new MccEntry(356,"kn",2)); //Saint Kitts and Nevis
- table.add(new MccEntry(358,"lc",2)); //Saint Lucia
- table.add(new MccEntry(360,"vc",2)); //Saint Vincent and the Grenadines
- table.add(new MccEntry(362,"nl",2)); //Netherlands Antilles
- table.add(new MccEntry(363,"aw",2)); //Aruba
- table.add(new MccEntry(364,"bs",2)); //Bahamas (Commonwealth of the)
- table.add(new MccEntry(365,"ai",3)); //Anguilla
- table.add(new MccEntry(366,"dm",2)); //Dominica (Commonwealth of)
- table.add(new MccEntry(368,"cu",2)); //Cuba
- table.add(new MccEntry(370,"do",2)); //Dominican Republic
- table.add(new MccEntry(372,"ht",2)); //Haiti (Republic of)
- table.add(new MccEntry(374,"tt",2)); //Trinidad and Tobago
- table.add(new MccEntry(376,"tc",2)); //Turks and Caicos Islands
- table.add(new MccEntry(400,"az",2)); //Azerbaijani Republic
- table.add(new MccEntry(401,"kz",2)); //Kazakhstan (Republic of)
- table.add(new MccEntry(402,"bt",2)); //Bhutan (Kingdom of)
- table.add(new MccEntry(404,"in",2)); //India (Republic of)
- table.add(new MccEntry(405,"in",2)); //India (Republic of)
- table.add(new MccEntry(410,"pk",2)); //Pakistan (Islamic Republic of)
- table.add(new MccEntry(412,"af",2)); //Afghanistan
- table.add(new MccEntry(413,"lk",2)); //Sri Lanka (Democratic Socialist Republic of)
- table.add(new MccEntry(414,"mm",2)); //Myanmar (Union of)
- table.add(new MccEntry(415,"lb",2)); //Lebanon
- table.add(new MccEntry(416,"jo",2)); //Jordan (Hashemite Kingdom of)
- table.add(new MccEntry(417,"sy",2)); //Syrian Arab Republic
- table.add(new MccEntry(418,"iq",2)); //Iraq (Republic of)
- table.add(new MccEntry(419,"kw",2)); //Kuwait (State of)
- table.add(new MccEntry(420,"sa",2)); //Saudi Arabia (Kingdom of)
- table.add(new MccEntry(421,"ye",2)); //Yemen (Republic of)
- table.add(new MccEntry(422,"om",2)); //Oman (Sultanate of)
- table.add(new MccEntry(424,"ae",2)); //United Arab Emirates
- table.add(new MccEntry(425,"il",2)); //Israel (State of)
- table.add(new MccEntry(426,"bh",2)); //Bahrain (Kingdom of)
- table.add(new MccEntry(427,"qa",2)); //Qatar (State of)
- table.add(new MccEntry(428,"mn",2)); //Mongolia
- table.add(new MccEntry(429,"np",2)); //Nepal
- table.add(new MccEntry(430,"ae",2)); //United Arab Emirates
- table.add(new MccEntry(431,"ae",2)); //United Arab Emirates
- table.add(new MccEntry(432,"ir",2)); //Iran (Islamic Republic of)
- table.add(new MccEntry(434,"uz",2)); //Uzbekistan (Republic of)
- table.add(new MccEntry(436,"tj",2)); //Tajikistan (Republic of)
- table.add(new MccEntry(437,"kg",2)); //Kyrgyz Republic
- table.add(new MccEntry(438,"tm",2)); //Turkmenistan
- table.add(new MccEntry(440,"jp",2,"Asia/Tokyo","ja", 14)); //Japan
- table.add(new MccEntry(441,"jp",2,"Asia/Tokyo","ja", 14)); //Japan
- table.add(new MccEntry(450,"kr",2)); //Korea (Republic of)
- table.add(new MccEntry(452,"vn",2)); //Viet Nam (Socialist Republic of)
- table.add(new MccEntry(454,"hk",2)); //"Hong Kong, China"
- table.add(new MccEntry(455,"mo",2)); //"Macao, China"
- table.add(new MccEntry(456,"kh",2)); //Cambodia (Kingdom of)
- table.add(new MccEntry(457,"la",2)); //Lao People's Democratic Republic
- table.add(new MccEntry(460,"cn",2)); //China (People's Republic of)
- table.add(new MccEntry(461,"cn",2)); //China (People's Republic of)
- table.add(new MccEntry(466,"tw",2)); //"Taiwan, China"
- table.add(new MccEntry(467,"kp",2)); //Democratic People's Republic of Korea
- table.add(new MccEntry(470,"bd",2)); //Bangladesh (People's Republic of)
- table.add(new MccEntry(472,"mv",2)); //Maldives (Republic of)
- table.add(new MccEntry(502,"my",2)); //Malaysia
- table.add(new MccEntry(505,"au",2,"Australia/Sydney","en", 11)); //Australia
- table.add(new MccEntry(510,"id",2)); //Indonesia (Republic of)
- table.add(new MccEntry(514,"tl",2)); //Democratic Republic of Timor-Leste
- table.add(new MccEntry(515,"ph",2)); //Philippines (Republic of the)
- table.add(new MccEntry(520,"th",2)); //Thailand
- table.add(new MccEntry(525,"sg",2,"Singapore","en", 11)); //Singapore (Republic of)
- table.add(new MccEntry(528,"bn",2)); //Brunei Darussalam
- table.add(new MccEntry(530,"nz",2,"Pacific/Auckland", "en")); //New Zealand
- table.add(new MccEntry(534,"mp",2)); //Northern Mariana Islands (Commonwealth of the)
- table.add(new MccEntry(535,"gu",2)); //Guam
- table.add(new MccEntry(536,"nr",2)); //Nauru (Republic of)
- table.add(new MccEntry(537,"pg",2)); //Papua New Guinea
- table.add(new MccEntry(539,"to",2)); //Tonga (Kingdom of)
- table.add(new MccEntry(540,"sb",2)); //Solomon Islands
- table.add(new MccEntry(541,"vu",2)); //Vanuatu (Republic of)
- table.add(new MccEntry(542,"fj",2)); //Fiji (Republic of)
- table.add(new MccEntry(543,"wf",2)); //Wallis and Futuna (Territoire franais d'outre-mer)
- table.add(new MccEntry(544,"as",2)); //American Samoa
- table.add(new MccEntry(545,"ki",2)); //Kiribati (Republic of)
- table.add(new MccEntry(546,"nc",2)); //New Caledonia (Territoire franais d'outre-mer)
- table.add(new MccEntry(547,"pf",2)); //French Polynesia (Territoire franais d'outre-mer)
- table.add(new MccEntry(548,"ck",2)); //Cook Islands
- table.add(new MccEntry(549,"ws",2)); //Samoa (Independent State of)
- table.add(new MccEntry(550,"fm",2)); //Micronesia (Federated States of)
- table.add(new MccEntry(551,"mh",2)); //Marshall Islands (Republic of the)
- table.add(new MccEntry(552,"pw",2)); //Palau (Republic of)
- table.add(new MccEntry(602,"eg",2)); //Egypt (Arab Republic of)
- table.add(new MccEntry(603,"dz",2)); //Algeria (People's Democratic Republic of)
- table.add(new MccEntry(604,"ma",2)); //Morocco (Kingdom of)
- table.add(new MccEntry(605,"tn",2)); //Tunisia
- table.add(new MccEntry(606,"ly",2)); //Libya (Socialist People's Libyan Arab Jamahiriya)
- table.add(new MccEntry(607,"gm",2)); //Gambia (Republic of the)
- table.add(new MccEntry(608,"sn",2)); //Senegal (Republic of)
- table.add(new MccEntry(609,"mr",2)); //Mauritania (Islamic Republic of)
- table.add(new MccEntry(610,"ml",2)); //Mali (Republic of)
- table.add(new MccEntry(611,"gn",2)); //Guinea (Republic of)
- table.add(new MccEntry(612,"ci",2)); //Cte d'Ivoire (Republic of)
- table.add(new MccEntry(613,"bf",2)); //Burkina Faso
- table.add(new MccEntry(614,"ne",2)); //Niger (Republic of the)
- table.add(new MccEntry(615,"tg",2)); //Togolese Republic
- table.add(new MccEntry(616,"bj",2)); //Benin (Republic of)
- table.add(new MccEntry(617,"mu",2)); //Mauritius (Republic of)
- table.add(new MccEntry(618,"lr",2)); //Liberia (Republic of)
- table.add(new MccEntry(619,"sl",2)); //Sierra Leone
- table.add(new MccEntry(620,"gh",2)); //Ghana
- table.add(new MccEntry(621,"ng",2)); //Nigeria (Federal Republic of)
- table.add(new MccEntry(622,"td",2)); //Chad (Republic of)
- table.add(new MccEntry(623,"cf",2)); //Central African Republic
- table.add(new MccEntry(624,"cm",2)); //Cameroon (Republic of)
- table.add(new MccEntry(625,"cv",2)); //Cape Verde (Republic of)
- table.add(new MccEntry(626,"st",2)); //Sao Tome and Principe (Democratic Republic of)
- table.add(new MccEntry(627,"gq",2)); //Equatorial Guinea (Republic of)
- table.add(new MccEntry(628,"ga",2)); //Gabonese Republic
- table.add(new MccEntry(629,"cg",2)); //Congo (Republic of the)
- table.add(new MccEntry(630,"cg",2)); //Democratic Republic of the Congo
- table.add(new MccEntry(631,"ao",2)); //Angola (Republic of)
- table.add(new MccEntry(632,"gw",2)); //Guinea-Bissau (Republic of)
- table.add(new MccEntry(633,"sc",2)); //Seychelles (Republic of)
- table.add(new MccEntry(634,"sd",2)); //Sudan (Republic of the)
- table.add(new MccEntry(635,"rw",2)); //Rwanda (Republic of)
- table.add(new MccEntry(636,"et",2)); //Ethiopia (Federal Democratic Republic of)
- table.add(new MccEntry(637,"so",2)); //Somali Democratic Republic
- table.add(new MccEntry(638,"dj",2)); //Djibouti (Republic of)
- table.add(new MccEntry(639,"ke",2)); //Kenya (Republic of)
- table.add(new MccEntry(640,"tz",2)); //Tanzania (United Republic of)
- table.add(new MccEntry(641,"ug",2)); //Uganda (Republic of)
- table.add(new MccEntry(642,"bi",2)); //Burundi (Republic of)
- table.add(new MccEntry(643,"mz",2)); //Mozambique (Republic of)
- table.add(new MccEntry(645,"zm",2)); //Zambia (Republic of)
- table.add(new MccEntry(646,"mg",2)); //Madagascar (Republic of)
- table.add(new MccEntry(647,"re",2)); //Reunion (French Department of)
- table.add(new MccEntry(648,"zw",2)); //Zimbabwe (Republic of)
- table.add(new MccEntry(649,"na",2)); //Namibia (Republic of)
- table.add(new MccEntry(650,"mw",2)); //Malawi
- table.add(new MccEntry(651,"ls",2)); //Lesotho (Kingdom of)
- table.add(new MccEntry(652,"bw",2)); //Botswana (Republic of)
- table.add(new MccEntry(653,"sz",2)); //Swaziland (Kingdom of)
- table.add(new MccEntry(654,"km",2)); //Comoros (Union of the)
- table.add(new MccEntry(655,"za",2,"Africa/Johannesburg","en")); //South Africa (Republic of)
- table.add(new MccEntry(657,"er",2)); //Eritrea
- table.add(new MccEntry(702,"bz",2)); //Belize
- table.add(new MccEntry(704,"gt",2)); //Guatemala (Republic of)
- table.add(new MccEntry(706,"sv",2)); //El Salvador (Republic of)
- table.add(new MccEntry(708,"hn",3)); //Honduras (Republic of)
- table.add(new MccEntry(710,"ni",2)); //Nicaragua
- table.add(new MccEntry(712,"cr",2)); //Costa Rica
- table.add(new MccEntry(714,"pa",2)); //Panama (Republic of)
- table.add(new MccEntry(716,"pe",2)); //Peru
- table.add(new MccEntry(722,"ar",3)); //Argentine Republic
- table.add(new MccEntry(724,"br",2)); //Brazil (Federative Republic of)
- table.add(new MccEntry(730,"cl",2)); //Chile
- table.add(new MccEntry(732,"co",3)); //Colombia (Republic of)
- table.add(new MccEntry(734,"ve",2)); //Venezuela (Bolivarian Republic of)
- table.add(new MccEntry(736,"bo",2)); //Bolivia (Republic of)
- table.add(new MccEntry(738,"gy",2)); //Guyana
- table.add(new MccEntry(740,"ec",2)); //Ecuador
- table.add(new MccEntry(742,"gf",2)); //French Guiana (French Department of)
- table.add(new MccEntry(744,"py",2)); //Paraguay (Republic of)
- table.add(new MccEntry(746,"sr",2)); //Suriname (Republic of)
- table.add(new MccEntry(748,"uy",2)); //Uruguay (Eastern Republic of)
- table.add(new MccEntry(750,"fk",2)); //Falkland Islands (Malvinas)
- //table.add(new MccEntry(901,"",2)); //"International Mobile, shared code"
-
- Collections.sort(table);
- }
}
diff --git a/tests/AndroidTests/src/com/android/unit_tests/MccTableTest.java b/tests/AndroidTests/src/com/android/unit_tests/MccTableTest.java
new file mode 100644
index 000000000000..875376a1488e
--- /dev/null
+++ b/tests/AndroidTests/src/com/android/unit_tests/MccTableTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2006 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.
+ */
+
+package com.android.unit_tests;
+
+import com.android.internal.telephony.gsm.MccTable;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import android.util.Log;
+
+public class MccTableTest extends AndroidTestCase {
+ private final static String LOG_TAG = "GSM";
+
+ @SmallTest
+ public void testTimeZone() throws Exception {
+ assertEquals(MccTable.defaultTimeZoneForMcc(208), "Europe/Paris");
+ assertEquals(MccTable.defaultTimeZoneForMcc(232), "Europe/Vienna");
+ assertEquals(MccTable.defaultTimeZoneForMcc(655), "Africa/Johannesburg");
+ assertEquals(MccTable.defaultTimeZoneForMcc(440), "Asia/Tokyo");
+ assertEquals(MccTable.defaultTimeZoneForMcc(441), "Asia/Tokyo");
+ assertEquals(MccTable.defaultTimeZoneForMcc(525), "Singapore");
+ assertEquals(MccTable.defaultTimeZoneForMcc(240), null); // tz not defined, hence default
+ assertEquals(MccTable.defaultTimeZoneForMcc(0), null); // mcc not defined, hence default
+ assertEquals(MccTable.defaultTimeZoneForMcc(2000), null); // mcc not defined, hence default
+ }
+
+ @SmallTest
+ public void testCountryCode() throws Exception {
+ assertEquals(MccTable.countryCodeForMcc(270), "lu");
+ assertEquals(MccTable.countryCodeForMcc(202), "gr");
+ assertEquals(MccTable.countryCodeForMcc(750), "fk");
+ assertEquals(MccTable.countryCodeForMcc(646), "mg");
+ assertEquals(MccTable.countryCodeForMcc(314), "us");
+ assertEquals(MccTable.countryCodeForMcc(300), ""); // mcc not defined, hence default
+ assertEquals(MccTable.countryCodeForMcc(0), ""); // mcc not defined, hence default
+ assertEquals(MccTable.countryCodeForMcc(2000), ""); // mcc not defined, hence default
+ }
+
+ @SmallTest
+ public void testLang() throws Exception {
+ assertEquals(MccTable.defaultLanguageForMcc(311), "en");
+ assertEquals(MccTable.defaultLanguageForMcc(232), "de");
+ assertEquals(MccTable.defaultLanguageForMcc(230), "cs");
+ assertEquals(MccTable.defaultLanguageForMcc(204), "nl");
+ assertEquals(MccTable.defaultLanguageForMcc(274), null); // lang not defined, hence default
+ assertEquals(MccTable.defaultLanguageForMcc(0), null); // mcc not defined, hence default
+ assertEquals(MccTable.defaultLanguageForMcc(2000), null); // mcc not defined, hence default
+ }
+
+ @SmallTest
+ public void testSmDigits() throws Exception {
+ assertEquals(MccTable.smallestDigitsMccForMnc(312), 3);
+ assertEquals(MccTable.smallestDigitsMccForMnc(430), 2);
+ assertEquals(MccTable.smallestDigitsMccForMnc(365), 3);
+ assertEquals(MccTable.smallestDigitsMccForMnc(536), 2);
+ assertEquals(MccTable.smallestDigitsMccForMnc(352), 2); // sd not defined, hence default
+ assertEquals(MccTable.smallestDigitsMccForMnc(0), 2); // mcc not defined, hence default
+ assertEquals(MccTable.smallestDigitsMccForMnc(2000), 2); // mcc not defined, hence default
+ }
+
+ @SmallTest
+ public void testWifi() throws Exception {
+ assertEquals(MccTable.wifiChannelsForMcc(262), 13);
+ assertEquals(MccTable.wifiChannelsForMcc(234), 13);
+ assertEquals(MccTable.wifiChannelsForMcc(505), 11);
+ assertEquals(MccTable.wifiChannelsForMcc(313), 11);
+ assertEquals(MccTable.wifiChannelsForMcc(330), 0); // wifi not defined, hence default
+ assertEquals(MccTable.wifiChannelsForMcc(0), 0); // mcc not defined, hence default
+ assertEquals(MccTable.wifiChannelsForMcc(2000), 0); // mcc not defined, hence default
+
+ }
+}