1 /*
2  * Copyright (C) 2017 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 android.telephony;
18 
19 import android.annotation.IntDef;
20 import android.annotation.SystemApi;
21 import android.annotation.TestApi;
22 import android.hardware.radio.V1_1.GeranBands;
23 import android.hardware.radio.V1_5.AccessNetwork;
24 import android.hardware.radio.V1_5.EutranBands;
25 import android.hardware.radio.V1_5.UtranBands;
26 
27 import java.lang.annotation.Retention;
28 import java.lang.annotation.RetentionPolicy;
29 
30 /**
31  * Contains access network related constants.
32  */
33 public final class AccessNetworkConstants {
34 
35     /**
36      * Wireless transportation type
37      *
38      * @hide */
39     @Retention(RetentionPolicy.SOURCE)
40     @IntDef(prefix = {"TRANSPORT_TYPE_"},
41             value = {
42                     TRANSPORT_TYPE_INVALID,
43                     TRANSPORT_TYPE_WWAN,
44                     TRANSPORT_TYPE_WLAN})
45     public @interface TransportType {}
46 
47     /**
48      * Invalid transport type
49      * @hide
50      */
51     @SystemApi
52     @TestApi
53     public static final int TRANSPORT_TYPE_INVALID = -1;
54 
55     /**
56      * Transport type for Wireless Wide Area Networks (i.e. Cellular)
57      */
58     public static final int TRANSPORT_TYPE_WWAN = 1;
59 
60     /**
61      * Transport type for Wireless Local Area Networks (i.e. Wifi)
62      */
63     public static final int TRANSPORT_TYPE_WLAN = 2;
64 
65     /** @hide */
transportTypeToString(@ransportType int transportType)66     public static String transportTypeToString(@TransportType int transportType) {
67         switch (transportType) {
68             case TRANSPORT_TYPE_WWAN: return "WWAN";
69             case TRANSPORT_TYPE_WLAN: return "WLAN";
70             default: return Integer.toString(transportType);
71         }
72     }
73 
74     /**
75      * Access network type
76      * @hide
77      */
78     @Retention(RetentionPolicy.SOURCE)
79     @IntDef(prefix = {"RADIO_ACCESS_NETWORK_TYPE_"},
80             value = {
81                     AccessNetworkType.UNKNOWN,
82                     AccessNetworkType.GERAN,
83                     AccessNetworkType.UTRAN,
84                     AccessNetworkType.EUTRAN,
85                     AccessNetworkType.CDMA2000,
86                     AccessNetworkType.IWLAN,
87                     AccessNetworkType.NGRAN})
88     public @interface RadioAccessNetworkType {}
89 
90     public static final class AccessNetworkType {
91         public static final int UNKNOWN = AccessNetwork.UNKNOWN;
92         public static final int GERAN = AccessNetwork.GERAN;
93         public static final int UTRAN = AccessNetwork.UTRAN;
94         public static final int EUTRAN = AccessNetwork.EUTRAN;
95         public static final int CDMA2000 = AccessNetwork.CDMA2000;
96         public static final int IWLAN = AccessNetwork.IWLAN;
97         public static final int NGRAN = AccessNetwork.NGRAN;
98 
99         /** @hide */
AccessNetworkType()100         private AccessNetworkType() {}
101 
102         /** @hide */
toString(int type)103         public static String toString(int type) {
104             switch (type) {
105                 case UNKNOWN: return "UNKNOWN";
106                 case GERAN: return "GERAN";
107                 case UTRAN: return "UTRAN";
108                 case EUTRAN: return "EUTRAN";
109                 case CDMA2000: return "CDMA2000";
110                 case IWLAN: return "IWLAN";
111                 case NGRAN: return "NGRAN";
112                 default: return Integer.toString(type);
113             }
114         }
115     }
116 
117     /**
118      * Frequency bands for GERAN.
119      * http://www.etsi.org/deliver/etsi_ts/145000_145099/145005/14.00.00_60/ts_145005v140000p.pdf
120      */
121     public static final class GeranBand {
122         public static final int BAND_T380 = GeranBands.BAND_T380;
123         public static final int BAND_T410 = GeranBands.BAND_T410;
124         public static final int BAND_450 = GeranBands.BAND_450;
125         public static final int BAND_480 = GeranBands.BAND_480;
126         public static final int BAND_710 = GeranBands.BAND_710;
127         public static final int BAND_750 = GeranBands.BAND_750;
128         public static final int BAND_T810 = GeranBands.BAND_T810;
129         public static final int BAND_850 = GeranBands.BAND_850;
130         public static final int BAND_P900 = GeranBands.BAND_P900;
131         public static final int BAND_E900 = GeranBands.BAND_E900;
132         public static final int BAND_R900 = GeranBands.BAND_R900;
133         public static final int BAND_DCS1800 = GeranBands.BAND_DCS1800;
134         public static final int BAND_PCS1900 = GeranBands.BAND_PCS1900;
135         public static final int BAND_ER900 = GeranBands.BAND_ER900;
136 
137         /** @hide */
GeranBand()138         private GeranBand() {}
139     }
140 
141     /**
142      * Frequency bands for UTRAN.
143      * http://www.etsi.org/deliver/etsi_ts/125100_125199/125104/13.03.00_60/ts_125104v130p.pdf
144      */
145     public static final class UtranBand {
146         public static final int BAND_1 = UtranBands.BAND_1;
147         public static final int BAND_2 = UtranBands.BAND_2;
148         public static final int BAND_3 = UtranBands.BAND_3;
149         public static final int BAND_4 = UtranBands.BAND_4;
150         public static final int BAND_5 = UtranBands.BAND_5;
151         public static final int BAND_6 = UtranBands.BAND_6;
152         public static final int BAND_7 = UtranBands.BAND_7;
153         public static final int BAND_8 = UtranBands.BAND_8;
154         public static final int BAND_9 = UtranBands.BAND_9;
155         public static final int BAND_10 = UtranBands.BAND_10;
156         public static final int BAND_11 = UtranBands.BAND_11;
157         public static final int BAND_12 = UtranBands.BAND_12;
158         public static final int BAND_13 = UtranBands.BAND_13;
159         public static final int BAND_14 = UtranBands.BAND_14;
160         // band 15, 16, 17, 18 are reserved
161         public static final int BAND_19 = UtranBands.BAND_19;
162         public static final int BAND_20 = UtranBands.BAND_20;
163         public static final int BAND_21 = UtranBands.BAND_21;
164         public static final int BAND_22 = UtranBands.BAND_22;
165         // band 23, 24 are reserved
166         public static final int BAND_25 = UtranBands.BAND_25;
167         public static final int BAND_26 = UtranBands.BAND_26;
168 
169         // Frequency bands for TD-SCDMA. Defined in 3GPP TS 25.102, Table 5.2.
170 
171         /**
172          * Band A
173          * 1900 - 1920 MHz: Uplink and downlink transmission
174          * 2010 - 2025 MHz: Uplink and downlink transmission
175          */
176         public static final int BAND_A = UtranBands.BAND_A;
177 
178         /**
179          * Band B
180          * 1850 - 1910 MHz: Uplink and downlink transmission
181          * 1930 - 1990 MHz: Uplink and downlink transmission
182          */
183         public static final int BAND_B = UtranBands.BAND_B;
184 
185         /**
186          * Band C
187          * 1910 - 1930 MHz: Uplink and downlink transmission
188          */
189         public static final int BAND_C = UtranBands.BAND_C;
190 
191         /**
192          * Band D
193          * 2570 - 2620 MHz: Uplink and downlink transmission
194          */
195         public static final int BAND_D = UtranBands.BAND_D;
196 
197         /**
198          * Band E
199          * 2300—2400 MHz: Uplink and downlink transmission
200          */
201         public static final int BAND_E = UtranBands.BAND_E;
202 
203         /**
204          * Band F
205          * 1880 - 1920 MHz: Uplink and downlink transmission
206          */
207         public static final int BAND_F = UtranBands.BAND_F;
208 
209         /** @hide */
UtranBand()210         private UtranBand() {}
211     }
212 
213     /**
214      * Frequency bands for EUTRAN.
215      * 3GPP TS 36.101, Version 16.4.0, Table 5.5: Operating bands
216      * https://www.etsi.org/deliver/etsi_ts/136100_136199/136101/15.09.00_60/ts_136101v150900p.pdf
217      */
218     public static final class EutranBand {
219         public static final int BAND_1 = EutranBands.BAND_1;
220         public static final int BAND_2 = EutranBands.BAND_2;
221         public static final int BAND_3 = EutranBands.BAND_3;
222         public static final int BAND_4 = EutranBands.BAND_4;
223         public static final int BAND_5 = EutranBands.BAND_5;
224         public static final int BAND_6 = EutranBands.BAND_6;
225         public static final int BAND_7 = EutranBands.BAND_7;
226         public static final int BAND_8 = EutranBands.BAND_8;
227         public static final int BAND_9 = EutranBands.BAND_9;
228         public static final int BAND_10 = EutranBands.BAND_10;
229         public static final int BAND_11 = EutranBands.BAND_11;
230         public static final int BAND_12 = EutranBands.BAND_12;
231         public static final int BAND_13 = EutranBands.BAND_13;
232         public static final int BAND_14 = EutranBands.BAND_14;
233         public static final int BAND_17 = EutranBands.BAND_17;
234         public static final int BAND_18 = EutranBands.BAND_18;
235         public static final int BAND_19 = EutranBands.BAND_19;
236         public static final int BAND_20 = EutranBands.BAND_20;
237         public static final int BAND_21 = EutranBands.BAND_21;
238         public static final int BAND_22 = EutranBands.BAND_22;
239         public static final int BAND_23 = EutranBands.BAND_23;
240         public static final int BAND_24 = EutranBands.BAND_24;
241         public static final int BAND_25 = EutranBands.BAND_25;
242         public static final int BAND_26 = EutranBands.BAND_26;
243         public static final int BAND_27 = EutranBands.BAND_27;
244         public static final int BAND_28 = EutranBands.BAND_28;
245         public static final int BAND_30 = EutranBands.BAND_30;
246         public static final int BAND_31 = EutranBands.BAND_31;
247         public static final int BAND_33 = EutranBands.BAND_33;
248         public static final int BAND_34 = EutranBands.BAND_34;
249         public static final int BAND_35 = EutranBands.BAND_35;
250         public static final int BAND_36 = EutranBands.BAND_36;
251         public static final int BAND_37 = EutranBands.BAND_37;
252         public static final int BAND_38 = EutranBands.BAND_38;
253         public static final int BAND_39 = EutranBands.BAND_39;
254         public static final int BAND_40 = EutranBands.BAND_40;
255         public static final int BAND_41 = EutranBands.BAND_41;
256         public static final int BAND_42 = EutranBands.BAND_42;
257         public static final int BAND_43 = EutranBands.BAND_43;
258         public static final int BAND_44 = EutranBands.BAND_44;
259         public static final int BAND_45 = EutranBands.BAND_45;
260         public static final int BAND_46 = EutranBands.BAND_46;
261         public static final int BAND_47 = EutranBands.BAND_47;
262         public static final int BAND_48 = EutranBands.BAND_48;
263         public static final int BAND_49 = EutranBands.BAND_49;
264         public static final int BAND_50 = EutranBands.BAND_50;
265         public static final int BAND_51 = EutranBands.BAND_51;
266         public static final int BAND_52 = EutranBands.BAND_52;
267         public static final int BAND_53 = EutranBands.BAND_53;
268         public static final int BAND_65 = EutranBands.BAND_65;
269         public static final int BAND_66 = EutranBands.BAND_66;
270         public static final int BAND_68 = EutranBands.BAND_68;
271         public static final int BAND_70 = EutranBands.BAND_70;
272         public static final int BAND_71 = EutranBands.BAND_71;
273         public static final int BAND_72 = EutranBands.BAND_72;
274         public static final int BAND_73 = EutranBands.BAND_73;
275         public static final int BAND_74 = EutranBands.BAND_74;
276         public static final int BAND_85 = EutranBands.BAND_85;
277         public static final int BAND_87 = EutranBands.BAND_87;
278         public static final int BAND_88 = EutranBands.BAND_88;
279 
280         /** @hide */
EutranBand()281         private EutranBand() {};
282     }
283 
284     /**
285      * Frequency bands for CDMA2000.
286      * http://www.3gpp2.org/Public_html/Specs/C.S0057-E_v1.0_Bandclass_Specification.pdf
287      * @hide
288      *
289      * TODO(yinxu): Check with the nexus team about the definition of CDMA bands.
290      */
291     public static final class CdmaBands {
292         public static final int BAND_0 = 1;
293         public static final int BAND_1 = 2;
294         public static final int BAND_2 = 3;
295         public static final int BAND_3 = 4;
296         public static final int BAND_4 = 5;
297         public static final int BAND_5 = 6;
298         public static final int BAND_6 = 7;
299         public static final int BAND_7 = 8;
300         public static final int BAND_8 = 9;
301         public static final int BAND_9 = 10;
302         public static final int BAND_10 = 11;
303         public static final int BAND_11 = 12;
304         public static final int BAND_12 = 13;
305         public static final int BAND_13 = 14;
306         public static final int BAND_14 = 15;
307         public static final int BAND_15 = 16;
308         public static final int BAND_16 = 17;
309         public static final int BAND_17 = 18;
310         public static final int BAND_18 = 19;
311         public static final int BAND_19 = 20;
312         public static final int BAND_20 = 21;
313         public static final int BAND_21 = 22;
314 
315         /** @hide */
CdmaBands()316         private CdmaBands() {}
317     }
318 
319     /**
320      * Frequency bands for NGRAN
321      * https://www.etsi.org/deliver/etsi_ts/138100_138199/13810101/15.08.02_60/ts_13810101v150802p.pdf
322      * https://www.etsi.org/deliver/etsi_ts/138100_138199/13810102/15.08.00_60/ts_13810102v150800p.pdf
323      */
324     public static final class NgranBands {
325         /** 3GPP TS 38.101-1, Version 16.2.0, Table 5.2-1: FR1 bands */
326         public static final int BAND_1 = android.hardware.radio.V1_5.NgranBands.BAND_1;
327         public static final int BAND_2 = android.hardware.radio.V1_5.NgranBands.BAND_2;
328         public static final int BAND_3 = android.hardware.radio.V1_5.NgranBands.BAND_3;
329         public static final int BAND_5 = android.hardware.radio.V1_5.NgranBands.BAND_5;
330         public static final int BAND_7 = android.hardware.radio.V1_5.NgranBands.BAND_7;
331         public static final int BAND_8 = android.hardware.radio.V1_5.NgranBands.BAND_8;
332         public static final int BAND_12 = android.hardware.radio.V1_5.NgranBands.BAND_12;
333         public static final int BAND_14 = android.hardware.radio.V1_5.NgranBands.BAND_14;
334         public static final int BAND_18 = android.hardware.radio.V1_5.NgranBands.BAND_18;
335         public static final int BAND_20 = android.hardware.radio.V1_5.NgranBands.BAND_20;
336         public static final int BAND_25 = android.hardware.radio.V1_5.NgranBands.BAND_25;
337         public static final int BAND_28 = android.hardware.radio.V1_5.NgranBands.BAND_28;
338         public static final int BAND_29 = android.hardware.radio.V1_5.NgranBands.BAND_29;
339         public static final int BAND_30 = android.hardware.radio.V1_5.NgranBands.BAND_30;
340         public static final int BAND_34 = android.hardware.radio.V1_5.NgranBands.BAND_34;
341         public static final int BAND_38 = android.hardware.radio.V1_5.NgranBands.BAND_38;
342         public static final int BAND_39 = android.hardware.radio.V1_5.NgranBands.BAND_39;
343         public static final int BAND_40 = android.hardware.radio.V1_5.NgranBands.BAND_40;
344         public static final int BAND_41 = android.hardware.radio.V1_5.NgranBands.BAND_41;
345         public static final int BAND_48 = android.hardware.radio.V1_5.NgranBands.BAND_48;
346         public static final int BAND_50 = android.hardware.radio.V1_5.NgranBands.BAND_50;
347         public static final int BAND_51 = android.hardware.radio.V1_5.NgranBands.BAND_51;
348         public static final int BAND_65 = android.hardware.radio.V1_5.NgranBands.BAND_65;
349         public static final int BAND_66 = android.hardware.radio.V1_5.NgranBands.BAND_66;
350         public static final int BAND_70 = android.hardware.radio.V1_5.NgranBands.BAND_70;
351         public static final int BAND_71 = android.hardware.radio.V1_5.NgranBands.BAND_71;
352         public static final int BAND_74 = android.hardware.radio.V1_5.NgranBands.BAND_74;
353         public static final int BAND_75 = android.hardware.radio.V1_5.NgranBands.BAND_75;
354         public static final int BAND_76 = android.hardware.radio.V1_5.NgranBands.BAND_76;
355         public static final int BAND_77 = android.hardware.radio.V1_5.NgranBands.BAND_77;
356         public static final int BAND_78 = android.hardware.radio.V1_5.NgranBands.BAND_78;
357         public static final int BAND_79 = android.hardware.radio.V1_5.NgranBands.BAND_79;
358         public static final int BAND_80 = android.hardware.radio.V1_5.NgranBands.BAND_80;
359         public static final int BAND_81 = android.hardware.radio.V1_5.NgranBands.BAND_81;
360         public static final int BAND_82 = android.hardware.radio.V1_5.NgranBands.BAND_82;
361         public static final int BAND_83 = android.hardware.radio.V1_5.NgranBands.BAND_83;
362         public static final int BAND_84 = android.hardware.radio.V1_5.NgranBands.BAND_84;
363         public static final int BAND_86 = android.hardware.radio.V1_5.NgranBands.BAND_86;
364         public static final int BAND_89 = android.hardware.radio.V1_5.NgranBands.BAND_89;
365         public static final int BAND_90 = android.hardware.radio.V1_5.NgranBands.BAND_90;
366         public static final int BAND_91 = android.hardware.radio.V1_5.NgranBands.BAND_91;
367         public static final int BAND_92 = android.hardware.radio.V1_5.NgranBands.BAND_92;
368         public static final int BAND_93 = android.hardware.radio.V1_5.NgranBands.BAND_93;
369         public static final int BAND_94 = android.hardware.radio.V1_5.NgranBands.BAND_94;
370         public static final int BAND_95 = android.hardware.radio.V1_5.NgranBands.BAND_95;
371 
372         /** 3GPP TS 38.101-2, Version 16.2.0, Table 5.2-1: FR2 bands */
373         public static final int BAND_257 = android.hardware.radio.V1_5.NgranBands.BAND_257;
374         public static final int BAND_258 = android.hardware.radio.V1_5.NgranBands.BAND_258;
375         public static final int BAND_260 = android.hardware.radio.V1_5.NgranBands.BAND_260;
376         public static final int BAND_261 = android.hardware.radio.V1_5.NgranBands.BAND_261;
377 
378         /**
379          * NR Bands
380          *
381          * @hide */
382         @Retention(RetentionPolicy.SOURCE)
383         @IntDef(prefix = {"BAND_"},
384                 value = {BAND_1,
385                         BAND_2,
386                         BAND_3,
387                         BAND_5,
388                         BAND_7,
389                         BAND_8,
390                         BAND_12,
391                         BAND_14,
392                         BAND_18,
393                         BAND_20,
394                         BAND_25,
395                         BAND_28,
396                         BAND_29,
397                         BAND_30,
398                         BAND_34,
399                         BAND_38,
400                         BAND_39,
401                         BAND_40,
402                         BAND_41,
403                         BAND_48,
404                         BAND_50,
405                         BAND_51,
406                         BAND_65,
407                         BAND_66,
408                         BAND_70,
409                         BAND_71,
410                         BAND_74,
411                         BAND_75,
412                         BAND_76,
413                         BAND_77,
414                         BAND_78,
415                         BAND_79,
416                         BAND_80,
417                         BAND_81,
418                         BAND_82,
419                         BAND_83,
420                         BAND_84,
421                         BAND_86,
422                         BAND_89,
423                         BAND_90,
424                         BAND_91,
425                         BAND_92,
426                         BAND_93,
427                         BAND_94,
428                         BAND_95,
429                         BAND_257,
430                         BAND_258,
431                         BAND_260,
432                         BAND_261})
433         public @interface NgranBand {}
434 
435         /**
436          * Unknown NR frequency.
437          *
438          * @hide
439          */
440         @SystemApi
441         @TestApi
442         public static final int FREQUENCY_RANGE_GROUP_UNKNOWN = 0;
443 
444         /**
445          * NR frequency group 1 defined in 3GPP TS 38.101-1 table 5.2-1
446          *
447          * @hide
448          */
449         @SystemApi
450         @TestApi
451         public static final int FREQUENCY_RANGE_GROUP_1 = 1;
452 
453         /**
454          * NR frequency group 2 defined in 3GPP TS 38.101-2 table 5.2-1
455          *
456          * @hide
457          */
458         @SystemApi
459         @TestApi
460         public static final int FREQUENCY_RANGE_GROUP_2 = 2;
461 
462         /**
463          * Radio frequency range group
464          *
465          * @hide
466          */
467         @Retention(RetentionPolicy.SOURCE)
468         @IntDef(prefix = {"FREQUENCY_RANGE_GROUP_"},
469                 value = {
470                         FREQUENCY_RANGE_GROUP_UNKNOWN,
471                         FREQUENCY_RANGE_GROUP_1,
472                         FREQUENCY_RANGE_GROUP_2})
473         public @interface FrequencyRangeGroup {}
474 
475         /**
476          * Get frequency range group
477          *
478          * @param band NR band
479          * @return The frequency range group
480          *
481          * @hide
482          */
483         @SystemApi
484         @TestApi
getFrequencyRangeGroup(@granBand int band)485         public static @FrequencyRangeGroup int getFrequencyRangeGroup(@NgranBand int band) {
486             switch (band) {
487                 case BAND_1:
488                 case BAND_2:
489                 case BAND_3:
490                 case BAND_5:
491                 case BAND_7:
492                 case BAND_8:
493                 case BAND_12:
494                 case BAND_14:
495                 case BAND_18:
496                 case BAND_20:
497                 case BAND_25:
498                 case BAND_28:
499                 case BAND_29:
500                 case BAND_30:
501                 case BAND_34:
502                 case BAND_38:
503                 case BAND_39:
504                 case BAND_40:
505                 case BAND_41:
506                 case BAND_48:
507                 case BAND_50:
508                 case BAND_51:
509                 case BAND_65:
510                 case BAND_66:
511                 case BAND_70:
512                 case BAND_71:
513                 case BAND_74:
514                 case BAND_75:
515                 case BAND_76:
516                 case BAND_77:
517                 case BAND_78:
518                 case BAND_79:
519                 case BAND_80:
520                 case BAND_81:
521                 case BAND_82:
522                 case BAND_83:
523                 case BAND_84:
524                 case BAND_86:
525                 case BAND_89:
526                 case BAND_90:
527                 case BAND_91:
528                 case BAND_92:
529                 case BAND_93:
530                 case BAND_94:
531                 case BAND_95:
532                     return FREQUENCY_RANGE_GROUP_1;
533                 case BAND_257:
534                 case BAND_258:
535                 case BAND_260:
536                 case BAND_261:
537                     return FREQUENCY_RANGE_GROUP_2;
538                 default:
539                     return FREQUENCY_RANGE_GROUP_UNKNOWN;
540             }
541         };
542 
543         /** @hide */
NgranBands()544         private NgranBands() {}
545     }
546 
547     /** @hide */
AccessNetworkConstants()548     private AccessNetworkConstants() {};
549 }
550