1 /*
2  * Copyright (C) 2021-2023 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 WIFI_COUNTRY_CODE_DEFINE_H
17 #define WIFI_COUNTRY_CODE_DEFINE_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Wifi {
23 constexpr int WIFI_COUNTRY_CODE_POLICE_DEF_LEN = 5;
24 constexpr const char* WIFI_COUNTRY_CODE_DYNAMIC_UPDATE_KEY = "persist.wifi.country_code.dynamic_update";
25 constexpr const char* DEFAULT_WIFI_COUNTRY_CODE_ZZ = "ZZ";  // for tablets only, priority greater than HK
26 constexpr const char* DEFAULT_WIFI_COUNTRY_CODE = "HK";
27 constexpr const char* DEFAULT_RO_RUN_MODE = "normal";
28 constexpr const char* FACTORY_RO_RUN_MODE = "factory";
29 constexpr const char* FACTORY_WIFI_COUNTRY_CODE = "const.wifi.country_code.factory";
30 constexpr const char* WIFI_COUNTRY_CODE_RUN_MODE = "const.wifi.country_code.runmode";
31 constexpr const char* WIFI_COUNTRY_CODE_CONFIG = "const.wifi.country_code.conf";
32 constexpr const char* WIFI_COUNTRY_CODE_CONFIG_DEFAULT = "0";
33 constexpr const char* DEFAULT_REGION_KEY = "const.global.region";
34 constexpr const char* DEFAULT_REGION = "CN";
35 constexpr const char* OPERATOR_NUMERIC_KEY = "ril.operator.numeric";  // plmn cached
36 constexpr const char* DEFAULT_OPERATOR_NUMERIC = "00000";
37 constexpr int WIFI_COUNTRY_CODE_SIZE = 16;
38 constexpr int FACTORY_WIFI_COUNTRY_CODE_SIZE = 16;
39 constexpr int WIFI_COUNTRY_CODE_RUN_MODE_SIZE = 16;
40 constexpr int WIFI_COUNTRY_CODE_DYNAMIC_UPDATE_SIZE = 16;
41 constexpr int OPERATOR_NUMERIC_SIZE = 16;
42 constexpr int SYSTEM_PARAMETER_ERROR_CODE = 0;
43 constexpr int PLMN_LEN = 3;
44 constexpr int PLMN_SUBSTR_LEFT = 0;
45 constexpr int PLMN_SUBSTR_RIGHT = 3;
46 constexpr int SLOT_ID = 0;
47 constexpr int MAX_SCAN_SAVED_SIZE = 3;
48 constexpr unsigned int COUNTRY_CODE_EID = 7;
49 constexpr int DEFAULT_REGION_SIZE = 16;
50 constexpr int BSSID_VECTOR_INDEX_ZERO = 0;
51 constexpr int BSSID_VECTOR_INDEX_ONE = 1;
52 constexpr int BSSID_VECTOR_INDEX_TWO = 2;
53 constexpr int BSSID_VECTOR_INDEX_THREE = 3;
54 constexpr int FEATURE_MCC = 0;
55 constexpr int FEATURE_RCV_AP_CONNECTED = 1;
56 constexpr int FEATURE_RCV_SCAN_RESLUT = 2;
57 constexpr int FEATURE_USE_REGION = 3;
58 constexpr int FEATURE_USE_ZZ = 4;
59 constexpr int TRIGGER_UPDATE_REASON_SCAN_CHANGE = 1;
60 constexpr int TRIGGER_UPDATE_REASON_TEL_NET_CHANGE = 2;
61 
62 struct MccEntry {
63     int mnc;
64     const char* iso;
65     int smallestDigitsMcc;
66 };
67 
68 /*
69  * The table below is built from two resources:
70  *
71  * 1) ITU "Mobile Network Code (MNC) for the international
72  *   identification plan for mobile terminals and mobile users"
73  *   which is available as an annex to the ITU operational bulletin
74  *   available here: http://www.itu.int/itu-t/bulletin/annex.html
75  *
76  * 2) The ISO 3166 country codes list, available here:
77  *    http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html
78  *
79  * very importent: The order of mnc must be from small to large!
80  */
81 const MccEntry MCC_TABLE[] = {
82     // Fake country code, which is the default value, Scan only 2.4G channels and passively receive 5G beacons
83     {0, "zz", 0},
84 
85     // Greece
86     {202, "gr", 2},
87 
88     // Netherlands Kingdom of the
89     {204, "nl", 2},
90 
91     // Belgium
92     {206, "be", 2},
93 
94     // France
95     {208, "fr", 2},
96 
97     // Monaco Principality of
98     {212, "mc", 2},
99 
100     // Andorra Principality of
101     {213, "ad", 2},
102 
103     // Spain
104     {214, "es", 2},
105 
106     // Hungary Republic of
107     {216, "hu", 2},
108 
109     // Bosnia and Herzegovina
110     {218, "ba", 2},
111 
112     // Croatia Republic of
113     {219, "hr", 2},
114 
115     // Serbia and Montenegro
116     {220, "rs", 2},
117 
118     // Italy
119     {222, "it", 2},
120 
121     // Vatican City State
122     {225, "va", 2},
123 
124     // Romania
125     {226, "ro", 2},
126 
127     // Switzerland Confederation of
128     {228, "ch", 2},
129 
130     // Czech Republic
131     {230, "cz", 2},
132 
133     // Slovak Republic
134     {231, "sk", 2},
135 
136     // Austria
137     {232, "at", 2},
138 
139     // United Kingdom of Great Britain and Northern Ireland
140     {234, "gb", 2},
141 
142     // United Kingdom of Great Britain and Northern Ireland
143     {235, "gb", 2},
144 
145     // Denmark
146     {238, "dk", 2},
147 
148     // Sweden
149     {240, "se", 2},
150 
151     // Norway
152     {242, "no", 2},
153 
154     // Finland
155     {244, "fi", 2},
156 
157     // Lithuania Republic of
158     {246, "lt", 2},
159 
160     // Latvia Republic of
161     {247, "lv", 2},
162 
163     // Estonia Republic of
164     {248, "ee", 2},
165 
166     // Russian Federation
167     {250, "ru", 2},
168 
169     // Ukraine
170     {255, "ua", 2},
171 
172     // Belarus Republic of
173     {257, "by", 2},
174 
175     // Moldova Republic of
176     {259, "md", 2},
177 
178     // Poland Republic of
179     {260, "pl", 2},
180 
181     // Germany Federal Republic of
182     {262, "de", 2},
183 
184     // Gibraltar
185     {266, "gi", 2},
186 
187     // Portugal
188     {268, "pt", 2},
189 
190     // Luxembourg
191     {270, "lu", 2},
192 
193     // Ireland
194     {272, "ie", 2},
195 
196     // Iceland
197     {274, "is", 2},
198 
199     // Albania Republic of
200     {276, "al", 2},
201 
202     // Malta
203     {278, "mt", 2},
204 
205     // Cyprus Republic of
206     {280, "cy", 2},
207 
208     // Georgia
209     {282, "ge", 2},
210 
211     // Armenia Republic of
212     {283, "am", 2},
213 
214     // Bulgaria Republic of
215     {284, "bg", 2},
216 
217     // Turkey
218     {286, "tr", 2},
219 
220     // Faroe Islands
221     {288, "fo", 2},
222 
223     // Abkhazia Georgia
224     {289, "ge", 2},
225 
226     // Greenland Denmark
227     {290, "gl", 2},
228 
229     // San Marino Republic of
230     {292, "sm", 2},
231 
232     // Slovenia Republic of
233     {293, "si", 2},
234 
235     // The Former Yugoslav Republic of Macedonia
236     {294, "mk", 2},
237 
238     // Liechtenstein Principality of
239     {295, "li", 2},
240 
241     // Montenegro Republic of
242     {297, "me", 2},
243 
244     // Canada
245     {302, "ca", 3},
246 
247     // Saint Pierre and Miquelon Collectivit territoriale de la Rpublique franaise
248     {308, "pm", 2},
249 
250     // United States of America
251     {310, "us", 3},
252 
253     // United States of America
254     {311, "us", 3},
255 
256     // United States of America
257     {312, "us", 3},
258 
259     // United States of America
260     {313, "us", 3},
261 
262     // United States of America
263     {314, "us", 3},
264 
265     // United States of America
266     {315, "us", 3},
267 
268     // United States of America
269     {316, "us", 3},
270 
271     // Puerto Rico
272     {330, "pr", 2},
273 
274     // United States Virgin Islands
275     {332, "vi", 2},
276 
277     // Mexico
278     {334, "mx", 3},
279 
280     // Jamaica
281     {338, "jm", 3},
282 
283     // Guadeloupe French Department of
284     {340, "gp", 2},
285 
286     // Barbados
287     {342, "bb", 3},
288 
289     // Antigua and Barbuda
290     {344, "ag", 3},
291 
292     // Cayman Islands
293     {346, "ky", 3},
294 
295     // British Virgin Islands
296     {348, "vg", 3},
297 
298     // Bermuda
299     {350, "bm", 2},
300 
301     // Grenada
302     {352, "gd", 2},
303 
304     // Montserrat
305     {354, "ms", 2},
306 
307     // Saint Kitts and Nevis
308     {356, "kn", 2},
309 
310     // Saint Lucia
311     {358, "lc", 2},
312 
313     // Saint Vincent and the Grenadines
314     {360, "vc", 2},
315 
316     // Netherlands Antilles
317     {362, "an", 2},
318 
319     // Aruba
320     {363, "aw", 2},
321 
322     // Bahamas Commonwealth of the
323     {364, "bs", 2},
324 
325     // Anguilla
326     {365, "ai", 3},
327 
328     // Dominica Commonwealth of
329     {366, "dm", 2},
330 
331     // Cuba
332     {368, "cu", 2},
333 
334     // Dominican Republic
335     {370, "do", 2},
336 
337     // Haiti Republic of
338     {372, "ht", 2},
339 
340     // Trinidad and Tobago
341     {374, "tt", 2},
342 
343     // Turks and Caicos Islands
344     {376, "tc", 2},
345 
346     // Azerbaijani Republic
347     {400, "az", 2},
348 
349     // Kazakhstan Republic of
350     {401, "kz", 2},
351 
352     // Bhutan Kingdom of
353     {402, "bt", 2},
354 
355     // India Republic of
356     {404, "in", 2},
357 
358     // India Republic of
359     {405, "in", 2},
360 
361     // India Republic of
362     {406, "in", 2},
363 
364     // Pakistan Islamic Republic of
365     {410, "pk", 2},
366 
367     // Afghanistan
368     {412, "af", 2},
369 
370     // Sri Lanka Democratic Socialist Republic of
371     {413, "lk", 2},
372 
373     // Myanmar Union of
374     {414, "mm", 2},
375 
376     // Lebanon
377     {415, "lb", 2},
378 
379     // Jordan Hashemite Kingdom of
380     {416, "jo", 2},
381 
382     // Syrian Arab Republic
383     {417, "sy", 2},
384 
385     // Iraq Republic of
386     {418, "iq", 2},
387 
388     // Kuwait State of
389     {419, "kw", 2},
390 
391     // Saudi Arabia Kingdom of
392     {420, "sa", 2},
393 
394     // Yemen Republic of
395     {421, "ye", 2},
396 
397     // Oman Sultanate of
398     {422, "om", 2},
399 
400     // Palestine
401     {423, "ps", 2},
402 
403     // United Arab Emirates
404     {424, "ae", 2},
405 
406     // Israel State of
407     {425, "il", 2},
408 
409     // Bahrain Kingdom of
410     {426, "bh", 2},
411 
412     // Qatar State of
413     {427, "qa", 2},
414 
415     // Mongolia
416     {428, "mn", 2},
417 
418     // Nepal
419     {429, "np", 2},
420 
421     // United Arab Emirates
422     {430, "ae", 2},
423 
424     // United Arab Emirates
425     {431, "ae", 2},
426 
427     // Iran Islamic Republic of
428     {432, "ir", 2},
429 
430     // Uzbekistan Republic of
431     {434, "uz", 2},
432 
433     // Tajikistan Republic of
434     {436, "tj", 2},
435 
436     // Kyrgyz Republic
437     {437, "kg", 2},
438 
439     // Turkmenistan
440     {438, "tm", 2},
441 
442     // Japan
443     {440, "jp", 2},
444 
445     // Japan
446     {441, "jp", 2},
447 
448     // Korea Republic of
449     {450, "kr", 2},
450 
451     // Viet Nam Socialist Republic of
452     {452, "vn", 2},
453 
454     // "Hong Kong, China"
455     {454, "hk", 2},
456 
457     // "Macao, China"
458     {455, "mo", 2},
459 
460     // Cambodia Kingdom of
461     {456, "kh", 2},
462 
463     // Lao People's Democratic Republic
464     {457, "la", 2},
465 
466     // China People's Republic of
467     {460, "cn", 2},
468 
469     // China People's Republic of
470     {461, "cn", 2},
471 
472     // "Taiwan, China"
473     {466, "tw", 2},
474 
475     // Democratic People's Republic of Korea
476     {467, "kp", 2},
477 
478     // Bangladesh People's Republic of
479     {470, "bd", 2},
480 
481     // Maldives Republic of
482     {472, "mv", 2},
483 
484     // Malaysia
485     {502, "my", 2},
486 
487     // Australia
488     {505, "au", 2},
489 
490     // Indonesia Republic of
491     {510, "id", 2},
492 
493     // Democratic Republic of Timor-Leste
494     {514, "tl", 2},
495 
496     // Philippines Republic of the
497     {515, "ph", 2},
498 
499     // Thailand
500     {520, "th", 2},
501 
502     // Singapore Republic of
503     {525, "sg", 2},
504 
505     // Brunei Darussalam
506     {528, "bn", 2},
507 
508     // New Zealand
509     {530, "nz", 2},
510 
511     // Northern Mariana Islands Commonwealth of the
512     {534, "mp", 2},
513 
514     // Guam
515     {535, "gu", 2},
516 
517     // Nauru Republic of
518     {536, "nr", 2},
519 
520     // Papua New Guinea
521     {537, "pg", 2},
522 
523     // Tonga Kingdom of
524     {539, "to", 2},
525 
526     // Solomon Islands
527     {540, "sb", 2},
528 
529     // Vanuatu Republic of
530     {541, "vu", 2},
531 
532     // Fiji Republic of
533     {542, "fj", 2},
534 
535     // Wallis and Futuna Territoire franais d'outre-mer
536     {543, "wf", 2},
537 
538     // American Samoa
539     {544, "as", 2},
540 
541     // Kiribati Republic of
542     {545, "ki", 2},
543 
544     // New Caledonia Territoire franais d'outre-mer
545     {546, "nc", 2},
546 
547     // French Polynesia Territoire franais d'outre-mer
548     {547, "pf", 2},
549 
550     // Cook Islands
551     {548, "ck", 2},
552 
553     // Samoa Independent State of
554     {549, "ws", 2},
555 
556     // Micronesia Federated States of
557     {550, "fm", 2},
558 
559     // Marshall Islands Republic of the
560     {551, "mh", 2},
561 
562     // Palau Republic of
563     {552, "pw", 2},
564 
565     // Tuvalu
566     {553, "tv", 2},
567 
568     // Niue
569     {555, "nu", 2},
570 
571     // Egypt Arab Republic of
572     {602, "eg", 2},
573 
574     // Algeria People's Democratic Republic of
575     {603, "dz", 2},
576 
577     // Morocco Kingdom of
578     {604, "ma", 2},
579 
580     // Tunisia
581     {605, "tn", 2},
582 
583     // Libya Socialist People's Libyan Arab Jamahiriya
584     {606, "ly", 2},
585 
586     // Gambia Republic of the
587     {607, "gm", 2},
588 
589     // Senegal Republic of
590     {608, "sn", 2},
591 
592     // Mauritania Islamic Republic of
593     {609, "mr", 2},
594 
595     // Mali Republic of
596     {610, "ml", 2},
597 
598     // Guinea Republic of
599     {611, "gn", 2},
600 
601     // C?te d'Ivoire Republic of
602     {612, "ci", 2},
603 
604     // Burkina Faso
605     {613, "bf", 2},
606 
607     // Niger Republic of the
608     {614, "ne", 2},
609 
610     // Togolese Republic
611     {615, "tg", 2},
612 
613     // Benin Republic of
614     {616, "bj", 2},
615 
616     // Mauritius Republic of
617     {617, "mu", 2},
618 
619     // Liberia Republic of
620     {618, "lr", 2},
621 
622     // Sierra Leone
623     {619, "sl", 2},
624 
625     // Ghana
626     {620, "gh", 2},
627 
628     // Nigeria Federal Republic of
629     {621, "ng", 2},
630 
631     // Chad Republic of
632     {622, "td", 2},
633 
634     // Central African Republic
635     {623, "cf", 2},
636 
637     // Cameroon Republic of
638     {624, "cm", 2},
639 
640     // Cape Verde Republic of
641     {625, "cv", 2},
642 
643     // Sao Tome and Principe Democratic Republic of
644     {626, "st", 2},
645 
646     // Equatorial Guinea Republic of
647     {627, "gq", 2},
648 
649     // Gabonese Republic
650     {628, "ga", 2},
651 
652     // Congo Republic of the
653     {629, "cg", 2},
654 
655     // Democratic Republic of the Congo
656     {630, "cd", 2},
657 
658     // Angola Republic of
659     {631, "ao", 2},
660 
661     // Guinea-Bissau Republic of
662     {632, "gw", 2},
663 
664     // Seychelles Republic of
665     {633, "sc", 2},
666 
667     // Sudan Republic of the
668     {634, "sd", 2},
669 
670     // Rwanda Republic of
671     {635, "rw", 2},
672 
673     // Ethiopia Federal Democratic Republic of
674     {636, "et", 2},
675 
676     // Somali Democratic Republic
677     {637, "so", 2},
678 
679     // Djibouti Republic of
680     {638, "dj", 2},
681 
682     // Kenya Republic of
683     {639, "ke", 2},
684 
685     // Tanzania United Republic of
686     {640, "tz", 2},
687 
688     // Uganda Republic of
689     {641, "ug", 2},
690 
691     // Burundi Republic of
692     {642, "bi", 2},
693 
694     // Mozambique Republic of
695     {643, "mz", 2},
696 
697     // Zambia Republic of
698     {645, "zm", 2},
699 
700     // Madagascar Republic of
701     {646, "mg", 2},
702 
703     // Reunion French Department of
704     {647, "re", 2},
705 
706     // Comoros and Mayotte(re and yt are the same mcc)
707     {647, "yt", 2},
708 
709     // Zimbabwe Republic of
710     {648, "zw", 2},
711 
712     // Namibia Republic of
713     {649, "na", 2},
714 
715     // Malawi
716     {650, "mw", 2},
717 
718     // Lesotho Kingdom of
719     {651, "ls", 2},
720 
721     // Botswana Republic of
722     {652, "bw", 2},
723 
724     // Swaziland Kingdom of
725     {653, "sz", 2},
726 
727     // Comoros Union of the
728     {654, "km", 2},
729 
730     // South Africa Republic of
731     {655, "za", 2},
732 
733     // Eritrea
734     {657, "er", 2},
735 
736     // Saint Helena, Ascension and Tristan da Cunha
737     {658, "sh", 2},
738 
739     // South Sudan Republic of
740     {659, "ss", 2},
741 
742     // Belize
743     {702, "bz", 2},
744 
745     // Guatemala Republic of
746     {704, "gt", 2},
747 
748     // El Salvador Republic of
749     {706, "sv", 2},
750 
751     // Honduras Republic of
752     {708, "hn", 3},
753 
754     // Nicaragua
755     {710, "ni", 2},
756 
757     // Costa Rica
758     {712, "cr", 2},
759 
760     // Panama Republic of
761     {714, "pa", 2},
762 
763     // Peru
764     {716, "pe", 2},
765 
766     // Argentine Republic
767     {722, "ar", 3},
768 
769     // Brazil Federative Republic of
770     {724, "br", 2},
771 
772     // Chile
773     {730, "cl", 2},
774 
775     // Colombia Republic of
776     {732, "co", 3},
777 
778     // Venezuela Bolivarian Republic of
779     {734, "ve", 2},
780 
781     // Bolivia Republic of
782     {736, "bo", 2},
783 
784     // Guyana
785     {738, "gy", 2},
786 
787     // Ecuador
788     {740, "ec", 2},
789 
790     // French Guiana French Department of
791     {742, "gf", 2},
792 
793     // Paraguay Republic of
794     {744, "py", 2},
795 
796     // Suriname Republic of
797     {746, "sr", 2},
798 
799     // Uruguay Eastern Republic of
800     {748, "uy", 2},
801 
802     // Falkland Islands Malvinas
803     {750, "fk", 2}
804 };
805 }
806 }
807 #endif