1 package android.telephony; 2 3 import static android.telephony.ServiceState.DUPLEX_MODE_FDD; 4 import static android.telephony.ServiceState.DUPLEX_MODE_TDD; 5 import static android.telephony.ServiceState.DUPLEX_MODE_UNKNOWN; 6 7 import android.telephony.AccessNetworkConstants.EutranBand; 8 import android.telephony.ServiceState.DuplexMode; 9 10 11 /** 12 * Utilities to map between radio constants. 13 * 14 * @hide 15 */ 16 public class AccessNetworkUtils { 17 18 // do not instantiate AccessNetworkUtils()19 private AccessNetworkUtils() {} 20 21 public static final int INVALID_BAND = -1; 22 23 /** 24 * Gets the duplex mode for the given EUTRAN operating band. 25 * 26 * <p>See 3GPP 36.101 sec 5.5-1 for calculation 27 * 28 * @param band The EUTRAN band number 29 * @return The duplex mode of the given EUTRAN band 30 */ 31 @DuplexMode getDuplexModeForEutranBand(int band)32 public static int getDuplexModeForEutranBand(int band) { 33 if (band == INVALID_BAND) { 34 return DUPLEX_MODE_UNKNOWN; 35 } 36 37 if (band >= EutranBand.BAND_68) { 38 return DUPLEX_MODE_UNKNOWN; 39 } else if (band >= EutranBand.BAND_65) { 40 return DUPLEX_MODE_FDD; 41 } else if (band >= EutranBand.BAND_47) { 42 return DUPLEX_MODE_UNKNOWN; 43 } else if (band >= EutranBand.BAND_33) { 44 return DUPLEX_MODE_TDD; 45 } else if (band >= EutranBand.BAND_1) { 46 return DUPLEX_MODE_FDD; 47 } 48 49 return DUPLEX_MODE_UNKNOWN; 50 } 51 52 /** 53 * Gets the EUTRAN Operating band for a given downlink EARFCN. 54 * 55 * <p>See 3GPP 36.101 sec 5.7.3-1 for calculation. 56 * 57 * @param earfcn The downlink EARFCN 58 * @return Operating band number, or {@link #INVALID_BAND} if no corresponding band exists 59 */ getOperatingBandForEarfcn(int earfcn)60 public static int getOperatingBandForEarfcn(int earfcn) { 61 if (earfcn > 67535) { 62 return INVALID_BAND; 63 } else if (earfcn >= 67366) { 64 return INVALID_BAND; // band 67 only for CarrierAgg 65 } else if (earfcn >= 66436) { 66 return EutranBand.BAND_66; 67 } else if (earfcn >= 65536) { 68 return EutranBand.BAND_65; 69 } else if (earfcn > 54339) { 70 return INVALID_BAND; 71 } else if (earfcn >= 46790 /* inferred from the end range of BAND_45 */) { 72 return EutranBand.BAND_46; 73 } else if (earfcn >= 46590) { 74 return EutranBand.BAND_45; 75 } else if (earfcn >= 45590) { 76 return EutranBand.BAND_44; 77 } else if (earfcn >= 43590) { 78 return EutranBand.BAND_43; 79 } else if (earfcn >= 41590) { 80 return EutranBand.BAND_42; 81 } else if (earfcn >= 39650) { 82 return EutranBand.BAND_41; 83 } else if (earfcn >= 38650) { 84 return EutranBand.BAND_40; 85 } else if (earfcn >= 38250) { 86 return EutranBand.BAND_39; 87 } else if (earfcn >= 37750) { 88 return EutranBand.BAND_38; 89 } else if (earfcn >= 37550) { 90 return EutranBand.BAND_37; 91 } else if (earfcn >= 36950) { 92 return EutranBand.BAND_36; 93 } else if (earfcn >= 36350) { 94 return EutranBand.BAND_35; 95 } else if (earfcn >= 36200) { 96 return EutranBand.BAND_34; 97 } else if (earfcn >= 36000) { 98 return EutranBand.BAND_33; 99 } else if (earfcn > 10359) { 100 return INVALID_BAND; 101 } else if (earfcn >= 9920) { 102 return INVALID_BAND; // band 32 only for CarrierAgg 103 } else if (earfcn >= 9870) { 104 return EutranBand.BAND_31; 105 } else if (earfcn >= 9770) { 106 return EutranBand.BAND_30; 107 } else if (earfcn >= 9660) { 108 return INVALID_BAND; // band 29 only for CarrierAgg 109 } else if (earfcn >= 9210) { 110 return EutranBand.BAND_28; 111 } else if (earfcn >= 9040) { 112 return EutranBand.BAND_27; 113 } else if (earfcn >= 8690) { 114 return EutranBand.BAND_26; 115 } else if (earfcn >= 8040) { 116 return EutranBand.BAND_25; 117 } else if (earfcn >= 7700) { 118 return EutranBand.BAND_24; 119 } else if (earfcn >= 7500) { 120 return EutranBand.BAND_23; 121 } else if (earfcn >= 6600) { 122 return EutranBand.BAND_22; 123 } else if (earfcn >= 6450) { 124 return EutranBand.BAND_21; 125 } else if (earfcn >= 6150) { 126 return EutranBand.BAND_20; 127 } else if (earfcn >= 6000) { 128 return EutranBand.BAND_19; 129 } else if (earfcn >= 5850) { 130 return EutranBand.BAND_18; 131 } else if (earfcn >= 5730) { 132 return EutranBand.BAND_17; 133 } else if (earfcn > 5379) { 134 return INVALID_BAND; 135 } else if (earfcn >= 5280) { 136 return EutranBand.BAND_14; 137 } else if (earfcn >= 5180) { 138 return EutranBand.BAND_13; 139 } else if (earfcn >= 5010) { 140 return EutranBand.BAND_12; 141 } else if (earfcn >= 4750) { 142 return EutranBand.BAND_11; 143 } else if (earfcn >= 4150) { 144 return EutranBand.BAND_10; 145 } else if (earfcn >= 3800) { 146 return EutranBand.BAND_9; 147 } else if (earfcn >= 3450) { 148 return EutranBand.BAND_8; 149 } else if (earfcn >= 2750) { 150 return EutranBand.BAND_7; 151 } else if (earfcn >= 2650) { 152 return EutranBand.BAND_6; 153 } else if (earfcn >= 2400) { 154 return EutranBand.BAND_5; 155 } else if (earfcn >= 1950) { 156 return EutranBand.BAND_4; 157 } else if (earfcn >= 1200) { 158 return EutranBand.BAND_3; 159 } else if (earfcn >= 600) { 160 return EutranBand.BAND_2; 161 } else if (earfcn >= 0) { 162 return EutranBand.BAND_1; 163 } 164 165 return INVALID_BAND; 166 } 167 } 168