1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.telephony;
18 
19 import android.app.ActivityManagerNative;
20 import android.app.AlarmManager;
21 import android.content.Context;
22 import android.content.res.Configuration;
23 import android.net.wifi.WifiManager;
24 import android.os.Build;
25 import android.os.RemoteException;
26 import android.os.SystemProperties;
27 import android.telephony.TelephonyManager;
28 import android.text.TextUtils;
29 import android.util.Slog;
30 
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.Collections;
34 import java.util.List;
35 import java.util.Locale;
36 import libcore.icu.ICU;
37 import libcore.icu.TimeZoneNames;
38 
39 /**
40  * Mobile Country Code
41  *
42  * {@hide}
43  */
44 public final class MccTable {
45     static final String LOG_TAG = "MccTable";
46 
47     static ArrayList<MccEntry> sTable;
48 
49     static class MccEntry implements Comparable<MccEntry> {
50         final int mMcc;
51         final String mIso;
52         final int mSmallestDigitsMnc;
53 
MccEntry(int mnc, String iso, int smallestDigitsMCC)54         MccEntry(int mnc, String iso, int smallestDigitsMCC) {
55             if (iso == null) {
56                 throw new NullPointerException();
57             }
58             mMcc = mnc;
59             mIso = iso;
60             mSmallestDigitsMnc = smallestDigitsMCC;
61         }
62 
63         @Override
compareTo(MccEntry o)64         public int compareTo(MccEntry o) {
65             return mMcc - o.mMcc;
66         }
67     }
68 
entryForMcc(int mcc)69     private static MccEntry entryForMcc(int mcc) {
70         MccEntry m = new MccEntry(mcc, "", 0);
71 
72         int index = Collections.binarySearch(sTable, m);
73 
74         if (index < 0) {
75             return null;
76         } else {
77             return sTable.get(index);
78         }
79     }
80 
81     /**
82      * Returns a default time zone ID for the given MCC.
83      * @param mcc Mobile Country Code
84      * @return default TimeZone ID, or null if not specified
85      */
defaultTimeZoneForMcc(int mcc)86     public static String defaultTimeZoneForMcc(int mcc) {
87         MccEntry entry = entryForMcc(mcc);
88         if (entry == null) {
89             return null;
90         }
91         Locale locale = new Locale("", entry.mIso);
92         String[] tz = TimeZoneNames.forLocale(locale);
93         if (tz.length == 0) return null;
94         return tz[0];
95     }
96 
97     /**
98      * Given a GSM Mobile Country Code, returns
99      * an ISO two-character country code if available.
100      * Returns "" if unavailable.
101      */
countryCodeForMcc(int mcc)102     public static String countryCodeForMcc(int mcc) {
103         MccEntry entry = entryForMcc(mcc);
104 
105         if (entry == null) {
106             return "";
107         } else {
108             return entry.mIso;
109         }
110     }
111 
112     /**
113      * Given a GSM Mobile Country Code, returns
114      * an ISO 2-3 character language code if available.
115      * Returns null if unavailable.
116      */
defaultLanguageForMcc(int mcc)117     public static String defaultLanguageForMcc(int mcc) {
118         MccEntry entry = entryForMcc(mcc);
119         if (entry == null) {
120             Slog.d(LOG_TAG, "defaultLanguageForMcc(" + mcc + "): no country for mcc");
121             return null;
122         }
123 
124         // Ask CLDR for the language this country uses...
125         Locale likelyLocale = ICU.addLikelySubtags(new Locale("und", entry.mIso));
126         String likelyLanguage = likelyLocale.getLanguage();
127         Slog.d(LOG_TAG, "defaultLanguageForMcc(" + mcc + "): country " + entry.mIso + " uses " +
128                likelyLanguage);
129         return likelyLanguage;
130     }
131 
132     /**
133      * Given a GSM Mobile Country Code, returns
134      * the smallest number of digits that M if available.
135      * Returns 2 if unavailable.
136      */
smallestDigitsMccForMnc(int mcc)137     public static int smallestDigitsMccForMnc(int mcc) {
138         MccEntry entry = entryForMcc(mcc);
139 
140         if (entry == null) {
141             return 2;
142         } else {
143             return entry.mSmallestDigitsMnc;
144         }
145     }
146 
147     /**
148      * Updates MCC and MNC device configuration information for application retrieving
149      * correct version of resources.  If MCC is 0, MCC and MNC will be ignored (not set).
150      * @param context Context to act on.
151      * @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end
152      * @param fromServiceState true if coming from the radio service state, false if from SIM
153      */
updateMccMncConfiguration(Context context, String mccmnc, boolean fromServiceState)154     public static void updateMccMncConfiguration(Context context, String mccmnc,
155             boolean fromServiceState) {
156         Slog.d(LOG_TAG, "updateMccMncConfiguration mccmnc='" + mccmnc + "' fromServiceState=" + fromServiceState);
157 
158         if (Build.IS_DEBUGGABLE) {
159             String overrideMcc = SystemProperties.get("persist.sys.override_mcc");
160             if (!TextUtils.isEmpty(overrideMcc)) {
161                 mccmnc = overrideMcc;
162                 Slog.d(LOG_TAG, "updateMccMncConfiguration overriding mccmnc='" + mccmnc + "'");
163             }
164         }
165 
166         if (!TextUtils.isEmpty(mccmnc)) {
167             int mcc, mnc;
168 
169             String defaultMccMnc = TelephonyManager.getDefault().getSimOperatorNumeric();
170             Slog.d(LOG_TAG, "updateMccMncConfiguration defaultMccMnc=" + defaultMccMnc);
171             //Update mccmnc only for default subscription in case of MultiSim.
172 //            if (!defaultMccMnc.equals(mccmnc)) {
173 //                Slog.d(LOG_TAG, "Not a Default subscription, ignoring mccmnc config update.");
174 //                return;
175 //            }
176 
177             try {
178                 mcc = Integer.parseInt(mccmnc.substring(0,3));
179                 mnc = Integer.parseInt(mccmnc.substring(3));
180             } catch (NumberFormatException e) {
181                 Slog.e(LOG_TAG, "Error parsing IMSI: " + mccmnc);
182                 return;
183             }
184 
185             Slog.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
186 
187             Locale locale = null;
188             if (mcc != 0) {
189                 setTimezoneFromMccIfNeeded(context, mcc);
190                 locale = getLocaleFromMcc(context, mcc);
191             }
192             if (fromServiceState) {
193                 setWifiCountryCodeFromMcc(context, mcc);
194             } else {
195                 // from SIM
196                 try {
197                     Configuration config = new Configuration();
198                     boolean updateConfig = false;
199                     if (mcc != 0) {
200                         config.mcc = mcc;
201                         config.mnc = mnc == 0 ? Configuration.MNC_ZERO : mnc;
202                         updateConfig = true;
203                     }
204                     if (locale != null) {
205                         config.setLocale(locale);
206                         updateConfig = true;
207                     }
208                     if (updateConfig) {
209                         Slog.d(LOG_TAG, "updateMccMncConfiguration updateConfig config=" + config);
210                         ActivityManagerNative.getDefault().updateConfiguration(config);
211                     } else {
212                         Slog.d(LOG_TAG, "updateMccMncConfiguration nothing to update");
213                     }
214                 } catch (RemoteException e) {
215                     Slog.e(LOG_TAG, "Can't update configuration", e);
216                 }
217             }
218         } else {
219             if (fromServiceState) {
220                 // an empty mccmnc means no signal - tell wifi we don't know
221                 setWifiCountryCodeFromMcc(context, 0);
222             }
223         }
224     }
225 
226     /**
227      * Return Locale for the language and country or null if no good match.
228      *
229      * @param context Context to act on.
230      * @param language Two character language code desired
231      * @param country Two character country code desired
232      *
233      * @return Locale or null if no appropriate value
234      */
getLocaleForLanguageCountry(Context context, String language, String country)235     private static Locale getLocaleForLanguageCountry(Context context, String language,
236             String country) {
237         if (language == null) {
238             Slog.d(LOG_TAG, "getLocaleForLanguageCountry: skipping no language");
239             return null; // no match possible
240         }
241         if (country == null) {
242             country = ""; // The Locale constructor throws if passed null.
243         }
244 
245         // Check whether a developer is trying to test an arbitrary MCC.
246         boolean debuggingMccOverride = false;
247         if (Build.IS_DEBUGGABLE) {
248             String overrideMcc = SystemProperties.get("persist.sys.override_mcc", "");
249             if (!overrideMcc.isEmpty()) {
250                 debuggingMccOverride = true;
251             }
252         }
253 
254         // If this is a regular user and they already have a persisted locale, we're done.
255         if (!debuggingMccOverride) {
256             String persistSysLanguage = SystemProperties.get("persist.sys.language", "");
257             String persistSysCountry = SystemProperties.get("persist.sys.country", "");
258             if (!(persistSysLanguage.isEmpty() && persistSysCountry.isEmpty())) {
259                 Slog.d(LOG_TAG, "getLocaleForLanguageCountry: skipping already persisted");
260                 return null;
261             }
262         }
263 
264         // Find the best match we actually have a localization for.
265         // TODO: this should really follow the CLDR chain of parent locales!
266         final Locale target = new Locale(language, country);
267         try {
268             String[] localeArray = context.getAssets().getLocales();
269             List<String> locales = new ArrayList<>(Arrays.asList(localeArray));
270 
271             // Even in developer mode, you don't want the pseudolocales.
272             locales.remove("ar-XB");
273             locales.remove("en-XA");
274 
275             Locale firstMatch = null;
276             for (String locale : locales) {
277                 final Locale l = Locale.forLanguageTag(locale.replace('_', '-'));
278 
279                 // Only consider locales with both language and country.
280                 if (l == null || "und".equals(l.getLanguage()) ||
281                         l.getLanguage().isEmpty() || l.getCountry().isEmpty()) {
282                     continue;
283                 }
284                 if (l.getLanguage().equals(target.getLanguage())) {
285                     // If we got a perfect match, we're done.
286                     if (l.getCountry().equals(target.getCountry())) {
287                         Slog.d(LOG_TAG, "getLocaleForLanguageCountry: got perfect match: " +
288                                l.toLanguageTag());
289                         return l;
290                     }
291                     // Otherwise somewhat arbitrarily take the first locale for the language,
292                     // unless we get a perfect match later. Note that these come back in no
293                     // particular order, so there's no reason to think the first match is
294                     // a particularly good match.
295                     if (firstMatch == null) {
296                         firstMatch = l;
297                     }
298                 }
299             }
300 
301             // We didn't find the exact locale, so return whichever locale we saw first where
302             // the language matched (if any).
303             if (firstMatch != null) {
304                 Slog.d(LOG_TAG, "getLocaleForLanguageCountry: got a language-only match: " +
305                        firstMatch.toLanguageTag());
306                 return firstMatch;
307             } else {
308                 Slog.d(LOG_TAG, "getLocaleForLanguageCountry: no locales for language " +
309                        language);
310             }
311         } catch (Exception e) {
312             Slog.d(LOG_TAG, "getLocaleForLanguageCountry: exception", e);
313         }
314 
315         return null;
316     }
317 
318     /**
319      * Utility code to set the system locale if it's not set already
320      * @param context Context to act on.
321      * @param language Two character language code desired
322      * @param country Two character country code desired
323      *
324      *  {@hide}
325      */
setSystemLocale(Context context, String language, String country)326     public static void setSystemLocale(Context context, String language, String country) {
327         Locale locale = getLocaleForLanguageCountry(context, language, country);
328         if (locale != null) {
329             Configuration config = new Configuration();
330             config.setLocale(locale);
331             config.userSetLocale = false;
332             Slog.d(LOG_TAG, "setSystemLocale: updateLocale config=" + config);
333             try {
334                 ActivityManagerNative.getDefault().updateConfiguration(config);
335             } catch (RemoteException e) {
336                 Slog.d(LOG_TAG, "setSystemLocale exception", e);
337             }
338         } else {
339             Slog.d(LOG_TAG, "setSystemLocale: no locale");
340         }
341     }
342 
343     /**
344      * If the timezone is not already set, set it based on the MCC of the SIM.
345      * @param context Context to act on.
346      * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
347      */
setTimezoneFromMccIfNeeded(Context context, int mcc)348     private static void setTimezoneFromMccIfNeeded(Context context, int mcc) {
349         String timezone = SystemProperties.get(ServiceStateTracker.TIMEZONE_PROPERTY);
350         if (timezone == null || timezone.length() == 0) {
351             String zoneId = defaultTimeZoneForMcc(mcc);
352             if (zoneId != null && zoneId.length() > 0) {
353                 // Set time zone based on MCC
354                 AlarmManager alarm =
355                         (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
356                 alarm.setTimeZone(zoneId);
357                 Slog.d(LOG_TAG, "timezone set to "+zoneId);
358             }
359         }
360     }
361 
362     /**
363      * Get Locale based on the MCC of the SIM.
364      * @param context Context to act on.
365      * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
366      *
367      * @return locale for the mcc or null if none
368      */
getLocaleFromMcc(Context context, int mcc)369     private static Locale getLocaleFromMcc(Context context, int mcc) {
370         String language = MccTable.defaultLanguageForMcc(mcc);
371         String country = MccTable.countryCodeForMcc(mcc);
372 
373         Slog.d(LOG_TAG, "getLocaleFromMcc to " + language + "_" + country + " mcc=" + mcc);
374         return getLocaleForLanguageCountry(context, language, country);
375     }
376 
377     /**
378      * Set the country code for wifi.  This sets allowed wifi channels based on the
379      * country of the carrier we see.  If we can't see any, reset to 0 so we don't
380      * broadcast on forbidden channels.
381      * @param context Context to act on.
382      * @param mcc Mobile Country Code of the operator.  0 if not known
383      */
setWifiCountryCodeFromMcc(Context context, int mcc)384     private static void setWifiCountryCodeFromMcc(Context context, int mcc) {
385         String country = MccTable.countryCodeForMcc(mcc);
386         Slog.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country);
387         WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
388         //persist
389         wM.setCountryCode(country, true);
390     }
391 
392     static {
393         sTable = new ArrayList<MccEntry>(240);
394 
395 
396         /*
397          * The table below is built from two resources:
398          *
399          * 1) ITU "Mobile Network Code (MNC) for the international
400          *   identification plan for mobile terminals and mobile users"
401          *   which is available as an annex to the ITU operational bulletin
402          *   available here: http://www.itu.int/itu-t/bulletin/annex.html
403          *
404          * 2) The ISO 3166 country codes list, available here:
405          *    http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html
406          *
407          * This table has not been verified.
408          */
409 
sTable.add(new MccEntry(202,"gr",2))410 		sTable.add(new MccEntry(202,"gr",2));	//Greece
sTable.add(new MccEntry(204,"nl",2))411 		sTable.add(new MccEntry(204,"nl",2));	//Netherlands (Kingdom of the)
sTable.add(new MccEntry(206,"be",2))412 		sTable.add(new MccEntry(206,"be",2));	//Belgium
sTable.add(new MccEntry(208,"fr",2))413 		sTable.add(new MccEntry(208,"fr",2));	//France
sTable.add(new MccEntry(212,"mc",2))414 		sTable.add(new MccEntry(212,"mc",2));	//Monaco (Principality of)
sTable.add(new MccEntry(213,"ad",2))415 		sTable.add(new MccEntry(213,"ad",2));	//Andorra (Principality of)
sTable.add(new MccEntry(214,"es",2))416 		sTable.add(new MccEntry(214,"es",2));	//Spain
sTable.add(new MccEntry(216,"hu",2))417 		sTable.add(new MccEntry(216,"hu",2));	//Hungary (Republic of)
sTable.add(new MccEntry(218,"ba",2))418 		sTable.add(new MccEntry(218,"ba",2));	//Bosnia and Herzegovina
sTable.add(new MccEntry(219,"hr",2))419 		sTable.add(new MccEntry(219,"hr",2));	//Croatia (Republic of)
sTable.add(new MccEntry(220,"rs",2))420 		sTable.add(new MccEntry(220,"rs",2));	//Serbia and Montenegro
sTable.add(new MccEntry(222,"it",2))421 		sTable.add(new MccEntry(222,"it",2));	//Italy
sTable.add(new MccEntry(225,"va",2))422 		sTable.add(new MccEntry(225,"va",2));	//Vatican City State
sTable.add(new MccEntry(226,"ro",2))423 		sTable.add(new MccEntry(226,"ro",2));	//Romania
sTable.add(new MccEntry(228,"ch",2))424 		sTable.add(new MccEntry(228,"ch",2));	//Switzerland (Confederation of)
sTable.add(new MccEntry(230,"cz",2))425 		sTable.add(new MccEntry(230,"cz",2));	//Czech Republic
sTable.add(new MccEntry(231,"sk",2))426 		sTable.add(new MccEntry(231,"sk",2));	//Slovak Republic
sTable.add(new MccEntry(232,"at",2))427 		sTable.add(new MccEntry(232,"at",2));	//Austria
sTable.add(new MccEntry(234,"gb",2))428 		sTable.add(new MccEntry(234,"gb",2));	//United Kingdom of Great Britain and Northern Ireland
sTable.add(new MccEntry(235,"gb",2))429 		sTable.add(new MccEntry(235,"gb",2));	//United Kingdom of Great Britain and Northern Ireland
sTable.add(new MccEntry(238,"dk",2))430 		sTable.add(new MccEntry(238,"dk",2));	//Denmark
sTable.add(new MccEntry(240,"se",2))431 		sTable.add(new MccEntry(240,"se",2));	//Sweden
sTable.add(new MccEntry(242,"no",2))432 		sTable.add(new MccEntry(242,"no",2));	//Norway
sTable.add(new MccEntry(244,"fi",2))433 		sTable.add(new MccEntry(244,"fi",2));	//Finland
sTable.add(new MccEntry(246,"lt",2))434 		sTable.add(new MccEntry(246,"lt",2));	//Lithuania (Republic of)
sTable.add(new MccEntry(247,"lv",2))435 		sTable.add(new MccEntry(247,"lv",2));	//Latvia (Republic of)
sTable.add(new MccEntry(248,"ee",2))436 		sTable.add(new MccEntry(248,"ee",2));	//Estonia (Republic of)
sTable.add(new MccEntry(250,"ru",2))437 		sTable.add(new MccEntry(250,"ru",2));	//Russian Federation
sTable.add(new MccEntry(255,"ua",2))438 		sTable.add(new MccEntry(255,"ua",2));	//Ukraine
sTable.add(new MccEntry(257,"by",2))439 		sTable.add(new MccEntry(257,"by",2));	//Belarus (Republic of)
sTable.add(new MccEntry(259,"md",2))440 		sTable.add(new MccEntry(259,"md",2));	//Moldova (Republic of)
sTable.add(new MccEntry(260,"pl",2))441 		sTable.add(new MccEntry(260,"pl",2));	//Poland (Republic of)
sTable.add(new MccEntry(262,"de",2))442 		sTable.add(new MccEntry(262,"de",2));	//Germany (Federal Republic of)
sTable.add(new MccEntry(266,"gi",2))443 		sTable.add(new MccEntry(266,"gi",2));	//Gibraltar
sTable.add(new MccEntry(268,"pt",2))444 		sTable.add(new MccEntry(268,"pt",2));	//Portugal
sTable.add(new MccEntry(270,"lu",2))445 		sTable.add(new MccEntry(270,"lu",2));	//Luxembourg
sTable.add(new MccEntry(272,"ie",2))446 		sTable.add(new MccEntry(272,"ie",2));	//Ireland
sTable.add(new MccEntry(274,"is",2))447 		sTable.add(new MccEntry(274,"is",2));	//Iceland
sTable.add(new MccEntry(276,"al",2))448 		sTable.add(new MccEntry(276,"al",2));	//Albania (Republic of)
sTable.add(new MccEntry(278,"mt",2))449 		sTable.add(new MccEntry(278,"mt",2));	//Malta
sTable.add(new MccEntry(280,"cy",2))450 		sTable.add(new MccEntry(280,"cy",2));	//Cyprus (Republic of)
sTable.add(new MccEntry(282,"ge",2))451 		sTable.add(new MccEntry(282,"ge",2));	//Georgia
sTable.add(new MccEntry(283,"am",2))452 		sTable.add(new MccEntry(283,"am",2));	//Armenia (Republic of)
sTable.add(new MccEntry(284,"bg",2))453 		sTable.add(new MccEntry(284,"bg",2));	//Bulgaria (Republic of)
sTable.add(new MccEntry(286,"tr",2))454 		sTable.add(new MccEntry(286,"tr",2));	//Turkey
sTable.add(new MccEntry(288,"fo",2))455 		sTable.add(new MccEntry(288,"fo",2));	//Faroe Islands
sTable.add(new MccEntry(289,"ge",2))456                 sTable.add(new MccEntry(289,"ge",2));    //Abkhazia (Georgia)
sTable.add(new MccEntry(290,"gl",2))457 		sTable.add(new MccEntry(290,"gl",2));	//Greenland (Denmark)
sTable.add(new MccEntry(292,"sm",2))458 		sTable.add(new MccEntry(292,"sm",2));	//San Marino (Republic of)
sTable.add(new MccEntry(293,"si",2))459 		sTable.add(new MccEntry(293,"si",2));	//Slovenia (Republic of)
sTable.add(new MccEntry(294,"mk",2))460                 sTable.add(new MccEntry(294,"mk",2));   //The Former Yugoslav Republic of Macedonia
sTable.add(new MccEntry(295,"li",2))461 		sTable.add(new MccEntry(295,"li",2));	//Liechtenstein (Principality of)
sTable.add(new MccEntry(297,"me",2))462                 sTable.add(new MccEntry(297,"me",2));    //Montenegro (Republic of)
sTable.add(new MccEntry(302,"ca",3))463 		sTable.add(new MccEntry(302,"ca",3));	//Canada
sTable.add(new MccEntry(308,"pm",2))464 		sTable.add(new MccEntry(308,"pm",2));	//Saint Pierre and Miquelon (Collectivit territoriale de la Rpublique franaise)
sTable.add(new MccEntry(310,"us",3))465 		sTable.add(new MccEntry(310,"us",3));	//United States of America
sTable.add(new MccEntry(311,"us",3))466 		sTable.add(new MccEntry(311,"us",3));	//United States of America
sTable.add(new MccEntry(312,"us",3))467 		sTable.add(new MccEntry(312,"us",3));	//United States of America
sTable.add(new MccEntry(313,"us",3))468 		sTable.add(new MccEntry(313,"us",3));	//United States of America
sTable.add(new MccEntry(314,"us",3))469 		sTable.add(new MccEntry(314,"us",3));	//United States of America
sTable.add(new MccEntry(315,"us",3))470 		sTable.add(new MccEntry(315,"us",3));	//United States of America
sTable.add(new MccEntry(316,"us",3))471 		sTable.add(new MccEntry(316,"us",3));	//United States of America
sTable.add(new MccEntry(330,"pr",2))472 		sTable.add(new MccEntry(330,"pr",2));	//Puerto Rico
sTable.add(new MccEntry(332,"vi",2))473 		sTable.add(new MccEntry(332,"vi",2));	//United States Virgin Islands
sTable.add(new MccEntry(334,"mx",3))474 		sTable.add(new MccEntry(334,"mx",3));	//Mexico
sTable.add(new MccEntry(338,"jm",3))475 		sTable.add(new MccEntry(338,"jm",3));	//Jamaica
sTable.add(new MccEntry(340,"gp",2))476 		sTable.add(new MccEntry(340,"gp",2));	//Guadeloupe (French Department of)
sTable.add(new MccEntry(342,"bb",3))477 		sTable.add(new MccEntry(342,"bb",3));	//Barbados
sTable.add(new MccEntry(344,"ag",3))478 		sTable.add(new MccEntry(344,"ag",3));	//Antigua and Barbuda
sTable.add(new MccEntry(346,"ky",3))479 		sTable.add(new MccEntry(346,"ky",3));	//Cayman Islands
sTable.add(new MccEntry(348,"vg",3))480 		sTable.add(new MccEntry(348,"vg",3));	//British Virgin Islands
sTable.add(new MccEntry(350,"bm",2))481 		sTable.add(new MccEntry(350,"bm",2));	//Bermuda
sTable.add(new MccEntry(352,"gd",2))482 		sTable.add(new MccEntry(352,"gd",2));	//Grenada
sTable.add(new MccEntry(354,"ms",2))483 		sTable.add(new MccEntry(354,"ms",2));	//Montserrat
sTable.add(new MccEntry(356,"kn",2))484 		sTable.add(new MccEntry(356,"kn",2));	//Saint Kitts and Nevis
sTable.add(new MccEntry(358,"lc",2))485 		sTable.add(new MccEntry(358,"lc",2));	//Saint Lucia
sTable.add(new MccEntry(360,"vc",2))486 		sTable.add(new MccEntry(360,"vc",2));	//Saint Vincent and the Grenadines
sTable.add(new MccEntry(362,"ai",2))487 		sTable.add(new MccEntry(362,"ai",2));	//Netherlands Antilles
sTable.add(new MccEntry(363,"aw",2))488 		sTable.add(new MccEntry(363,"aw",2));	//Aruba
sTable.add(new MccEntry(364,"bs",2))489 		sTable.add(new MccEntry(364,"bs",2));	//Bahamas (Commonwealth of the)
sTable.add(new MccEntry(365,"ai",3))490 		sTable.add(new MccEntry(365,"ai",3));	//Anguilla
sTable.add(new MccEntry(366,"dm",2))491 		sTable.add(new MccEntry(366,"dm",2));	//Dominica (Commonwealth of)
sTable.add(new MccEntry(368,"cu",2))492 		sTable.add(new MccEntry(368,"cu",2));	//Cuba
sTable.add(new MccEntry(370,"do",2))493 		sTable.add(new MccEntry(370,"do",2));	//Dominican Republic
sTable.add(new MccEntry(372,"ht",2))494 		sTable.add(new MccEntry(372,"ht",2));	//Haiti (Republic of)
sTable.add(new MccEntry(374,"tt",2))495 		sTable.add(new MccEntry(374,"tt",2));	//Trinidad and Tobago
sTable.add(new MccEntry(376,"tc",2))496 		sTable.add(new MccEntry(376,"tc",2));	//Turks and Caicos Islands
sTable.add(new MccEntry(400,"az",2))497 		sTable.add(new MccEntry(400,"az",2));	//Azerbaijani Republic
sTable.add(new MccEntry(401,"kz",2))498 		sTable.add(new MccEntry(401,"kz",2));	//Kazakhstan (Republic of)
sTable.add(new MccEntry(402,"bt",2))499 		sTable.add(new MccEntry(402,"bt",2));	//Bhutan (Kingdom of)
sTable.add(new MccEntry(404,"in",2))500 		sTable.add(new MccEntry(404,"in",2));	//India (Republic of)
sTable.add(new MccEntry(405,"in",2))501 		sTable.add(new MccEntry(405,"in",2));	//India (Republic of)
sTable.add(new MccEntry(406,"in",2))502 		sTable.add(new MccEntry(406,"in",2));	//India (Republic of)
sTable.add(new MccEntry(410,"pk",2))503 		sTable.add(new MccEntry(410,"pk",2));	//Pakistan (Islamic Republic of)
sTable.add(new MccEntry(412,"af",2))504 		sTable.add(new MccEntry(412,"af",2));	//Afghanistan
sTable.add(new MccEntry(413,"lk",2))505 		sTable.add(new MccEntry(413,"lk",2));	//Sri Lanka (Democratic Socialist Republic of)
sTable.add(new MccEntry(414,"mm",2))506 		sTable.add(new MccEntry(414,"mm",2));	//Myanmar (Union of)
sTable.add(new MccEntry(415,"lb",2))507 		sTable.add(new MccEntry(415,"lb",2));	//Lebanon
sTable.add(new MccEntry(416,"jo",2))508 		sTable.add(new MccEntry(416,"jo",2));	//Jordan (Hashemite Kingdom of)
sTable.add(new MccEntry(417,"sy",2))509 		sTable.add(new MccEntry(417,"sy",2));	//Syrian Arab Republic
sTable.add(new MccEntry(418,"iq",2))510 		sTable.add(new MccEntry(418,"iq",2));	//Iraq (Republic of)
sTable.add(new MccEntry(419,"kw",2))511 		sTable.add(new MccEntry(419,"kw",2));	//Kuwait (State of)
sTable.add(new MccEntry(420,"sa",2))512 		sTable.add(new MccEntry(420,"sa",2));	//Saudi Arabia (Kingdom of)
sTable.add(new MccEntry(421,"ye",2))513 		sTable.add(new MccEntry(421,"ye",2));	//Yemen (Republic of)
sTable.add(new MccEntry(422,"om",2))514 		sTable.add(new MccEntry(422,"om",2));	//Oman (Sultanate of)
sTable.add(new MccEntry(423,"ps",2))515                 sTable.add(new MccEntry(423,"ps",2));    //Palestine
sTable.add(new MccEntry(424,"ae",2))516 		sTable.add(new MccEntry(424,"ae",2));	//United Arab Emirates
sTable.add(new MccEntry(425,"il",2))517 		sTable.add(new MccEntry(425,"il",2));	//Israel (State of)
sTable.add(new MccEntry(426,"bh",2))518 		sTable.add(new MccEntry(426,"bh",2));	//Bahrain (Kingdom of)
sTable.add(new MccEntry(427,"qa",2))519 		sTable.add(new MccEntry(427,"qa",2));	//Qatar (State of)
sTable.add(new MccEntry(428,"mn",2))520 		sTable.add(new MccEntry(428,"mn",2));	//Mongolia
sTable.add(new MccEntry(429,"np",2))521 		sTable.add(new MccEntry(429,"np",2));	//Nepal
sTable.add(new MccEntry(430,"ae",2))522 		sTable.add(new MccEntry(430,"ae",2));	//United Arab Emirates
sTable.add(new MccEntry(431,"ae",2))523 		sTable.add(new MccEntry(431,"ae",2));	//United Arab Emirates
sTable.add(new MccEntry(432,"ir",2))524 		sTable.add(new MccEntry(432,"ir",2));	//Iran (Islamic Republic of)
sTable.add(new MccEntry(434,"uz",2))525 		sTable.add(new MccEntry(434,"uz",2));	//Uzbekistan (Republic of)
sTable.add(new MccEntry(436,"tj",2))526 		sTable.add(new MccEntry(436,"tj",2));	//Tajikistan (Republic of)
sTable.add(new MccEntry(437,"kg",2))527 		sTable.add(new MccEntry(437,"kg",2));	//Kyrgyz Republic
sTable.add(new MccEntry(438,"tm",2))528 		sTable.add(new MccEntry(438,"tm",2));	//Turkmenistan
sTable.add(new MccEntry(440,"jp",2))529 		sTable.add(new MccEntry(440,"jp",2));	//Japan
sTable.add(new MccEntry(441,"jp",2))530 		sTable.add(new MccEntry(441,"jp",2));	//Japan
sTable.add(new MccEntry(450,"kr",2))531 		sTable.add(new MccEntry(450,"kr",2));	//Korea (Republic of)
sTable.add(new MccEntry(452,"vn",2))532 		sTable.add(new MccEntry(452,"vn",2));	//Viet Nam (Socialist Republic of)
sTable.add(new MccEntry(454,"hk",2))533 		sTable.add(new MccEntry(454,"hk",2));	//"Hong Kong, China"
sTable.add(new MccEntry(455,"mo",2))534 		sTable.add(new MccEntry(455,"mo",2));	//"Macao, China"
sTable.add(new MccEntry(456,"kh",2))535 		sTable.add(new MccEntry(456,"kh",2));	//Cambodia (Kingdom of)
sTable.add(new MccEntry(457,"la",2))536 		sTable.add(new MccEntry(457,"la",2));	//Lao People's Democratic Republic
sTable.add(new MccEntry(460,"cn",2))537 		sTable.add(new MccEntry(460,"cn",2));	//China (People's Republic of)
sTable.add(new MccEntry(461,"cn",2))538 		sTable.add(new MccEntry(461,"cn",2));	//China (People's Republic of)
sTable.add(new MccEntry(466,"tw",2))539 		sTable.add(new MccEntry(466,"tw",2));	//"Taiwan, China"
sTable.add(new MccEntry(467,"kp",2))540 		sTable.add(new MccEntry(467,"kp",2));	//Democratic People's Republic of Korea
sTable.add(new MccEntry(470,"bd",2))541 		sTable.add(new MccEntry(470,"bd",2));	//Bangladesh (People's Republic of)
sTable.add(new MccEntry(472,"mv",2))542 		sTable.add(new MccEntry(472,"mv",2));	//Maldives (Republic of)
sTable.add(new MccEntry(502,"my",2))543 		sTable.add(new MccEntry(502,"my",2));	//Malaysia
sTable.add(new MccEntry(505,"au",2))544 		sTable.add(new MccEntry(505,"au",2));	//Australia
sTable.add(new MccEntry(510,"id",2))545 		sTable.add(new MccEntry(510,"id",2));	//Indonesia (Republic of)
sTable.add(new MccEntry(514,"tl",2))546 		sTable.add(new MccEntry(514,"tl",2));	//Democratic Republic of Timor-Leste
sTable.add(new MccEntry(515,"ph",2))547 		sTable.add(new MccEntry(515,"ph",2));	//Philippines (Republic of the)
sTable.add(new MccEntry(520,"th",2))548 		sTable.add(new MccEntry(520,"th",2));	//Thailand
sTable.add(new MccEntry(525,"sg",2))549 		sTable.add(new MccEntry(525,"sg",2));	//Singapore (Republic of)
sTable.add(new MccEntry(528,"bn",2))550 		sTable.add(new MccEntry(528,"bn",2));	//Brunei Darussalam
sTable.add(new MccEntry(530,"nz",2))551 		sTable.add(new MccEntry(530,"nz",2));	//New Zealand
sTable.add(new MccEntry(534,"mp",2))552 		sTable.add(new MccEntry(534,"mp",2));	//Northern Mariana Islands (Commonwealth of the)
sTable.add(new MccEntry(535,"gu",2))553 		sTable.add(new MccEntry(535,"gu",2));	//Guam
sTable.add(new MccEntry(536,"nr",2))554 		sTable.add(new MccEntry(536,"nr",2));	//Nauru (Republic of)
sTable.add(new MccEntry(537,"pg",2))555 		sTable.add(new MccEntry(537,"pg",2));	//Papua New Guinea
sTable.add(new MccEntry(539,"to",2))556 		sTable.add(new MccEntry(539,"to",2));	//Tonga (Kingdom of)
sTable.add(new MccEntry(540,"sb",2))557 		sTable.add(new MccEntry(540,"sb",2));	//Solomon Islands
sTable.add(new MccEntry(541,"vu",2))558 		sTable.add(new MccEntry(541,"vu",2));	//Vanuatu (Republic of)
sTable.add(new MccEntry(542,"fj",2))559 		sTable.add(new MccEntry(542,"fj",2));	//Fiji (Republic of)
sTable.add(new MccEntry(543,"wf",2))560 		sTable.add(new MccEntry(543,"wf",2));	//Wallis and Futuna (Territoire franais d'outre-mer)
sTable.add(new MccEntry(544,"as",2))561 		sTable.add(new MccEntry(544,"as",2));	//American Samoa
sTable.add(new MccEntry(545,"ki",2))562 		sTable.add(new MccEntry(545,"ki",2));	//Kiribati (Republic of)
sTable.add(new MccEntry(546,"nc",2))563 		sTable.add(new MccEntry(546,"nc",2));	//New Caledonia (Territoire franais d'outre-mer)
sTable.add(new MccEntry(547,"pf",2))564 		sTable.add(new MccEntry(547,"pf",2));	//French Polynesia (Territoire franais d'outre-mer)
sTable.add(new MccEntry(548,"ck",2))565 		sTable.add(new MccEntry(548,"ck",2));	//Cook Islands
sTable.add(new MccEntry(549,"ws",2))566 		sTable.add(new MccEntry(549,"ws",2));	//Samoa (Independent State of)
sTable.add(new MccEntry(550,"fm",2))567 		sTable.add(new MccEntry(550,"fm",2));	//Micronesia (Federated States of)
sTable.add(new MccEntry(551,"mh",2))568 		sTable.add(new MccEntry(551,"mh",2));	//Marshall Islands (Republic of the)
sTable.add(new MccEntry(552,"pw",2))569 		sTable.add(new MccEntry(552,"pw",2));	//Palau (Republic of)
sTable.add(new MccEntry(553,"tv",2))570 		sTable.add(new MccEntry(553,"tv",2));	//Tuvalu
sTable.add(new MccEntry(555,"nu",2))571 		sTable.add(new MccEntry(555,"nu",2));	//Niue
sTable.add(new MccEntry(602,"eg",2))572 		sTable.add(new MccEntry(602,"eg",2));	//Egypt (Arab Republic of)
sTable.add(new MccEntry(603,"dz",2))573 		sTable.add(new MccEntry(603,"dz",2));	//Algeria (People's Democratic Republic of)
sTable.add(new MccEntry(604,"ma",2))574 		sTable.add(new MccEntry(604,"ma",2));	//Morocco (Kingdom of)
sTable.add(new MccEntry(605,"tn",2))575 		sTable.add(new MccEntry(605,"tn",2));	//Tunisia
sTable.add(new MccEntry(606,"ly",2))576 		sTable.add(new MccEntry(606,"ly",2));	//Libya (Socialist People's Libyan Arab Jamahiriya)
sTable.add(new MccEntry(607,"gm",2))577 		sTable.add(new MccEntry(607,"gm",2));	//Gambia (Republic of the)
sTable.add(new MccEntry(608,"sn",2))578 		sTable.add(new MccEntry(608,"sn",2));	//Senegal (Republic of)
sTable.add(new MccEntry(609,"mr",2))579 		sTable.add(new MccEntry(609,"mr",2));	//Mauritania (Islamic Republic of)
sTable.add(new MccEntry(610,"ml",2))580 		sTable.add(new MccEntry(610,"ml",2));	//Mali (Republic of)
sTable.add(new MccEntry(611,"gn",2))581 		sTable.add(new MccEntry(611,"gn",2));	//Guinea (Republic of)
sTable.add(new MccEntry(612,"ci",2))582 		sTable.add(new MccEntry(612,"ci",2));	//Côte d'Ivoire (Republic of)
sTable.add(new MccEntry(613,"bf",2))583 		sTable.add(new MccEntry(613,"bf",2));	//Burkina Faso
sTable.add(new MccEntry(614,"ne",2))584 		sTable.add(new MccEntry(614,"ne",2));	//Niger (Republic of the)
sTable.add(new MccEntry(615,"tg",2))585 		sTable.add(new MccEntry(615,"tg",2));	//Togolese Republic
sTable.add(new MccEntry(616,"bj",2))586 		sTable.add(new MccEntry(616,"bj",2));	//Benin (Republic of)
sTable.add(new MccEntry(617,"mu",2))587 		sTable.add(new MccEntry(617,"mu",2));	//Mauritius (Republic of)
sTable.add(new MccEntry(618,"lr",2))588 		sTable.add(new MccEntry(618,"lr",2));	//Liberia (Republic of)
sTable.add(new MccEntry(619,"sl",2))589 		sTable.add(new MccEntry(619,"sl",2));	//Sierra Leone
sTable.add(new MccEntry(620,"gh",2))590 		sTable.add(new MccEntry(620,"gh",2));	//Ghana
sTable.add(new MccEntry(621,"ng",2))591 		sTable.add(new MccEntry(621,"ng",2));	//Nigeria (Federal Republic of)
sTable.add(new MccEntry(622,"td",2))592 		sTable.add(new MccEntry(622,"td",2));	//Chad (Republic of)
sTable.add(new MccEntry(623,"cf",2))593 		sTable.add(new MccEntry(623,"cf",2));	//Central African Republic
sTable.add(new MccEntry(624,"cm",2))594 		sTable.add(new MccEntry(624,"cm",2));	//Cameroon (Republic of)
sTable.add(new MccEntry(625,"cv",2))595 		sTable.add(new MccEntry(625,"cv",2));	//Cape Verde (Republic of)
sTable.add(new MccEntry(626,"st",2))596 		sTable.add(new MccEntry(626,"st",2));	//Sao Tome and Principe (Democratic Republic of)
sTable.add(new MccEntry(627,"gq",2))597 		sTable.add(new MccEntry(627,"gq",2));	//Equatorial Guinea (Republic of)
sTable.add(new MccEntry(628,"ga",2))598 		sTable.add(new MccEntry(628,"ga",2));	//Gabonese Republic
sTable.add(new MccEntry(629,"cg",2))599 		sTable.add(new MccEntry(629,"cg",2));	//Congo (Republic of the)
sTable.add(new MccEntry(630,"cg",2))600 		sTable.add(new MccEntry(630,"cg",2));	//Democratic Republic of the Congo
sTable.add(new MccEntry(631,"ao",2))601 		sTable.add(new MccEntry(631,"ao",2));	//Angola (Republic of)
sTable.add(new MccEntry(632,"gw",2))602 		sTable.add(new MccEntry(632,"gw",2));	//Guinea-Bissau (Republic of)
sTable.add(new MccEntry(633,"sc",2))603 		sTable.add(new MccEntry(633,"sc",2));	//Seychelles (Republic of)
sTable.add(new MccEntry(634,"sd",2))604 		sTable.add(new MccEntry(634,"sd",2));	//Sudan (Republic of the)
sTable.add(new MccEntry(635,"rw",2))605 		sTable.add(new MccEntry(635,"rw",2));	//Rwanda (Republic of)
sTable.add(new MccEntry(636,"et",2))606 		sTable.add(new MccEntry(636,"et",2));	//Ethiopia (Federal Democratic Republic of)
sTable.add(new MccEntry(637,"so",2))607 		sTable.add(new MccEntry(637,"so",2));	//Somali Democratic Republic
sTable.add(new MccEntry(638,"dj",2))608 		sTable.add(new MccEntry(638,"dj",2));	//Djibouti (Republic of)
sTable.add(new MccEntry(639,"ke",2))609 		sTable.add(new MccEntry(639,"ke",2));	//Kenya (Republic of)
sTable.add(new MccEntry(640,"tz",2))610 		sTable.add(new MccEntry(640,"tz",2));	//Tanzania (United Republic of)
sTable.add(new MccEntry(641,"ug",2))611 		sTable.add(new MccEntry(641,"ug",2));	//Uganda (Republic of)
sTable.add(new MccEntry(642,"bi",2))612 		sTable.add(new MccEntry(642,"bi",2));	//Burundi (Republic of)
sTable.add(new MccEntry(643,"mz",2))613 		sTable.add(new MccEntry(643,"mz",2));	//Mozambique (Republic of)
sTable.add(new MccEntry(645,"zm",2))614 		sTable.add(new MccEntry(645,"zm",2));	//Zambia (Republic of)
sTable.add(new MccEntry(646,"mg",2))615 		sTable.add(new MccEntry(646,"mg",2));	//Madagascar (Republic of)
sTable.add(new MccEntry(647,"re",2))616 		sTable.add(new MccEntry(647,"re",2));	//Reunion (French Department of)
sTable.add(new MccEntry(648,"zw",2))617 		sTable.add(new MccEntry(648,"zw",2));	//Zimbabwe (Republic of)
sTable.add(new MccEntry(649,"na",2))618 		sTable.add(new MccEntry(649,"na",2));	//Namibia (Republic of)
sTable.add(new MccEntry(650,"mw",2))619 		sTable.add(new MccEntry(650,"mw",2));	//Malawi
sTable.add(new MccEntry(651,"ls",2))620 		sTable.add(new MccEntry(651,"ls",2));	//Lesotho (Kingdom of)
sTable.add(new MccEntry(652,"bw",2))621 		sTable.add(new MccEntry(652,"bw",2));	//Botswana (Republic of)
sTable.add(new MccEntry(653,"sz",2))622 		sTable.add(new MccEntry(653,"sz",2));	//Swaziland (Kingdom of)
sTable.add(new MccEntry(654,"km",2))623 		sTable.add(new MccEntry(654,"km",2));	//Comoros (Union of the)
sTable.add(new MccEntry(655,"za",2))624 		sTable.add(new MccEntry(655,"za",2));	//South Africa (Republic of)
sTable.add(new MccEntry(657,"er",2))625 		sTable.add(new MccEntry(657,"er",2));	//Eritrea
sTable.add(new MccEntry(658,"sh",2))626 		sTable.add(new MccEntry(658,"sh",2));	//Saint Helena, Ascension and Tristan da Cunha
sTable.add(new MccEntry(659,"ss",2))627 		sTable.add(new MccEntry(659,"ss",2));	//South Sudan (Republic of)
sTable.add(new MccEntry(702,"bz",2))628 		sTable.add(new MccEntry(702,"bz",2));	//Belize
sTable.add(new MccEntry(704,"gt",2))629 		sTable.add(new MccEntry(704,"gt",2));	//Guatemala (Republic of)
sTable.add(new MccEntry(706,"sv",2))630 		sTable.add(new MccEntry(706,"sv",2));	//El Salvador (Republic of)
sTable.add(new MccEntry(708,"hn",3))631 		sTable.add(new MccEntry(708,"hn",3));	//Honduras (Republic of)
sTable.add(new MccEntry(710,"ni",2))632 		sTable.add(new MccEntry(710,"ni",2));	//Nicaragua
sTable.add(new MccEntry(712,"cr",2))633 		sTable.add(new MccEntry(712,"cr",2));	//Costa Rica
sTable.add(new MccEntry(714,"pa",2))634 		sTable.add(new MccEntry(714,"pa",2));	//Panama (Republic of)
sTable.add(new MccEntry(716,"pe",2))635 		sTable.add(new MccEntry(716,"pe",2));	//Peru
sTable.add(new MccEntry(722,"ar",3))636 		sTable.add(new MccEntry(722,"ar",3));	//Argentine Republic
sTable.add(new MccEntry(724,"br",2))637 		sTable.add(new MccEntry(724,"br",2));	//Brazil (Federative Republic of)
sTable.add(new MccEntry(730,"cl",2))638 		sTable.add(new MccEntry(730,"cl",2));	//Chile
sTable.add(new MccEntry(732,"co",3))639 		sTable.add(new MccEntry(732,"co",3));	//Colombia (Republic of)
sTable.add(new MccEntry(734,"ve",2))640 		sTable.add(new MccEntry(734,"ve",2));	//Venezuela (Bolivarian Republic of)
sTable.add(new MccEntry(736,"bo",2))641 		sTable.add(new MccEntry(736,"bo",2));	//Bolivia (Republic of)
sTable.add(new MccEntry(738,"gy",2))642 		sTable.add(new MccEntry(738,"gy",2));	//Guyana
sTable.add(new MccEntry(740,"ec",2))643 		sTable.add(new MccEntry(740,"ec",2));	//Ecuador
sTable.add(new MccEntry(742,"gf",2))644 		sTable.add(new MccEntry(742,"gf",2));	//French Guiana (French Department of)
sTable.add(new MccEntry(744,"py",2))645 		sTable.add(new MccEntry(744,"py",2));	//Paraguay (Republic of)
sTable.add(new MccEntry(746,"sr",2))646 		sTable.add(new MccEntry(746,"sr",2));	//Suriname (Republic of)
sTable.add(new MccEntry(748,"uy",2))647 		sTable.add(new MccEntry(748,"uy",2));	//Uruguay (Eastern Republic of)
sTable.add(new MccEntry(750,"fk",2))648 		sTable.add(new MccEntry(750,"fk",2));	//Falkland Islands (Malvinas)
649         //table.add(new MccEntry(901,"",2));	//"International Mobile, shared code"
650 
651         Collections.sort(sTable);
652     }
653 }
654