1 /* 2 * Copyright (C) 2018 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.IntRange; 21 import android.annotation.NonNull; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 import android.telephony.Annotation.NetworkType; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 import java.util.Arrays; 29 import java.util.Objects; 30 31 public final class PhysicalChannelConfig implements Parcelable { 32 33 // TODO(b/72993578) consolidate these enums in a central location. 34 /** @hide */ 35 @Retention(RetentionPolicy.SOURCE) 36 @IntDef({CONNECTION_PRIMARY_SERVING, CONNECTION_SECONDARY_SERVING, CONNECTION_UNKNOWN}) 37 public @interface ConnectionStatus {} 38 39 /** 40 * UE has connection to cell for signalling and possibly data (3GPP 36.331, 25.331). 41 */ 42 public static final int CONNECTION_PRIMARY_SERVING = 1; 43 44 /** 45 * UE has connection to cell for data (3GPP 36.331, 25.331). 46 */ 47 public static final int CONNECTION_SECONDARY_SERVING = 2; 48 49 /** Connection status is unknown. */ 50 public static final int CONNECTION_UNKNOWN = -1; 51 52 /** Channel number is unknown. */ 53 public static final int CHANNEL_NUMBER_UNKNOWN = Integer.MAX_VALUE; 54 55 /** Physical Cell Id is unknown. */ 56 public static final int PHYSICAL_CELL_ID_UNKNOWN = -1; 57 58 /** Physical Cell Id's maximum value is 1007. */ 59 public static final int PHYSICAL_CELL_ID_MAXIMUM_VALUE = 1007; 60 61 /** Cell bandwidth is unknown. */ 62 public static final int CELL_BANDWIDTH_UNKNOWN = 0; 63 64 /** The frequency is unknown. */ 65 public static final int FREQUENCY_UNKNOWN = -1; 66 67 /** The band is unknown. */ 68 public static final int BAND_UNKNOWN = 0; 69 70 /** 71 * Connection status of the cell. 72 * 73 * <p>One of {@link #CONNECTION_PRIMARY_SERVING}, {@link #CONNECTION_SECONDARY_SERVING}. 74 */ 75 @ConnectionStatus 76 private int mCellConnectionStatus; 77 78 /** 79 * Downlink cell bandwidth, in kHz. 80 */ 81 private int mCellBandwidthDownlinkKhz; 82 83 /** 84 * Uplink cell bandwidth, in kHz. 85 */ 86 private int mCellBandwidthUplinkKhz; 87 88 /** 89 * The radio technology for this physical channel. 90 */ 91 @NetworkType 92 private int mNetworkType; 93 94 /** 95 * The rough frequency range for this physical channel. 96 */ 97 @ServiceState.FrequencyRange 98 private int mFrequencyRange; 99 100 /** 101 * The frequency of Downlink. 102 */ 103 private int mDownlinkFrequency; 104 105 /** 106 * The frequency of Uplink. 107 */ 108 private int mUplinkFrequency; 109 110 /** 111 * Downlink Absolute Radio Frequency Channel Number 112 */ 113 private int mDownlinkChannelNumber; 114 115 /** 116 * Uplink Absolute Radio Frequency Channel Number 117 */ 118 private int mUplinkChannelNumber; 119 120 /** 121 * A list of data calls mapped to this physical channel. An empty list means the physical 122 * channel has no data call mapped to it. 123 */ 124 private int[] mContextIds; 125 126 /** 127 * The physical cell identifier for this cell - PCI, PSC, {@link #PHYSICAL_CELL_ID_UNKNOWN} 128 * if unknown. 129 */ 130 private int mPhysicalCellId; 131 132 /** 133 * This is the band which is being used. 134 */ 135 private int mBand; 136 137 @Override describeContents()138 public int describeContents() { 139 return 0; 140 } 141 142 @Override writeToParcel(@onNull Parcel dest, int flags)143 public void writeToParcel(@NonNull Parcel dest, int flags) { 144 dest.writeInt(mCellConnectionStatus); 145 dest.writeInt(mCellBandwidthDownlinkKhz); 146 dest.writeInt(mCellBandwidthUplinkKhz); 147 dest.writeInt(mNetworkType); 148 dest.writeInt(mDownlinkChannelNumber); 149 dest.writeInt(mUplinkChannelNumber); 150 dest.writeInt(mFrequencyRange); 151 dest.writeIntArray(mContextIds); 152 dest.writeInt(mPhysicalCellId); 153 dest.writeInt(mBand); 154 } 155 156 /** 157 * @return Downlink cell bandwidth in kHz, {@link #CELL_BANDWIDTH_UNKNOWN} if unknown. 158 */ 159 @IntRange(from = 1) getCellBandwidthDownlinkKhz()160 public int getCellBandwidthDownlinkKhz() { 161 return mCellBandwidthDownlinkKhz; 162 } 163 164 /** 165 * @return Uplink cell bandwidth in kHz, {@link #CELL_BANDWIDTH_UNKNOWN} if unknown. 166 */ 167 @IntRange(from = 1) getCellBandwidthUplinkKhz()168 public int getCellBandwidthUplinkKhz() { 169 return mCellBandwidthUplinkKhz; 170 } 171 172 /** 173 * Get the list of data call ids mapped to this physical channel. This list is sorted into 174 * ascending numerical order. Each id in this list must match the id in 175 * {@link com.android.internal.telephony.dataconnection.DataConnection}. An empty list means the 176 * physical channel has no data call mapped to it. 177 * 178 * @return an integer list indicates the data call ids, 179 * @hide 180 */ getContextIds()181 public int[] getContextIds() { 182 return mContextIds; 183 } 184 185 /** 186 * @return the rough frequency range for this physical channel, 187 * {@link ServiceState#FREQUENCY_RANGE_UNKNOWN} if unknown. 188 * @see {@link ServiceState#FREQUENCY_RANGE_LOW} 189 * @see {@link ServiceState#FREQUENCY_RANGE_MID} 190 * @see {@link ServiceState#FREQUENCY_RANGE_HIGH} 191 * @see {@link ServiceState#FREQUENCY_RANGE_MMWAVE} 192 * @hide 193 */ 194 @ServiceState.FrequencyRange getFrequencyRange()195 public int getFrequencyRange() { 196 return mFrequencyRange; 197 } 198 199 /** 200 * @return Downlink Absolute Radio Frequency Channel Number, 201 * {@link #CHANNEL_NUMBER_UNKNOWN} if unknown. 202 */ 203 @IntRange(from = 0) getDownlinkChannelNumber()204 public int getDownlinkChannelNumber() { 205 return mDownlinkChannelNumber; 206 } 207 208 /** 209 * @return Uplink Absolute Radio Frequency Channel Number, 210 * {@link #CHANNEL_NUMBER_UNKNOWN} if unknown. 211 */ 212 @IntRange(from = 0) getUplinkChannelNumber()213 public int getUplinkChannelNumber() { 214 return mUplinkChannelNumber; 215 } 216 217 /** 218 * The valid bands are {@link AccessNetworkConstants.GeranBand}, 219 * {@link AccessNetworkConstants.UtranBand}, {@link AccessNetworkConstants.EutranBand} and 220 * {@link AccessNetworkConstants.NgranBands}. 221 * 222 * @return the frequency band, {@link #BAND_UNKNOWN} if unknown. */ 223 @IntRange(from = 1, to = 261) getBand()224 public int getBand() { 225 return mBand; 226 } 227 228 /** 229 * @return The downlink frequency in kHz, {@link #FREQUENCY_UNKNOWN} if unknown. 230 */ 231 @IntRange(from = 0) getDownlinkFrequencyKhz()232 public int getDownlinkFrequencyKhz() { 233 return mDownlinkFrequency; 234 } 235 236 /** 237 * @return The uplink frequency in kHz, {@link #FREQUENCY_UNKNOWN} if unknown. 238 */ 239 @IntRange(from = 0) getUplinkFrequencyKhz()240 public int getUplinkFrequencyKhz() { 241 return mUplinkFrequency; 242 } 243 244 /** 245 * In UTRAN, this value is primary scrambling code. The range is [0, 511]. 246 * Reference: 3GPP TS 25.213 section 5.2.2. 247 * 248 * In EUTRAN, this value is physical layer cell identity. The range is [0, 503]. 249 * Reference: 3GPP TS 36.211 section 6.11. 250 * 251 * In 5G RAN, this value is physical layer cell identity. The range is [0, 1007]. 252 * Reference: 3GPP TS 38.211 section 7.4.2.1. 253 * 254 * @return the physical cell identifier for this cell, {@link #PHYSICAL_CELL_ID_UNKNOWN} 255 * if {@link android.telephony.CellInfo#UNAVAILABLE}. 256 */ 257 @IntRange(from = 0, to = 1007) getPhysicalCellId()258 public int getPhysicalCellId() { 259 return mPhysicalCellId; 260 } 261 262 /** 263 * @return The network type for this physical channel, 264 * {@link TelephonyManager#NETWORK_TYPE_UNKNOWN} if unknown. 265 */ 266 @NetworkType getNetworkType()267 public int getNetworkType() { 268 return mNetworkType; 269 } 270 271 /** 272 * Gets the connection status of the cell. 273 * 274 * @see #CONNECTION_PRIMARY_SERVING 275 * @see #CONNECTION_SECONDARY_SERVING 276 * @see #CONNECTION_UNKNOWN 277 * 278 * @return Connection status of the cell, {@link #CONNECTION_UNKNOWN} if unknown. 279 */ 280 @ConnectionStatus getConnectionStatus()281 public int getConnectionStatus() { 282 return mCellConnectionStatus; 283 } 284 285 /** 286 * Return a copy of this PhysicalChannelConfig object but redact all the location info. 287 * @hide 288 */ createLocationInfoSanitizedCopy()289 public PhysicalChannelConfig createLocationInfoSanitizedCopy() { 290 return new Builder(this).setPhysicalCellId(PHYSICAL_CELL_ID_UNKNOWN).build(); 291 } 292 293 /** 294 * @return String representation of the connection status 295 * @hide 296 */ getConnectionStatusString()297 private String getConnectionStatusString() { 298 switch(mCellConnectionStatus) { 299 case CONNECTION_PRIMARY_SERVING: 300 return "PrimaryServing"; 301 case CONNECTION_SECONDARY_SERVING: 302 return "SecondaryServing"; 303 case CONNECTION_UNKNOWN: 304 return "Unknown"; 305 default: 306 return "Invalid(" + mCellConnectionStatus + ")"; 307 } 308 } 309 setDownlinkFrequency()310 private void setDownlinkFrequency() { 311 switch (mNetworkType) { 312 case TelephonyManager.NETWORK_TYPE_NR: 313 mDownlinkFrequency = AccessNetworkUtils.getFrequencyFromNrArfcn( 314 mDownlinkChannelNumber); 315 break; 316 case TelephonyManager.NETWORK_TYPE_LTE: 317 mDownlinkFrequency = AccessNetworkUtils.getFrequencyFromEarfcn( 318 mBand, mDownlinkChannelNumber, false); 319 break; 320 case TelephonyManager.NETWORK_TYPE_HSPAP: 321 case TelephonyManager.NETWORK_TYPE_TD_SCDMA: 322 case TelephonyManager.NETWORK_TYPE_UMTS: 323 case TelephonyManager.NETWORK_TYPE_HSDPA: 324 case TelephonyManager.NETWORK_TYPE_HSUPA: 325 case TelephonyManager.NETWORK_TYPE_HSPA: 326 mDownlinkFrequency = AccessNetworkUtils.getFrequencyFromUarfcn( 327 mBand, mDownlinkChannelNumber, false); 328 break; 329 case TelephonyManager.NETWORK_TYPE_GPRS: 330 case TelephonyManager.NETWORK_TYPE_EDGE: 331 case TelephonyManager.NETWORK_TYPE_GSM: 332 mDownlinkFrequency = AccessNetworkUtils.getFrequencyFromArfcn( 333 mBand, mDownlinkChannelNumber, false); 334 break; 335 } 336 } 337 setUplinkFrequency()338 private void setUplinkFrequency() { 339 switch (mNetworkType){ 340 case TelephonyManager.NETWORK_TYPE_NR: 341 mUplinkFrequency = AccessNetworkUtils.getFrequencyFromNrArfcn( 342 mUplinkChannelNumber); 343 break; 344 case TelephonyManager.NETWORK_TYPE_LTE: 345 mUplinkFrequency = AccessNetworkUtils.getFrequencyFromEarfcn( 346 mBand, mUplinkChannelNumber, true); 347 break; 348 case TelephonyManager.NETWORK_TYPE_HSPAP: 349 case TelephonyManager.NETWORK_TYPE_TD_SCDMA: 350 case TelephonyManager.NETWORK_TYPE_UMTS: 351 case TelephonyManager.NETWORK_TYPE_HSDPA: 352 case TelephonyManager.NETWORK_TYPE_HSUPA: 353 case TelephonyManager.NETWORK_TYPE_HSPA: 354 mUplinkFrequency = AccessNetworkUtils.getFrequencyFromUarfcn( 355 mBand, mUplinkChannelNumber, true); 356 break; 357 case TelephonyManager.NETWORK_TYPE_GPRS: 358 case TelephonyManager.NETWORK_TYPE_EDGE: 359 case TelephonyManager.NETWORK_TYPE_GSM: 360 mUplinkFrequency = AccessNetworkUtils.getFrequencyFromArfcn( 361 mBand, mUplinkChannelNumber, true); 362 break; 363 } 364 } 365 setFrequencyRange()366 private void setFrequencyRange() { 367 if (mFrequencyRange != ServiceState.FREQUENCY_RANGE_UNKNOWN) { 368 return; 369 } 370 371 switch (mNetworkType) { 372 case TelephonyManager.NETWORK_TYPE_NR: 373 mFrequencyRange = AccessNetworkUtils.getFrequencyRangeGroupFromNrBand(mBand); 374 break; 375 case TelephonyManager.NETWORK_TYPE_LTE: 376 mFrequencyRange = AccessNetworkUtils.getFrequencyRangeGroupFromEutranBand(mBand); 377 break; 378 case TelephonyManager.NETWORK_TYPE_HSPAP: 379 case TelephonyManager.NETWORK_TYPE_TD_SCDMA: 380 case TelephonyManager.NETWORK_TYPE_UMTS: 381 case TelephonyManager.NETWORK_TYPE_HSDPA: 382 case TelephonyManager.NETWORK_TYPE_HSUPA: 383 case TelephonyManager.NETWORK_TYPE_HSPA: 384 mFrequencyRange = AccessNetworkUtils.getFrequencyRangeGroupFromUtranBand(mBand); 385 break; 386 case TelephonyManager.NETWORK_TYPE_GPRS: 387 case TelephonyManager.NETWORK_TYPE_EDGE: 388 case TelephonyManager.NETWORK_TYPE_GSM: 389 mFrequencyRange = AccessNetworkUtils.getFrequencyRangeGroupFromGeranBand(mBand); 390 break; 391 default: 392 mFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN; 393 break; 394 } 395 396 if (mFrequencyRange == ServiceState.FREQUENCY_RANGE_UNKNOWN) { 397 mFrequencyRange = AccessNetworkUtils.getFrequencyRangeFromArfcn( 398 mDownlinkFrequency); 399 } 400 } 401 402 @Override equals(Object o)403 public boolean equals(Object o) { 404 if (this == o) { 405 return true; 406 } 407 408 if (!(o instanceof PhysicalChannelConfig)) { 409 return false; 410 } 411 412 PhysicalChannelConfig config = (PhysicalChannelConfig) o; 413 return mCellConnectionStatus == config.mCellConnectionStatus 414 && mCellBandwidthDownlinkKhz == config.mCellBandwidthDownlinkKhz 415 && mCellBandwidthUplinkKhz == config.mCellBandwidthUplinkKhz 416 && mNetworkType == config.mNetworkType 417 && mFrequencyRange == config.mFrequencyRange 418 && mDownlinkChannelNumber == config.mDownlinkChannelNumber 419 && mUplinkChannelNumber == config.mUplinkChannelNumber 420 && mPhysicalCellId == config.mPhysicalCellId 421 && Arrays.equals(mContextIds, config.mContextIds) 422 && mBand == config.mBand 423 && mDownlinkFrequency == config.mDownlinkFrequency 424 && mUplinkFrequency == config.mUplinkFrequency; 425 } 426 427 @Override hashCode()428 public int hashCode() { 429 return Objects.hash( 430 mCellConnectionStatus, mCellBandwidthDownlinkKhz, mCellBandwidthUplinkKhz, 431 mNetworkType, mFrequencyRange, mDownlinkChannelNumber, mUplinkChannelNumber, 432 mContextIds, mPhysicalCellId, mBand, mDownlinkFrequency, mUplinkFrequency); 433 } 434 435 public static final 436 @android.annotation.NonNull Parcelable.Creator<PhysicalChannelConfig> CREATOR = 437 new Parcelable.Creator<PhysicalChannelConfig>() { 438 public PhysicalChannelConfig createFromParcel(Parcel in) { 439 return new PhysicalChannelConfig(in); 440 } 441 442 public PhysicalChannelConfig[] newArray(int size) { 443 return new PhysicalChannelConfig[size]; 444 } 445 }; 446 447 @Override toString()448 public String toString() { 449 return new StringBuilder() 450 .append("{mConnectionStatus=") 451 .append(getConnectionStatusString()) 452 .append(",mCellBandwidthDownlinkKhz=") 453 .append(mCellBandwidthDownlinkKhz) 454 .append(",mCellBandwidthUplinkKhz=") 455 .append(mCellBandwidthUplinkKhz) 456 .append(",mNetworkType=") 457 .append(TelephonyManager.getNetworkTypeName(mNetworkType)) 458 .append(",mFrequencyRange=") 459 .append(ServiceState.frequencyRangeToString(mFrequencyRange)) 460 .append(",mDownlinkChannelNumber=") 461 .append(mDownlinkChannelNumber) 462 .append(",mUplinkChannelNumber=") 463 .append(mUplinkChannelNumber) 464 .append(",mContextIds=") 465 .append(Arrays.toString(mContextIds)) 466 .append(",mPhysicalCellId=") 467 .append(mPhysicalCellId) 468 .append(",mBand=") 469 .append(mBand) 470 .append(",mDownlinkFrequency=") 471 .append(mDownlinkFrequency) 472 .append(",mUplinkFrequency=") 473 .append(mUplinkFrequency) 474 .append("}") 475 .toString(); 476 } 477 PhysicalChannelConfig(Parcel in)478 private PhysicalChannelConfig(Parcel in) { 479 mCellConnectionStatus = in.readInt(); 480 mCellBandwidthDownlinkKhz = in.readInt(); 481 mCellBandwidthUplinkKhz = in.readInt(); 482 mNetworkType = in.readInt(); 483 mDownlinkChannelNumber = in.readInt(); 484 mUplinkChannelNumber = in.readInt(); 485 mFrequencyRange = in.readInt(); 486 mContextIds = in.createIntArray(); 487 mPhysicalCellId = in.readInt(); 488 mBand = in.readInt(); 489 if (mBand > BAND_UNKNOWN) { 490 setDownlinkFrequency(); 491 setUplinkFrequency(); 492 setFrequencyRange(); 493 } 494 } 495 PhysicalChannelConfig(Builder builder)496 private PhysicalChannelConfig(Builder builder) { 497 mCellConnectionStatus = builder.mCellConnectionStatus; 498 mCellBandwidthDownlinkKhz = builder.mCellBandwidthDownlinkKhz; 499 mCellBandwidthUplinkKhz = builder.mCellBandwidthUplinkKhz; 500 mNetworkType = builder.mNetworkType; 501 mDownlinkChannelNumber = builder.mDownlinkChannelNumber; 502 mUplinkChannelNumber = builder.mUplinkChannelNumber; 503 mFrequencyRange = builder.mFrequencyRange; 504 mContextIds = builder.mContextIds; 505 mPhysicalCellId = builder.mPhysicalCellId; 506 mBand = builder.mBand; 507 if (mBand > BAND_UNKNOWN) { 508 setDownlinkFrequency(); 509 setUplinkFrequency(); 510 setFrequencyRange(); 511 } 512 } 513 514 /** 515 * The builder of {@code PhysicalChannelConfig}. 516 * @hide 517 */ 518 public static final class Builder { 519 private int mNetworkType; 520 private int mFrequencyRange; 521 private int mDownlinkChannelNumber; 522 private int mUplinkChannelNumber; 523 private int mCellBandwidthDownlinkKhz; 524 private int mCellBandwidthUplinkKhz; 525 private int mCellConnectionStatus; 526 private int[] mContextIds; 527 private int mPhysicalCellId; 528 private int mBand; 529 Builder()530 public Builder() { 531 mNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; 532 mFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN; 533 mDownlinkChannelNumber = CHANNEL_NUMBER_UNKNOWN; 534 mUplinkChannelNumber = CHANNEL_NUMBER_UNKNOWN; 535 mCellBandwidthDownlinkKhz = CELL_BANDWIDTH_UNKNOWN; 536 mCellBandwidthUplinkKhz = CELL_BANDWIDTH_UNKNOWN; 537 mCellConnectionStatus = CONNECTION_UNKNOWN; 538 mContextIds = new int[0]; 539 mPhysicalCellId = PHYSICAL_CELL_ID_UNKNOWN; 540 mBand = BAND_UNKNOWN; 541 } 542 543 /** 544 * Builder object constructed from existing PhysicalChannelConfig object. 545 * @hide 546 */ Builder(PhysicalChannelConfig config)547 public Builder(PhysicalChannelConfig config) { 548 mNetworkType = config.getNetworkType(); 549 mFrequencyRange = config.getFrequencyRange(); 550 mDownlinkChannelNumber = config.getDownlinkChannelNumber(); 551 mUplinkChannelNumber = config.getUplinkChannelNumber(); 552 mCellBandwidthDownlinkKhz = config.getCellBandwidthDownlinkKhz(); 553 mCellBandwidthUplinkKhz = config.getCellBandwidthUplinkKhz(); 554 mCellConnectionStatus = config.getConnectionStatus(); 555 mContextIds = Arrays.copyOf(config.getContextIds(), config.getContextIds().length); 556 mPhysicalCellId = config.getPhysicalCellId(); 557 mBand = config.getBand(); 558 } 559 build()560 public PhysicalChannelConfig build() { 561 return new PhysicalChannelConfig(this); 562 } 563 setNetworkType(@etworkType int networkType)564 public @NonNull Builder setNetworkType(@NetworkType int networkType) { 565 if (!TelephonyManager.isNetworkTypeValid(networkType)) { 566 throw new IllegalArgumentException("Network type: " + networkType + " is invalid."); 567 } 568 mNetworkType = networkType; 569 return this; 570 } 571 setFrequencyRange(int frequencyRange)572 public @NonNull Builder setFrequencyRange(int frequencyRange) { 573 if (!ServiceState.isFrequencyRangeValid(frequencyRange) 574 && frequencyRange != ServiceState.FREQUENCY_RANGE_UNKNOWN) { 575 throw new IllegalArgumentException("Frequency range: " + frequencyRange + 576 " is invalid."); 577 } 578 mFrequencyRange = frequencyRange; 579 return this; 580 } 581 setDownlinkChannelNumber(int downlinkChannelNumber)582 public @NonNull Builder setDownlinkChannelNumber(int downlinkChannelNumber) { 583 mDownlinkChannelNumber = downlinkChannelNumber; 584 return this; 585 } 586 setUplinkChannelNumber(int uplinkChannelNumber)587 public @NonNull Builder setUplinkChannelNumber(int uplinkChannelNumber) { 588 mUplinkChannelNumber = uplinkChannelNumber; 589 return this; 590 } 591 setCellBandwidthDownlinkKhz(int cellBandwidthDownlinkKhz)592 public @NonNull Builder setCellBandwidthDownlinkKhz(int cellBandwidthDownlinkKhz) { 593 if (cellBandwidthDownlinkKhz < CELL_BANDWIDTH_UNKNOWN) { 594 throw new IllegalArgumentException("Cell downlink bandwidth(kHz): " + 595 cellBandwidthDownlinkKhz + " is invalid."); 596 } 597 mCellBandwidthDownlinkKhz = cellBandwidthDownlinkKhz; 598 return this; 599 } 600 setCellBandwidthUplinkKhz(int cellBandwidthUplinkKhz)601 public @NonNull Builder setCellBandwidthUplinkKhz(int cellBandwidthUplinkKhz) { 602 if (cellBandwidthUplinkKhz < CELL_BANDWIDTH_UNKNOWN) { 603 throw new IllegalArgumentException("Cell uplink bandwidth(kHz): "+ 604 cellBandwidthUplinkKhz +" is invalid."); 605 } 606 mCellBandwidthUplinkKhz = cellBandwidthUplinkKhz; 607 return this; 608 } 609 setCellConnectionStatus(int connectionStatus)610 public @NonNull Builder setCellConnectionStatus(int connectionStatus) { 611 mCellConnectionStatus = connectionStatus; 612 return this; 613 } 614 setContextIds(int[] contextIds)615 public @NonNull Builder setContextIds(int[] contextIds) { 616 if (contextIds != null) Arrays.sort(contextIds); 617 mContextIds = contextIds; 618 return this; 619 } 620 setPhysicalCellId(int physicalCellId)621 public @NonNull Builder setPhysicalCellId(int physicalCellId) { 622 if (physicalCellId > PHYSICAL_CELL_ID_MAXIMUM_VALUE) { 623 throw new IllegalArgumentException("Physical cell Id: " + physicalCellId + 624 " is over limit."); 625 } 626 mPhysicalCellId = physicalCellId; 627 return this; 628 } 629 setBand(int band)630 public @NonNull Builder setBand(int band) { 631 if (band <= BAND_UNKNOWN) { 632 throw new IllegalArgumentException("Band: " + band + 633 " is invalid."); 634 } 635 mBand = band; 636 return this; 637 } 638 } 639 } 640