1#!/usr/bin/env python3
2#
3#   Copyright 2016 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16from acts.utils import NexusModelNames
17from acts.test_utils.tel import tel_defines
18
19
20def rat_family_from_rat(rat_type):
21    return _TelTables.technology_tbl[rat_type]['rat_family']
22
23
24def rat_generation_from_rat(rat_type):
25    return _TelTables.technology_tbl[rat_type]['generation']
26
27
28def network_preference_for_generation(generation, operator, phone_type=None):
29    if not phone_type:
30        return _TelTables.operator_network_tbl[operator][generation][
31            'network_preference']
32    else:
33        return _TelTables.operator_network_tbl_by_phone_type[phone_type][
34            generation]['network_preference']
35
36
37def rat_families_for_network_preference(network_preference):
38    return _TelTables.network_preference_tbl[network_preference][
39        'rat_family_list']
40
41
42def rat_family_for_generation(generation, operator, phone_type=None):
43    if not phone_type:
44        return _TelTables.operator_network_tbl[operator][generation][
45            'rat_family']
46    else:
47        return _TelTables.operator_network_tbl_by_phone_type[phone_type][
48            generation]['rat_family']
49
50
51def operator_name_from_plmn_id(plmn_id):
52    return _TelTables.operator_id_to_name[plmn_id]
53
54
55def operator_name_from_network_name(name):
56    return _TelTables.operator_name_tbl.get("name", name)
57
58
59def is_valid_rat(rat_type):
60    return True if rat_type in _TelTables.technology_tbl else False
61
62
63def is_valid_generation(gen):
64    return True if gen in _TelTables.technology_gen_tbl else False
65
66
67def is_rat_svd_capable(rat):
68    return _TelTables.technology_tbl[rat]["simultaneous_voice_data"]
69
70
71def connection_type_from_type_string(input_string):
72    if input_string in _ConnectionTables.connection_type_tbl:
73        return _ConnectionTables.connection_type_tbl[input_string]
74    return tel_defines.NETWORK_CONNECTION_TYPE_UNKNOWN
75
76
77def is_user_plane_data_type(connection_type):
78    if connection_type in _ConnectionTables.user_plane_data_type:
79        return _ConnectionTables.user_plane_data_type[connection_type]
80    return False
81
82
83# For TMO, to check if voice mail count is correct after leaving a new voice message.
84def check_tmo_voice_mail_count(voice_mail_count_before,
85                               voice_mail_count_after):
86    return (voice_mail_count_after == -1)
87
88
89# For ATT, to check if voice mail count is correct after leaving a new voice message.
90def check_att_voice_mail_count(voice_mail_count_before,
91                               voice_mail_count_after):
92    return (voice_mail_count_after == (voice_mail_count_before + 1))
93
94
95# For SPT, to check if voice mail count is correct after leaving a new voice message.
96def check_spt_voice_mail_count(voice_mail_count_before,
97                               voice_mail_count_after):
98    return (voice_mail_count_after == (voice_mail_count_before + 1))
99
100
101def get_voice_mail_check_number(operator):
102    return _TelTables.voice_mail_number_tbl.get(operator)
103
104
105def get_voice_mail_count_check_function(operator):
106    return _TelTables.voice_mail_count_check_function_tbl.get(
107        operator, check_tmo_voice_mail_count)
108
109
110def get_voice_mail_delete_digit(operator):
111    return _TelTables.voice_mail_delete_digit_tbl.get(operator, "7")
112
113
114def get_allowable_network_preference(operator, phone_type=None):
115    if not phone_type:
116        return _TelTables.allowable_network_preference_tbl[operator]
117    else:
118        return _TelTables.allowable_network_preference_tbl_by_phone_type[
119            phone_type]
120
121
122class _ConnectionTables():
123    connection_type_tbl = {
124        'WIFI': tel_defines.NETWORK_CONNECTION_TYPE_WIFI,
125        'WIFI_P2P': tel_defines.NETWORK_CONNECTION_TYPE_WIFI,
126        'MOBILE': tel_defines.NETWORK_CONNECTION_TYPE_CELL,
127        'MOBILE_DUN': tel_defines.NETWORK_CONNECTION_TYPE_CELL,
128        'MOBILE_HIPRI': tel_defines.NETWORK_CONNECTION_TYPE_HIPRI,
129        # TODO: b/26296489 add support for 'MOBILE_SUPL', 'MOBILE_HIPRI',
130        # 'MOBILE_FOTA', 'MOBILE_IMS', 'MOBILE_CBS', 'MOBILE_IA',
131        # 'MOBILE_EMERGENCY'
132        'MOBILE_MMS': tel_defines.NETWORK_CONNECTION_TYPE_MMS
133    }
134
135    user_plane_data_type = {
136        tel_defines.NETWORK_CONNECTION_TYPE_WIFI: True,
137        tel_defines.NETWORK_CONNECTION_TYPE_CELL: False,
138        tel_defines.NETWORK_CONNECTION_TYPE_MMS: False,
139        tel_defines.NETWORK_CONNECTION_TYPE_UNKNOWN: False
140    }
141
142
143class _TelTables():
144    # Operator id mapping to operator name
145    # Reference: Pages 43-50 in
146    # https://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.212B-2013-PDF-E.pdf [2013]
147
148    operator_name_tbl = {
149        "T-Mobile": tel_defines.CARRIER_TMO,
150        "AT&T": tel_defines.CARRIER_ATT,
151        "Verizon": tel_defines.CARRIER_VZW,
152        "Verizon Wireless": tel_defines.CARRIER_VZW,
153        "Sprint": tel_defines.CARRIER_SPT,
154        "ROGERS": tel_defines.CARRIER_ROGERS,
155        "Videotron PRTNR1": tel_defines.CARRIER_VIDEOTRON,
156        "Bell": tel_defines.CARRIER_BELL,
157        "Koodo": tel_defines.CARRIER_KOODO,
158        "Ntt Docomo" : tel_defines.CARRIER_NTT_DOCOMO,
159        "KDDI" : tel_defines.CARRIER_KDDI,
160        "Rakuten": tel_defines.CARRIER_RAKUTEN,
161        "SBM": tel_defines.CARRIER_SBM
162    }
163    operator_id_to_name = {
164
165        #VZW (Verizon Wireless)
166        '310010': tel_defines.CARRIER_VZW,
167        '310012': tel_defines.CARRIER_VZW,
168        '310013': tel_defines.CARRIER_VZW,
169        '310590': tel_defines.CARRIER_VZW,
170        '310890': tel_defines.CARRIER_VZW,
171        '310910': tel_defines.CARRIER_VZW,
172        '310110': tel_defines.CARRIER_VZW,
173        '311270': tel_defines.CARRIER_VZW,
174        '311271': tel_defines.CARRIER_VZW,
175        '311272': tel_defines.CARRIER_VZW,
176        '311273': tel_defines.CARRIER_VZW,
177        '311274': tel_defines.CARRIER_VZW,
178        '311275': tel_defines.CARRIER_VZW,
179        '311276': tel_defines.CARRIER_VZW,
180        '311277': tel_defines.CARRIER_VZW,
181        '311278': tel_defines.CARRIER_VZW,
182        '311279': tel_defines.CARRIER_VZW,
183        '311280': tel_defines.CARRIER_VZW,
184        '311281': tel_defines.CARRIER_VZW,
185        '311282': tel_defines.CARRIER_VZW,
186        '311283': tel_defines.CARRIER_VZW,
187        '311284': tel_defines.CARRIER_VZW,
188        '311285': tel_defines.CARRIER_VZW,
189        '311286': tel_defines.CARRIER_VZW,
190        '311287': tel_defines.CARRIER_VZW,
191        '311288': tel_defines.CARRIER_VZW,
192        '311289': tel_defines.CARRIER_VZW,
193        '311390': tel_defines.CARRIER_VZW,
194        '311480': tel_defines.CARRIER_VZW,
195        '311481': tel_defines.CARRIER_VZW,
196        '311482': tel_defines.CARRIER_VZW,
197        '311483': tel_defines.CARRIER_VZW,
198        '311484': tel_defines.CARRIER_VZW,
199        '311485': tel_defines.CARRIER_VZW,
200        '311486': tel_defines.CARRIER_VZW,
201        '311487': tel_defines.CARRIER_VZW,
202        '311488': tel_defines.CARRIER_VZW,
203        '311489': tel_defines.CARRIER_VZW,
204
205        #TMO (T-Mobile USA)
206        '310160': tel_defines.CARRIER_TMO,
207        '310200': tel_defines.CARRIER_TMO,
208        '310210': tel_defines.CARRIER_TMO,
209        '310220': tel_defines.CARRIER_TMO,
210        '310230': tel_defines.CARRIER_TMO,
211        '310240': tel_defines.CARRIER_TMO,
212        '310250': tel_defines.CARRIER_TMO,
213        '310260': tel_defines.CARRIER_TMO,
214        '310270': tel_defines.CARRIER_TMO,
215        '310310': tel_defines.CARRIER_TMO,
216        '310490': tel_defines.CARRIER_TMO,
217        '310660': tel_defines.CARRIER_TMO,
218        '310800': tel_defines.CARRIER_TMO,
219
220        #ATT (AT&T and Cingular)
221        '310070': tel_defines.CARRIER_ATT,
222        '310560': tel_defines.CARRIER_ATT,
223        '310670': tel_defines.CARRIER_ATT,
224        '310680': tel_defines.CARRIER_ATT,
225        '310150': tel_defines.CARRIER_ATT,  #Cingular
226        '310170': tel_defines.CARRIER_ATT,  #Cingular
227        '310410': tel_defines.CARRIER_ATT,  #Cingular
228        '311180': tel_defines.CARRIER_ATT,
229        #Cingular Licensee Pacific Telesis Mobile Services, LLC
230
231        #Sprint (and Sprint-Nextel)
232        '310120': tel_defines.CARRIER_SPT,
233        '311490': tel_defines.CARRIER_SPT,
234        '311870': tel_defines.CARRIER_SPT,
235        '311880': tel_defines.CARRIER_SPT,
236        '312190': tel_defines.CARRIER_SPT,  #Sprint-Nextel Communications Inc
237        '316010': tel_defines.CARRIER_SPT,  #Sprint-Nextel Communications Inc
238        '23433': tel_defines.CARRIER_EEUK,  #Orange
239        '23434': tel_defines.CARRIER_EEUK,  #Orange
240        '23430': tel_defines.CARRIER_EEUK,  #T-Mobile UK
241        '23431': tel_defines.CARRIER_EEUK,  #Virgin Mobile (MVNO)
242        '23432': tel_defines.CARRIER_EEUK,  #Virgin Mobile (MVNO)
243        '23415': tel_defines.CARRIER_VFUK,
244
245        # Google Fi
246        '312580': tel_defines.CARRIER_FI,
247
248        #USCC
249        '311580': tel_defines.CARRIER_USCC,
250
251        #Vodafone (Germany)
252        '26202': tel_defines.CARRIER_GMBH,
253        '26204': tel_defines.CARRIER_GMBH,
254        '26209': tel_defines.CARRIER_GMBH,
255        '26242': tel_defines.CARRIER_GMBH,
256        '26243': tel_defines.CARRIER_GMBH,
257
258        #Vodafone (Italy)
259        '22206': tel_defines.CARRIER_ITA,
260        '22210': tel_defines.CARRIER_ITA,
261
262        #Vodafone (Spain)
263        '21401': tel_defines.CARRIER_ESP,
264        '20406': tel_defines.CARRIER_ESP,
265
266        #Orange (France)
267        '20801': tel_defines.CARRIER_ORG,
268        '20802': tel_defines.CARRIER_ORG,
269        '20891': tel_defines.CARRIER_ORG,
270
271        #Telenor (Norway)
272        '24201': tel_defines.CARRIER_TEL,
273        '24212': tel_defines.CARRIER_TEL,
274
275        #Canada Freedom
276        '302490': tel_defines.CARRIER_FRE,
277
278        #Telstra (Australia)
279        '52501': tel_defines.CARRIER_SING,
280        '50501': tel_defines.CARRIER_TSA
281    }
282
283    technology_gen_tbl = [
284        tel_defines.GEN_2G, tel_defines.GEN_3G, tel_defines.GEN_4G
285    ]
286
287    technology_tbl = {
288        tel_defines.RAT_1XRTT: {
289            'is_voice_rat': True,
290            'is_data_rat': False,
291            'generation': tel_defines.GEN_3G,
292            'simultaneous_voice_data': False,
293            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
294        },
295        tel_defines.RAT_EDGE: {
296            'is_voice_rat': False,
297            'is_data_rat': True,
298            'generation': tel_defines.GEN_2G,
299            'simultaneous_voice_data': False,
300            'rat_family': tel_defines.RAT_FAMILY_GSM
301        },
302        tel_defines.RAT_GPRS: {
303            'is_voice_rat': False,
304            'is_data_rat': True,
305            'generation': tel_defines.GEN_2G,
306            'simultaneous_voice_data': False,
307            'rat_family': tel_defines.RAT_FAMILY_GSM
308        },
309        tel_defines.RAT_GSM: {
310            'is_voice_rat': True,
311            'is_data_rat': False,
312            'generation': tel_defines.GEN_2G,
313            'simultaneous_voice_data': False,
314            'rat_family': tel_defines.RAT_FAMILY_GSM
315        },
316        tel_defines.RAT_UMTS: {
317            'is_voice_rat': True,
318            'is_data_rat': True,
319            'generation': tel_defines.GEN_3G,
320            'simultaneous_voice_data': True,
321            'rat_family': tel_defines.RAT_FAMILY_WCDMA
322        },
323        tel_defines.RAT_WCDMA: {
324            'is_voice_rat': True,
325            'is_data_rat': True,
326            'generation': tel_defines.GEN_3G,
327            'simultaneous_voice_data': True,
328            'rat_family': tel_defines.RAT_FAMILY_WCDMA
329        },
330        tel_defines.RAT_HSDPA: {
331            'is_voice_rat': False,
332            'is_data_rat': True,
333            'generation': tel_defines.GEN_3G,
334            'simultaneous_voice_data': False,
335            'rat_family': tel_defines.RAT_FAMILY_WCDMA
336        },
337        tel_defines.RAT_HSUPA: {
338            'is_voice_rat': False,
339            'is_data_rat': True,
340            'generation': tel_defines.GEN_3G,
341            'simultaneous_voice_data': False,
342            'rat_family': tel_defines.RAT_FAMILY_WCDMA
343        },
344        tel_defines.RAT_CDMA: {
345            'is_voice_rat': True,
346            'is_data_rat': False,
347            'generation': tel_defines.GEN_2G,
348            'simultaneous_voice_data': False,
349            'rat_family': tel_defines.RAT_FAMILY_CDMA
350        },
351        tel_defines.RAT_EVDO: {
352            'is_voice_rat': False,
353            'is_data_rat': True,
354            'generation': tel_defines.GEN_3G,
355            'simultaneous_voice_data': False,
356            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
357        },
358        tel_defines.RAT_EVDO_0: {
359            'is_voice_rat': False,
360            'is_data_rat': True,
361            'generation': tel_defines.GEN_3G,
362            'simultaneous_voice_data': False,
363            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
364        },
365        tel_defines.RAT_EVDO_A: {
366            'is_voice_rat': False,
367            'is_data_rat': True,
368            'generation': tel_defines.GEN_3G,
369            'simultaneous_voice_data': False,
370            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
371        },
372        tel_defines.RAT_EVDO_B: {
373            'is_voice_rat': False,
374            'is_data_rat': True,
375            'generation': tel_defines.GEN_3G,
376            'simultaneous_voice_data': False,
377            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
378        },
379        tel_defines.RAT_IDEN: {
380            'is_voice_rat': False,
381            'is_data_rat': True,
382            'generation': tel_defines.GEN_2G,
383            'simultaneous_voice_data': False,
384            'rat_family': tel_defines.RAT_FAMILY_IDEN
385        },
386        tel_defines.RAT_LTE_CA: {
387            'is_voice_rat': True,
388            'is_data_rat': True,
389            'generation': tel_defines.GEN_4G,
390            'simultaneous_voice_data': True,
391            'rat_family': tel_defines.RAT_FAMILY_LTE
392        },
393        tel_defines.RAT_LTE: {
394            'is_voice_rat': True,
395            'is_data_rat': True,
396            'generation': tel_defines.GEN_4G,
397            'simultaneous_voice_data': True,
398            'rat_family': tel_defines.RAT_FAMILY_LTE
399        },
400        tel_defines.RAT_NR: {
401            'is_voice_rat': True,
402            'is_data_rat': True,
403            'generation': tel_defines.GEN_5G,
404            'simultaneous_voice_data': True,
405            'rat_family': tel_defines.RAT_FAMILY_NR
406        },
407        tel_defines.RAT_EHRPD: {
408            'is_voice_rat': False,
409            'is_data_rat': True,
410            'generation': tel_defines.GEN_3G,
411            'simultaneous_voice_data': False,
412            'rat_family': tel_defines.RAT_FAMILY_CDMA2000
413        },
414        tel_defines.RAT_HSPA: {
415            'is_voice_rat': False,
416            'is_data_rat': True,
417            'generation': tel_defines.GEN_3G,
418            'simultaneous_voice_data': True,
419            'rat_family': tel_defines.RAT_FAMILY_WCDMA
420        },
421        tel_defines.RAT_HSPAP: {
422            'is_voice_rat': False,
423            'is_data_rat': True,
424            'generation': tel_defines.GEN_3G,
425            'simultaneous_voice_data': True,
426            'rat_family': tel_defines.RAT_FAMILY_WCDMA
427        },
428        tel_defines.RAT_IWLAN: {
429            'is_voice_rat': True,
430            'is_data_rat': True,
431            'generation': tel_defines.GEN_4G,
432            'simultaneous_voice_data': True,
433            'rat_family': tel_defines.RAT_FAMILY_WLAN
434        },
435        tel_defines.RAT_TD_SCDMA: {
436            'is_voice_rat': True,
437            'is_data_rat': True,
438            'generation': tel_defines.GEN_3G,
439            'simultaneous_voice_data': True,
440            'rat_family': tel_defines.RAT_FAMILY_TDSCDMA
441        },
442        tel_defines.RAT_UNKNOWN: {
443            'is_voice_rat': False,
444            'is_data_rat': False,
445            'generation': tel_defines.GEN_UNKNOWN,
446            'simultaneous_voice_data': False,
447            'rat_family': tel_defines.RAT_FAMILY_UNKNOWN
448        },
449        tel_defines.RAT_GLOBAL: {
450            'is_voice_rat': False,
451            'is_data_rat': False,
452            'generation': tel_defines.GEN_UNKNOWN,
453            'simultaneous_voice_data': False,
454            'rat_family': tel_defines.RAT_FAMILY_UNKNOWN
455        }
456    }
457
458    network_preference_tbl = {
459        tel_defines.NETWORK_MODE_LTE_GSM_WCDMA: {
460            'rat_family_list': [
461                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_WCDMA,
462                tel_defines.RAT_FAMILY_GSM
463            ]
464        },
465        tel_defines.NETWORK_MODE_GSM_UMTS: {
466            'rat_family_list':
467            [tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_GSM]
468        },
469        tel_defines.NETWORK_MODE_GSM_ONLY: {
470            'rat_family_list': [tel_defines.RAT_FAMILY_GSM]
471        },
472        tel_defines.NETWORK_MODE_LTE_CDMA_EVDO: {
473            'rat_family_list': [
474                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_CDMA2000,
475                tel_defines.RAT_FAMILY_CDMA
476            ]
477        },
478        tel_defines.NETWORK_MODE_CDMA: {
479            'rat_family_list':
480            [tel_defines.RAT_FAMILY_CDMA2000, tel_defines.RAT_FAMILY_CDMA]
481        },
482        tel_defines.NETWORK_MODE_CDMA_NO_EVDO: {
483            'rat_family_list':
484            [tel_defines.RAT_FAMILY_CDMA2000, tel_defines.RAT_FAMILY_CDMA]
485        },
486        tel_defines.NETWORK_MODE_WCDMA_PREF: {
487            'rat_family_list':
488            [tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_GSM]
489        },
490        tel_defines.NETWORK_MODE_WCDMA_ONLY: {
491            'rat_family_list': [tel_defines.RAT_FAMILY_WCDMA]
492        },
493        tel_defines.NETWORK_MODE_EVDO_NO_CDMA: {
494            'rat_family_list': [tel_defines.RAT_FAMILY_CDMA2000]
495        },
496        tel_defines.NETWORK_MODE_GLOBAL: {
497            'rat_family_list': [
498                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_TDSCDMA,
499                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_GSM,
500                tel_defines.RAT_FAMILY_CDMA2000, tel_defines.RAT_FAMILY_CDMA
501            ]
502        },
503        tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: {
504            'rat_family_list': [
505                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_WCDMA,
506                tel_defines.RAT_FAMILY_GSM, tel_defines.RAT_FAMILY_CDMA2000,
507                tel_defines.RAT_FAMILY_CDMA
508            ]
509        },
510        tel_defines.NETWORK_MODE_LTE_ONLY: {
511            'rat_family_list': [tel_defines.RAT_FAMILY_LTE]
512        },
513        tel_defines.NETWORK_MODE_LTE_WCDMA: {
514            'rat_family_list':
515            [tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_WCDMA]
516        },
517        tel_defines.NETWORK_MODE_TDSCDMA_ONLY: {
518            'rat_family_list': [tel_defines.RAT_FAMILY_TDSCDMA]
519        },
520        tel_defines.NETWORK_MODE_TDSCDMA_WCDMA: {
521            'rat_family_list':
522            [tel_defines.RAT_FAMILY_TDSCDMA, tel_defines.RAT_FAMILY_WCDMA]
523        },
524        tel_defines.NETWORK_MODE_LTE_TDSCDMA: {
525            'rat_family_list':
526            [tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_TDSCDMA]
527        },
528        tel_defines.NETWORK_MODE_TDSCDMA_GSM: {
529            'rat_family_list':
530            [tel_defines.RAT_FAMILY_TDSCDMA, tel_defines.RAT_FAMILY_GSM]
531        },
532        tel_defines.NETWORK_MODE_LTE_TDSCDMA_GSM: {
533            'rat_family_list': [
534                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_TDSCDMA,
535                tel_defines.RAT_FAMILY_GSM
536            ]
537        },
538        tel_defines.NETWORK_MODE_TDSCDMA_GSM_WCDMA: {
539            'rat_family_list': [
540                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_TDSCDMA,
541                tel_defines.RAT_FAMILY_GSM
542            ]
543        },
544        tel_defines.NETWORK_MODE_LTE_TDSCDMA_WCDMA: {
545            'rat_family_list': [
546                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_TDSCDMA,
547                tel_defines.RAT_FAMILY_LTE
548            ]
549        },
550        tel_defines.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA: {
551            'rat_family_list': [
552                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_TDSCDMA,
553                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_GSM
554            ]
555        },
556        tel_defines.NETWORK_MODE_TDSCDMA_CDMA_EVDO_WCDMA: {
557            'rat_family_list': [
558                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_TDSCDMA,
559                tel_defines.RAT_FAMILY_CDMA2000, tel_defines.RAT_FAMILY_CDMA
560            ]
561        },
562        tel_defines.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: {
563            'rat_family_list': [
564                tel_defines.RAT_FAMILY_WCDMA, tel_defines.RAT_FAMILY_TDSCDMA,
565                tel_defines.RAT_FAMILY_LTE, tel_defines.RAT_FAMILY_GSM,
566                tel_defines.RAT_FAMILY_CDMA2000, tel_defines.RAT_FAMILY_CDMA
567            ]
568        }
569    }
570    default_umts_operator_network_tbl = {
571        tel_defines.GEN_5G: {
572            'rat_family': tel_defines.RAT_FAMILY_NR,
573            'network_preference': tel_defines.NETWORK_MODE_NR_LTE_GSM_WCDMA
574        },
575        tel_defines.GEN_4G: {
576            'rat_family': tel_defines.RAT_FAMILY_LTE,
577            'network_preference':
578            tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
579        },
580        tel_defines.GEN_3G: {
581            'rat_family': tel_defines.RAT_FAMILY_WCDMA,
582            'network_preference': tel_defines.NETWORK_MODE_WCDMA_ONLY
583        },
584        tel_defines.GEN_2G: {
585            'rat_family': tel_defines.RAT_FAMILY_GSM,
586            'network_preference': tel_defines.NETWORK_MODE_GSM_ONLY
587        }
588    }
589    default_cdma_operator_network_tbl = {
590        tel_defines.GEN_5G: {
591            'rat_family': tel_defines.RAT_FAMILY_NR,
592            'network_preference': tel_defines.NETWORK_MODE_NR_LTE_GSM_WCDMA
593        },
594        tel_defines.GEN_4G: {
595            'rat_family': tel_defines.RAT_FAMILY_LTE,
596            'network_preference':
597            tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
598        },
599        tel_defines.GEN_3G: {
600            'rat_family': tel_defines.RAT_FAMILY_CDMA2000,
601            'network_preference': tel_defines.NETWORK_MODE_CDMA
602        },
603        tel_defines.GEN_2G: {
604            'rat_family': tel_defines.RAT_FAMILY_CDMA2000,
605            'network_preference': tel_defines.NETWORK_MODE_CDMA_NO_EVDO
606        }
607    }
608    operator_network_tbl = {
609        tel_defines.CARRIER_TMO: default_umts_operator_network_tbl,
610        tel_defines.CARRIER_ATT: default_umts_operator_network_tbl,
611        tel_defines.CARRIER_VZW: default_cdma_operator_network_tbl,
612        tel_defines.CARRIER_SPT: default_cdma_operator_network_tbl,
613        tel_defines.CARRIER_EEUK: default_umts_operator_network_tbl,
614        tel_defines.CARRIER_VFUK: default_umts_operator_network_tbl,
615        tel_defines.CARRIER_GMBH: default_umts_operator_network_tbl,
616        tel_defines.CARRIER_ITA: default_umts_operator_network_tbl,
617        tel_defines.CARRIER_ESP: default_umts_operator_network_tbl,
618        tel_defines.CARRIER_ORG: default_umts_operator_network_tbl,
619        tel_defines.CARRIER_TEL: default_umts_operator_network_tbl,
620        tel_defines.CARRIER_TSA: default_umts_operator_network_tbl
621    }
622    operator_network_tbl_by_phone_type = {
623        tel_defines.PHONE_TYPE_GSM: default_umts_operator_network_tbl,
624        tel_defines.PHONE_TYPE_CDMA: default_cdma_operator_network_tbl
625    }
626
627    umts_allowable_network_preference_tbl = \
628        [tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA,
629         tel_defines.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA,
630         tel_defines.NETWORK_MODE_LTE_GSM_WCDMA,
631         tel_defines.NETWORK_MODE_WCDMA_PREF,
632         tel_defines.NETWORK_MODE_WCDMA_ONLY,
633         tel_defines.NETWORK_MODE_GSM_ONLY]
634
635    cdma_allowable_network_preference_tbl = \
636        [tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA,
637         tel_defines.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA,
638         tel_defines.NETWORK_MODE_LTE_CDMA_EVDO,
639         tel_defines.NETWORK_MODE_CDMA,
640         tel_defines.NETWORK_MODE_CDMA_NO_EVDO,
641         tel_defines.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA]
642
643    allowable_network_preference_tbl = {
644        tel_defines.CARRIER_TMO: umts_allowable_network_preference_tbl,
645        tel_defines.CARRIER_ATT: umts_allowable_network_preference_tbl,
646        tel_defines.CARRIER_VZW: cdma_allowable_network_preference_tbl,
647        tel_defines.CARRIER_SPT: cdma_allowable_network_preference_tbl,
648        tel_defines.CARRIER_EEUK: umts_allowable_network_preference_tbl,
649        tel_defines.CARRIER_VFUK: umts_allowable_network_preference_tbl
650    }
651    allowable_network_preference_tbl_by_phone_type = {
652        tel_defines.PHONE_TYPE_GSM: umts_allowable_network_preference_tbl,
653        tel_defines.PHONE_TYPE_CDMA: cdma_allowable_network_preference_tbl
654    }
655
656    voice_mail_number_tbl = {
657        tel_defines.CARRIER_TMO: "123",
658        tel_defines.CARRIER_VZW: "*86",
659        tel_defines.CARRIER_ATT: None,
660        tel_defines.CARRIER_SPT: None,
661        tel_defines.CARRIER_EEUK: "+447953222222",
662        tel_defines.CARRIER_NTT_DOCOMO: "1417",
663        tel_defines.CARRIER_KDDI: "1417",
664        tel_defines.CARRIER_RAKUTEN: "1417",
665        tel_defines.CARRIER_SBM: "1416"
666    }
667
668    voice_mail_count_check_function_tbl = {
669        tel_defines.CARRIER_TMO: check_tmo_voice_mail_count,
670        tel_defines.CARRIER_ATT: check_att_voice_mail_count,
671        tel_defines.CARRIER_SPT: check_spt_voice_mail_count
672    }
673
674    voice_mail_delete_digit_tbl = {
675        tel_defines.CARRIER_EEUK: "3",
676        tel_defines.CARRIER_NTT_DOCOMO: "3",
677        tel_defines.CARRIER_KDDI: "9"
678    }
679
680
681device_capabilities = {
682    NexusModelNames.ONE:
683    [tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_MSIM],
684    NexusModelNames.N5: [tel_defines.CAPABILITY_PHONE],
685    NexusModelNames.N5v2: [
686        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
687        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC
688    ],
689    NexusModelNames.N6: [
690        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
691        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC
692    ],
693    NexusModelNames.N6v2: [
694        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
695        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC
696    ],
697    NexusModelNames.N5v3: [
698        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
699        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC,
700        tel_defines.CAPABILITY_VT
701    ],
702    NexusModelNames.N6v3: [
703        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
704        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC,
705        tel_defines.CAPABILITY_VT
706    ],
707    "default": [
708        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
709        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC,
710        tel_defines.CAPABILITY_VT
711    ]
712}
713
714operator_capabilities = {
715    tel_defines.CARRIER_VZW: [
716        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_OMADM,
717        tel_defines.CAPABILITY_VOLTE, tel_defines.CAPABILITY_WFC,
718        tel_defines.CAPABILITY_VT
719    ],
720    tel_defines.CARRIER_ATT:
721    [tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_VOLTE],
722    tel_defines.CARRIER_TMO: [
723        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_VOLTE,
724        tel_defines.CAPABILITY_WFC, tel_defines.CAPABILITY_VT
725    ],
726    tel_defines.CARRIER_SPT: [tel_defines.CAPABILITY_PHONE],
727    tel_defines.CARRIER_ROGERS: [
728        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_VOLTE,
729        tel_defines.CAPABILITY_WFC
730    ],
731    tel_defines.CARRIER_EEUK: [
732        tel_defines.CAPABILITY_PHONE, tel_defines.CAPABILITY_VOLTE,
733        tel_defines.CAPABILITY_WFC
734    ],
735    tel_defines.CARRIER_VFUK: [tel_defines.CAPABILITY_PHONE],
736    "default": [tel_defines.CAPABILITY_PHONE]
737}
738