• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_MCC_POOL_H
17 #define OHOS_MCC_POOL_H
18 
19 #include <algorithm>
20 #include <cstdio>
21 #include <functional>
22 #include <iostream>
23 #include <vector>
24 
25 enum MccCountry {
26     MCC_GR = 202,
27     MCC_NL = 204,
28     MCC_BE = 206,
29     MCC_FR = 208,
30     MCC_MC = 212,
31     MCC_AD = 213,
32     MCC_ES = 214,
33     MCC_HU = 216,
34     MCC_BA = 218,
35     MCC_HR = 219,
36     MCC_RS = 220,
37     MCC_IT = 222,
38     MCC_VA = 225,
39     MCC_RO = 226,
40     MCC_CH = 228,
41     MCC_CZ = 230,
42     MCC_SK = 231,
43     MCC_AT = 232,
44     MCC_GB_A = 234,
45     MCC_GB_B = 235,
46     MCC_DK = 238,
47     MCC_SE = 240,
48     MCC_NO = 242,
49     MCC_FI = 244,
50     MCC_LT = 246,
51     MCC_LV = 247,
52     MCC_EE = 248,
53     MCC_RU = 250,
54     MCC_UA = 255,
55     MCC_BY = 257,
56     MCC_MD = 259,
57     MCC_PL = 260,
58     MCC_DE = 262,
59     MCC_GI = 266,
60     MCC_PT = 268,
61     MCC_LU = 270,
62     MCC_IE = 272,
63     MCC_IS = 274,
64     MCC_AL = 276,
65     MCC_MT = 278,
66     MCC_CY = 280,
67     MCC_GE_A = 282,
68     MCC_AM = 283,
69     MCC_BG = 284,
70     MCC_TR = 286,
71     MCC_FO = 288,
72     MCC_GE_B = 289,
73     MCC_GL = 290,
74     MCC_SM = 292,
75     MCC_SI = 293,
76     MCC_MK = 294,
77     MCC_LI = 295,
78     MCC_ME = 297,
79     MCC_CA = 302,
80     MCC_PM = 308,
81     MCC_US_A = 310,
82     MCC_US_B = 311,
83     MCC_US_C = 312,
84     MCC_US_D = 313,
85     MCC_US_E = 314,
86     MCC_US_F = 315,
87     MCC_US_G = 316,
88     MCC_PR = 330,
89     MCC_VI = 332,
90     MCC_MX = 334,
91     MCC_JM = 338,
92     MCC_GP = 340,
93     MCC_BB = 342,
94     MCC_AG = 344,
95     MCC_KY = 346,
96     MCC_VG = 348,
97     MCC_BM = 350,
98     MCC_GD = 352,
99     MCC_MS = 354,
100     MCC_KN = 356,
101     MCC_LC = 358,
102     MCC_VC = 360,
103     MCC_AI_A = 362,
104     MCC_AW = 363,
105     MCC_BS = 364,
106     MCC_AI_B = 365,
107     MCC_DM = 366,
108     MCC_CU = 368,
109     MCC_DO = 370,
110     MCC_HT = 372,
111     MCC_TT = 374,
112     MCC_TC = 376,
113     MCC_AZ = 400,
114     MCC_KZ = 401,
115     MCC_BT = 402,
116     MCC_IN_A = 404,
117     MCC_IN_B = 405,
118     MCC_IN_C = 406,
119     MCC_PK = 410,
120     MCC_AF = 412,
121     MCC_LK = 413,
122     MCC_MM = 414,
123     MCC_LB = 415,
124     MCC_JO = 416,
125     MCC_SY = 417,
126     MCC_IQ = 418,
127     MCC_KW = 419,
128     MCC_SA = 420,
129     MCC_YE = 421,
130     MCC_OM = 422,
131     MCC_PS = 423,
132     MCC_AE_A = 424,
133     MCC_IL = 425,
134     MCC_BH = 426,
135     MCC_QA = 427,
136     MCC_MN = 428,
137     MCC_NP = 429,
138     MCC_AE_B = 430,
139     MCC_AE_C = 431,
140     MCC_IR = 432,
141     MCC_UZ = 434,
142     MCC_TJ = 436,
143     MCC_KG = 437,
144     MCC_TM = 438,
145     MCC_JP_A = 440,
146     MCC_JP_B = 441,
147     MCC_KR = 450,
148     MCC_VN = 452,
149     MCC_HK = 454,
150     MCC_MO = 455,
151     MCC_KH = 456,
152     MCC_LA = 457,
153     MCC_CN_A = 460,
154     MCC_CN_B = 461,
155     MCC_TW = 466,
156     MCC_KP = 467,
157     MCC_BD = 470,
158     MCC_MV = 472,
159     MCC_MY = 502,
160     MCC_AU = 505,
161     MCC_ID = 510,
162     MCC_TL = 514,
163     MCC_PH = 515,
164     MCC_TH = 520,
165     MCC_SG = 525,
166     MCC_BN = 528,
167     MCC_NZ = 530,
168     MCC_MP = 534,
169     MCC_GU = 535,
170     MCC_NR = 536,
171     MCC_PG = 537,
172     MCC_TO = 539,
173     MCC_SB = 540,
174     MCC_VU = 541,
175     MCC_FJ = 542,
176     MCC_WF = 543,
177     MCC_AS = 544,
178     MCC_KI = 545,
179     MCC_NC = 546,
180     MCC_PF = 547,
181     MCC_CK = 548,
182     MCC_WS = 549,
183     MCC_FM = 550,
184     MCC_MH = 551,
185     MCC_PW = 552,
186     MCC_TV = 553,
187     MCC_NU = 555,
188     MCC_EG = 602,
189     MCC_DZ = 603,
190     MCC_MA = 604,
191     MCC_TN = 605,
192     MCC_LY = 606,
193     MCC_GM = 607,
194     MCC_SN = 608,
195     MCC_MR = 609,
196     MCC_ML = 610,
197     MCC_GN = 611,
198     MCC_CI = 612,
199     MCC_BF = 613,
200     MCC_NE = 614,
201     MCC_TG = 615,
202     MCC_BJ = 616,
203     MCC_MU = 617,
204     MCC_LR = 618,
205     MCC_SL = 619,
206     MCC_GH = 620,
207     MCC_NG = 621,
208     MCC_TD = 622,
209     MCC_CF = 623,
210     MCC_CM = 624,
211     MCC_CV = 625,
212     MCC_ST = 626,
213     MCC_GQ = 627,
214     MCC_GA = 628,
215     MCC_CG = 629,
216     MCC_CD = 630,
217     MCC_AO = 631,
218     MCC_GW = 632,
219     MCC_SC = 633,
220     MCC_SD = 634,
221     MCC_RW = 635,
222     MCC_ET = 636,
223     MCC_SO = 637,
224     MCC_DJ = 638,
225     MCC_KE = 639,
226     MCC_TZ = 640,
227     MCC_UG = 641,
228     MCC_BI = 642,
229     MCC_MZ = 643,
230     MCC_ZM = 645,
231     MCC_MG = 646,
232     MCC_RE = 647,
233     MCC_ZW = 648,
234     MCC_NA = 649,
235     MCC_MW = 650,
236     MCC_LS = 651,
237     MCC_BW = 652,
238     MCC_SZ = 653,
239     MCC_KM = 654,
240     MCC_ZA = 655,
241     MCC_ER = 657,
242     MCC_SH = 658,
243     MCC_SS = 659,
244     MCC_BZ = 702,
245     MCC_GT = 704,
246     MCC_SV = 706,
247     MCC_HN = 708,
248     MCC_NI = 710,
249     MCC_CR = 712,
250     MCC_PA = 714,
251     MCC_PE = 716,
252     MCC_AR = 722,
253     MCC_BR = 724,
254     MCC_CL = 730,
255     MCC_CO = 732,
256     MCC_VE = 734,
257     MCC_BO = 736,
258     MCC_GY = 738,
259     MCC_EC = 740,
260     MCC_GF = 742,
261     MCC_PY = 744,
262     MCC_SR = 746,
263     MCC_UY = 748,
264     MCC_FK = 750
265 };
266 
267 enum MccType { MCC_SHORT = 2, MCC_LONG = 3 };
268 
269 namespace OHOS {
270 namespace Telephony {
271 class MccAccess {
272 public:
273     int mcc_ = 0;
274     std::string iso_ = "";
275     int mncShortestLength_ = 0;
MccAccess(int mnc,std::string iso,int shortestMnc)276     MccAccess(int mnc, std::string iso, int shortestMnc)
277     {
278         mcc_ = mnc;
279         iso_ = iso;
280         mncShortestLength_ = shortestMnc;
281     }
282 
283     bool operator==(MccAccess m)
284     {
285         return (mcc_ == m.mcc_);
286     }
287 };
288 
289 class MccPool {
290 public:
291     MccPool();
292     ~MccPool();
293     static std::string MccCountryCode(int mcc);
294     static int ShortestMncLengthFromMcc(int mcc);
295     static bool LengthIsThreeMnc(const std::string &mccMncCode);
296     static std::vector<MccAccess> mccAccessTable_;
297     static std::vector<std::string> specialMccMnc_;
298 
299 private:
300     static MccAccess AccessToMcc(int mcc);
301     static void InitMccTables();
302     static bool MccCompare(const MccAccess &a, const MccAccess &b);
303     static void AddMccForAsia();
304     static void AddMccForEurope();
305     static void AddMccForAfrica();
306     static void AddMccForNorthAmerica();
307     static void AddMccForSouthAmerica();
308     static void AddMccForAustralia();
309 
310     static void InitSpecialMccMncTables();
311     static void AddMccMncForCa();
312     static void AddMccMncForInAirtel();
313     static void AddMccMncForInHutch();
314     static void AddMccMncForMy();
315 };
316 } // namespace Telephony
317 } // namespace OHOS
318 #endif // OHOS_MCC_TABLE_H