1 /* 2 * Copyright (C) 2019 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.NonNull; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.util.Arrays; 27 import java.util.Objects; 28 29 /** 30 * Defines the threshold value of the signal strength. 31 */ 32 public final class SignalThresholdInfo implements Parcelable { 33 34 /** 35 * Unknown signal measurement type. 36 */ 37 public static final int SIGNAL_MEASUREMENT_TYPE_UNKNOWN = 0; 38 39 /** 40 * Received Signal Strength Indication. 41 * Range: -113 dBm and -51 dBm 42 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#GERAN}, 43 * {@link AccessNetworkConstants.AccessNetworkType#CDMA2000} 44 * Reference: 3GPP TS 27.007 section 8.5. 45 */ 46 public static final int SIGNAL_MEASUREMENT_TYPE_RSSI = 1; 47 48 /** 49 * Received Signal Code Power. 50 * Range: -120 dBm to -25 dBm; 51 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#UTRAN} 52 * Reference: 3GPP TS 25.123, section 9.1.1.1 53 */ 54 public static final int SIGNAL_MEASUREMENT_TYPE_RSCP = 2; 55 56 /** 57 * Reference Signal Received Power. 58 * Range: -140 dBm to -44 dBm; 59 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN} 60 * Reference: 3GPP TS 36.133 9.1.4 61 */ 62 public static final int SIGNAL_MEASUREMENT_TYPE_RSRP = 3; 63 64 /** 65 * Reference Signal Received Quality 66 * Range: -34 dB to 3 dB; 67 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN} 68 * Reference: 3GPP TS 36.133 9.1.7 69 */ 70 public static final int SIGNAL_MEASUREMENT_TYPE_RSRQ = 4; 71 72 /** 73 * Reference Signal Signal to Noise Ratio 74 * Range: -20 dB to 30 dB; 75 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN} 76 */ 77 public static final int SIGNAL_MEASUREMENT_TYPE_RSSNR = 5; 78 79 /** 80 * 5G SS reference signal received power. 81 * Range: -140 dBm to -44 dBm. 82 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN} 83 * Reference: 3GPP TS 38.215. 84 */ 85 public static final int SIGNAL_MEASUREMENT_TYPE_SSRSRP = 6; 86 87 /** 88 * 5G SS reference signal received quality. 89 * Range: -43 dB to 20 dB. 90 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN} 91 * Reference: 3GPP TS 38.133 section 10.1.11.1. 92 */ 93 public static final int SIGNAL_MEASUREMENT_TYPE_SSRSRQ = 7; 94 95 /** 96 * 5G SS signal-to-noise and interference ratio. 97 * Range: -23 dB to 40 dB 98 * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN} 99 * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. 100 */ 101 public static final int SIGNAL_MEASUREMENT_TYPE_SSSINR = 8; 102 103 /** @hide */ 104 @IntDef(prefix = {"SIGNAL_MEASUREMENT_TYPE_"}, value = { 105 SIGNAL_MEASUREMENT_TYPE_UNKNOWN, 106 SIGNAL_MEASUREMENT_TYPE_RSSI, 107 SIGNAL_MEASUREMENT_TYPE_RSCP, 108 SIGNAL_MEASUREMENT_TYPE_RSRP, 109 SIGNAL_MEASUREMENT_TYPE_RSRQ, 110 SIGNAL_MEASUREMENT_TYPE_RSSNR, 111 SIGNAL_MEASUREMENT_TYPE_SSRSRP, 112 SIGNAL_MEASUREMENT_TYPE_SSRSRQ, 113 SIGNAL_MEASUREMENT_TYPE_SSSINR 114 }) 115 @Retention(RetentionPolicy.SOURCE) 116 public @interface SignalMeasurementType { 117 } 118 119 @SignalMeasurementType 120 private final int mSignalMeasurementType; 121 122 /** 123 * A hysteresis time in milliseconds to prevent flapping. 124 * A value of 0 disables hysteresis 125 */ 126 private final int mHysteresisMs; 127 128 /** 129 * An interval in dB defining the required magnitude change between reports. 130 * hysteresisDb must be smaller than the smallest threshold delta. 131 * An interval value of 0 disables hysteresis. 132 */ 133 private final int mHysteresisDb; 134 135 /** 136 * List of threshold values. 137 * Range and unit must reference specific SignalMeasurementType 138 * The threshold values for which to apply criteria. 139 * A vector size of 0 disables the use of thresholds for reporting. 140 */ 141 private final int[] mThresholds; 142 143 /** 144 * {@code true} means modem must trigger the report based on the criteria; 145 * {@code false} means modem must not trigger the report based on the criteria. 146 */ 147 private final boolean mIsEnabled; 148 149 /** 150 * The radio access network type associated with the signal thresholds. 151 */ 152 @AccessNetworkConstants.RadioAccessNetworkType 153 private final int mRan; 154 155 /** 156 * Indicates the hysteresisMs is disabled. 157 * 158 * @hide 159 */ 160 public static final int HYSTERESIS_MS_DISABLED = 0; 161 162 /** 163 * Indicates the hysteresisDb is disabled. 164 * 165 * @hide 166 */ 167 public static final int HYSTERESIS_DB_DISABLED = 0; 168 169 170 /** 171 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSI}. 172 * 173 * @hide 174 */ 175 public static final int SIGNAL_RSSI_MIN_VALUE = -113; 176 177 /** 178 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSI}. 179 * 180 * @hide 181 */ 182 public static final int SIGNAL_RSSI_MAX_VALUE = -51; 183 184 /** 185 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSCP}. 186 * 187 * @hide 188 */ 189 public static final int SIGNAL_RSCP_MIN_VALUE = -120; 190 191 /** 192 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSCP}. 193 * 194 * @hide 195 */ 196 public static final int SIGNAL_RSCP_MAX_VALUE = -25; 197 198 /** 199 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRP}. 200 * 201 * @hide 202 */ 203 public static final int SIGNAL_RSRP_MIN_VALUE = -140; 204 205 /** 206 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRP}. 207 * 208 * @hide 209 */ 210 public static final int SIGNAL_RSRP_MAX_VALUE = -44; 211 212 /** 213 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRQ}. 214 * 215 * @hide 216 */ 217 public static final int SIGNAL_RSRQ_MIN_VALUE = -34; 218 219 /** 220 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRQ}. 221 * 222 * @hide 223 */ 224 public static final int SIGNAL_RSRQ_MAX_VALUE = 3; 225 226 /** 227 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSNR}. 228 * 229 * @hide 230 */ 231 public static final int SIGNAL_RSSNR_MIN_VALUE = -20; 232 233 /** 234 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSNR}. 235 * 236 * @hide 237 */ 238 public static final int SIGNAL_RSSNR_MAX_VALUE = 30; 239 240 /** 241 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRP}. 242 * 243 * @hide 244 */ 245 public static final int SIGNAL_SSRSRP_MIN_VALUE = -140; 246 247 /** 248 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRP}. 249 * 250 * @hide 251 */ 252 public static final int SIGNAL_SSRSRP_MAX_VALUE = -44; 253 254 /** 255 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRQ}. 256 * 257 * @hide 258 */ 259 public static final int SIGNAL_SSRSRQ_MIN_VALUE = -43; 260 261 /** 262 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRQ}. 263 * 264 * @hide 265 */ 266 public static final int SIGNAL_SSRSRQ_MAX_VALUE = 20; 267 268 /** 269 * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSSINR}. 270 * 271 * @hide 272 */ 273 public static final int SIGNAL_SSSINR_MIN_VALUE = -23; 274 275 /** 276 * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSSINR}. 277 * 278 * @hide 279 */ 280 public static final int SIGNAL_SSSINR_MAX_VALUE = 40; 281 282 /** 283 * The minimum number of thresholds allowed in each SignalThresholdInfo. 284 * 285 * @hide 286 */ 287 public static final int MINIMUM_NUMBER_OF_THRESHOLDS_ALLOWED = 1; 288 289 /** 290 * The maximum number of thresholds allowed in each SignalThresholdInfo. 291 * 292 * @hide 293 */ 294 public static final int MAXIMUM_NUMBER_OF_THRESHOLDS_ALLOWED = 4; 295 296 /** 297 * Constructor 298 * 299 * @param ran Radio Access Network type 300 * @param signalMeasurementType Signal Measurement Type 301 * @param hysteresisMs hysteresisMs 302 * @param hysteresisDb hysteresisDb 303 * @param thresholds threshold value 304 * @param isEnabled isEnabled 305 */ SignalThresholdInfo(@ccessNetworkConstants.RadioAccessNetworkType int ran, @SignalMeasurementType int signalMeasurementType, int hysteresisMs, int hysteresisDb, @NonNull int[] thresholds, boolean isEnabled)306 private SignalThresholdInfo(@AccessNetworkConstants.RadioAccessNetworkType int ran, 307 @SignalMeasurementType int signalMeasurementType, int hysteresisMs, int hysteresisDb, 308 @NonNull int[] thresholds, boolean isEnabled) { 309 Objects.requireNonNull(thresholds, "thresholds must not be null"); 310 validateRanWithMeasurementType(ran, signalMeasurementType); 311 validateThresholdRange(signalMeasurementType, thresholds); 312 313 mRan = ran; 314 mSignalMeasurementType = signalMeasurementType; 315 mHysteresisMs = hysteresisMs < 0 ? HYSTERESIS_MS_DISABLED : hysteresisMs; 316 mHysteresisDb = hysteresisDb < 0 ? HYSTERESIS_DB_DISABLED : hysteresisDb; 317 mThresholds = thresholds; 318 mIsEnabled = isEnabled; 319 } 320 321 /** 322 * Builder class to create {@link SignalThresholdInfo} objects. 323 */ 324 public static final class Builder { 325 private int mRan = AccessNetworkConstants.AccessNetworkType.UNKNOWN; 326 private int mSignalMeasurementType = SIGNAL_MEASUREMENT_TYPE_UNKNOWN; 327 private int mHysteresisMs = HYSTERESIS_MS_DISABLED; 328 private int mHysteresisDb = HYSTERESIS_DB_DISABLED; 329 private int[] mThresholds = null; 330 private boolean mIsEnabled = false; 331 332 /** 333 * Set the radio access network type for the builder instance. 334 * 335 * @param ran The radio access network type 336 * @return the builder to facilitate the chaining 337 */ 338 public @NonNull Builder setRadioAccessNetworkType( 339 @AccessNetworkConstants.RadioAccessNetworkType int ran) { 340 mRan = ran; 341 return this; 342 } 343 344 /** 345 * Set the signal measurement type for the builder instance. 346 * 347 * @param signalMeasurementType The signal measurement type 348 * @return the builder to facilitate the chaining 349 */ 350 public @NonNull Builder setSignalMeasurementType( 351 @SignalMeasurementType int signalMeasurementType) { 352 mSignalMeasurementType = signalMeasurementType; 353 return this; 354 } 355 356 /** 357 * Set the hysteresis time in milliseconds to prevent flapping. A value of 0 disables 358 * hysteresis. 359 * 360 * @param hysteresisMs the hysteresis time in milliseconds 361 * @return the builder to facilitate the chaining 362 * @hide 363 */ 364 public @NonNull Builder setHysteresisMs(int hysteresisMs) { 365 mHysteresisMs = hysteresisMs; 366 return this; 367 } 368 369 /** 370 * Set the interval in dB defining the required magnitude change between reports. A value of 371 * zero disabled dB-based hysteresis restrictions. 372 * 373 * @param hysteresisDb the interval in dB 374 * @return the builder to facilitate the chaining 375 * @hide 376 */ 377 public @NonNull Builder setHysteresisDb(int hysteresisDb) { 378 mHysteresisDb = hysteresisDb; 379 return this; 380 } 381 382 /** 383 * Set the signal strength thresholds of the corresponding signal measurement type. 384 * 385 * The range and unit must reference specific SignalMeasurementType. The length of the 386 * thresholds should between the numbers return from 387 * {@link #getMinimumNumberOfThresholdsAllowed()} and 388 * {@link #getMaximumNumberOfThresholdsAllowed()}. An IllegalArgumentException will throw 389 * otherwise. 390 * 391 * @param thresholds array of integer as the signal threshold values 392 * @return the builder to facilitate the chaining 393 * 394 * @see #SIGNAL_MEASUREMENT_TYPE_RSSI 395 * @see #SIGNAL_MEASUREMENT_TYPE_RSCP 396 * @see #SIGNAL_MEASUREMENT_TYPE_RSRP 397 * @see #SIGNAL_MEASUREMENT_TYPE_RSRQ 398 * @see #SIGNAL_MEASUREMENT_TYPE_RSSNR 399 * @see #SIGNAL_MEASUREMENT_TYPE_SSRSRP 400 * @see #SIGNAL_MEASUREMENT_TYPE_SSRSRQ 401 * @see #SIGNAL_MEASUREMENT_TYPE_SSSINR 402 * @see #getThresholds() for more details on signal strength thresholds 403 */ 404 public @NonNull Builder setThresholds(@NonNull int[] thresholds) { 405 return setThresholds(thresholds, false /*isSystem*/); 406 } 407 408 /** 409 * Set the signal strength thresholds for the corresponding signal measurement type. 410 * 411 * @param thresholds array of integer as the signal threshold values 412 * @param isSystem true is the caller is system which does not have restrictions on 413 * the length of thresholds array. 414 * @return the builder to facilitate the chaining 415 * 416 * @hide 417 */ 418 public @NonNull Builder setThresholds(@NonNull int[] thresholds, boolean isSystem) { 419 Objects.requireNonNull(thresholds, "thresholds must not be null"); 420 if (!isSystem && (thresholds.length < MINIMUM_NUMBER_OF_THRESHOLDS_ALLOWED 421 || thresholds.length > MAXIMUM_NUMBER_OF_THRESHOLDS_ALLOWED)) { 422 throw new IllegalArgumentException( 423 "thresholds length must between " + MINIMUM_NUMBER_OF_THRESHOLDS_ALLOWED 424 + " and " + MAXIMUM_NUMBER_OF_THRESHOLDS_ALLOWED); 425 } 426 mThresholds = thresholds.clone(); 427 Arrays.sort(mThresholds); 428 return this; 429 } 430 431 432 /** 433 * Set if the modem should trigger the report based on the criteria. 434 * 435 * @param isEnabled true if the modem should trigger the report based on the criteria 436 * @return the builder to facilitate the chaining 437 * @hide 438 */ 439 public @NonNull Builder setIsEnabled(boolean isEnabled) { 440 mIsEnabled = isEnabled; 441 return this; 442 } 443 444 /** 445 * Build {@link SignalThresholdInfo} object. 446 * 447 * @return the SignalThresholdInfo object build out 448 * 449 * @throws IllegalArgumentException if the signal measurement type is invalid, any value in 450 * the thresholds is out of range, or the RAN is not allowed to set with the signal 451 * measurement type 452 */ 453 public @NonNull SignalThresholdInfo build() { 454 return new SignalThresholdInfo(mRan, mSignalMeasurementType, mHysteresisMs, 455 mHysteresisDb, mThresholds, mIsEnabled); 456 } 457 } 458 459 /** 460 * Get the radio access network type. 461 * 462 * @return radio access network type 463 */ 464 public @AccessNetworkConstants.RadioAccessNetworkType int getRadioAccessNetworkType() { 465 return mRan; 466 } 467 468 /** 469 * Get the signal measurement type. 470 * 471 * @return the SignalMeasurementType value 472 */ 473 public @SignalMeasurementType int getSignalMeasurementType() { 474 return mSignalMeasurementType; 475 } 476 477 /** @hide */ 478 public int getHysteresisMs() { 479 return mHysteresisMs; 480 } 481 482 /** @hide */ 483 public int getHysteresisDb() { 484 return mHysteresisDb; 485 } 486 487 /** @hide */ 488 public boolean isEnabled() { 489 return mIsEnabled; 490 } 491 492 /** 493 * Get the signal strength thresholds. 494 * 495 * Signal strength thresholds are a list of integer used for suggesting signal level and signal 496 * reporting criteria. The range and unit must reference specific SignalMeasurementType. 497 * 498 * Please refer to https://source.android.com/devices/tech/connect/signal-strength on how signal 499 * strength thresholds are used for signal strength reporting. 500 * 501 * @return array of integer of the signal thresholds 502 * 503 * @see #SIGNAL_MEASUREMENT_TYPE_RSSI 504 * @see #SIGNAL_MEASUREMENT_TYPE_RSCP 505 * @see #SIGNAL_MEASUREMENT_TYPE_RSRP 506 * @see #SIGNAL_MEASUREMENT_TYPE_RSRQ 507 * @see #SIGNAL_MEASUREMENT_TYPE_RSSNR 508 * @see #SIGNAL_MEASUREMENT_TYPE_SSRSRP 509 * @see #SIGNAL_MEASUREMENT_TYPE_SSRSRQ 510 * @see #SIGNAL_MEASUREMENT_TYPE_SSSINR 511 */ 512 public @NonNull int[] getThresholds() { 513 return mThresholds.clone(); 514 } 515 516 /** 517 * Get the minimum number of thresholds allowed in each SignalThresholdInfo. 518 * 519 * @return the minimum number of thresholds allowed 520 */ 521 public static int getMinimumNumberOfThresholdsAllowed() { 522 return MINIMUM_NUMBER_OF_THRESHOLDS_ALLOWED; 523 } 524 525 /** 526 * Get the maximum number of threshold allowed in each SignalThresholdInfo. 527 * 528 * @return the maximum number of thresholds allowed 529 */ 530 public static int getMaximumNumberOfThresholdsAllowed() { 531 return MAXIMUM_NUMBER_OF_THRESHOLDS_ALLOWED; 532 } 533 534 @Override 535 public int describeContents() { 536 return 0; 537 } 538 539 @Override 540 public void writeToParcel(@NonNull Parcel out, int flags) { 541 out.writeInt(mRan); 542 out.writeInt(mSignalMeasurementType); 543 out.writeInt(mHysteresisMs); 544 out.writeInt(mHysteresisDb); 545 out.writeIntArray(mThresholds); 546 out.writeBoolean(mIsEnabled); 547 } 548 549 private SignalThresholdInfo(Parcel in) { 550 mRan = in.readInt(); 551 mSignalMeasurementType = in.readInt(); 552 mHysteresisMs = in.readInt(); 553 mHysteresisDb = in.readInt(); 554 mThresholds = in.createIntArray(); 555 mIsEnabled = in.readBoolean(); 556 } 557 558 @Override 559 public boolean equals(Object o) { 560 if (this == o) return true; 561 562 if (!(o instanceof SignalThresholdInfo)) { 563 return false; 564 } 565 566 SignalThresholdInfo other = (SignalThresholdInfo) o; 567 return mRan == other.mRan 568 && mSignalMeasurementType == other.mSignalMeasurementType 569 && mHysteresisMs == other.mHysteresisMs 570 && mHysteresisDb == other.mHysteresisDb 571 && Arrays.equals(mThresholds, other.mThresholds) 572 && mIsEnabled == other.mIsEnabled; 573 } 574 575 @Override 576 public int hashCode() { 577 return Objects.hash(mRan, mSignalMeasurementType, mHysteresisMs, mHysteresisDb, mThresholds, 578 mIsEnabled); 579 } 580 581 public static final @NonNull Parcelable.Creator<SignalThresholdInfo> CREATOR = 582 new Parcelable.Creator<SignalThresholdInfo>() { 583 @Override 584 public SignalThresholdInfo createFromParcel(Parcel in) { 585 return new SignalThresholdInfo(in); 586 } 587 588 @Override 589 public SignalThresholdInfo[] newArray(int size) { 590 return new SignalThresholdInfo[size]; 591 } 592 }; 593 594 @Override 595 public String toString() { 596 return new StringBuilder("SignalThresholdInfo{") 597 .append("mRan=").append(mRan) 598 .append(" mSignalMeasurementType=").append(mSignalMeasurementType) 599 .append(" mHysteresisMs=").append(mHysteresisMs) 600 .append(" mHysteresisDb=").append(mHysteresisDb) 601 .append(" mThresholds=").append(Arrays.toString(mThresholds)) 602 .append(" mIsEnabled=").append(mIsEnabled) 603 .append("}").toString(); 604 } 605 606 /** 607 * Return true if signal measurement type is valid and the threshold value is in range. 608 */ 609 private static boolean isValidThreshold(@SignalMeasurementType int type, int threshold) { 610 switch (type) { 611 case SIGNAL_MEASUREMENT_TYPE_RSSI: 612 return threshold >= SIGNAL_RSSI_MIN_VALUE && threshold <= SIGNAL_RSSI_MAX_VALUE; 613 case SIGNAL_MEASUREMENT_TYPE_RSCP: 614 return threshold >= SIGNAL_RSCP_MIN_VALUE && threshold <= SIGNAL_RSCP_MAX_VALUE; 615 case SIGNAL_MEASUREMENT_TYPE_RSRP: 616 return threshold >= SIGNAL_RSRP_MIN_VALUE && threshold <= SIGNAL_RSRP_MAX_VALUE; 617 case SIGNAL_MEASUREMENT_TYPE_RSRQ: 618 return threshold >= SIGNAL_RSRQ_MIN_VALUE && threshold <= SIGNAL_RSRQ_MAX_VALUE; 619 case SIGNAL_MEASUREMENT_TYPE_RSSNR: 620 return threshold >= SIGNAL_RSSNR_MIN_VALUE && threshold <= SIGNAL_RSSNR_MAX_VALUE; 621 case SIGNAL_MEASUREMENT_TYPE_SSRSRP: 622 return threshold >= SIGNAL_SSRSRP_MIN_VALUE && threshold <= SIGNAL_SSRSRP_MAX_VALUE; 623 case SIGNAL_MEASUREMENT_TYPE_SSRSRQ: 624 return threshold >= SIGNAL_SSRSRQ_MIN_VALUE && threshold <= SIGNAL_SSRSRQ_MAX_VALUE; 625 case SIGNAL_MEASUREMENT_TYPE_SSSINR: 626 return threshold >= SIGNAL_SSSINR_MIN_VALUE && threshold <= SIGNAL_SSSINR_MAX_VALUE; 627 default: 628 return false; 629 } 630 } 631 632 /** 633 * Return true if the radio access type is allowed to set with the measurement type. 634 */ 635 private static boolean isValidRanWithMeasurementType( 636 @AccessNetworkConstants.RadioAccessNetworkType int ran, 637 @SignalMeasurementType int type) { 638 switch (type) { 639 case SIGNAL_MEASUREMENT_TYPE_RSSI: 640 return ran == AccessNetworkConstants.AccessNetworkType.GERAN 641 || ran == AccessNetworkConstants.AccessNetworkType.CDMA2000; 642 case SIGNAL_MEASUREMENT_TYPE_RSCP: 643 return ran == AccessNetworkConstants.AccessNetworkType.UTRAN; 644 case SIGNAL_MEASUREMENT_TYPE_RSRP: 645 case SIGNAL_MEASUREMENT_TYPE_RSRQ: 646 case SIGNAL_MEASUREMENT_TYPE_RSSNR: 647 return ran == AccessNetworkConstants.AccessNetworkType.EUTRAN; 648 case SIGNAL_MEASUREMENT_TYPE_SSRSRP: 649 case SIGNAL_MEASUREMENT_TYPE_SSRSRQ: 650 case SIGNAL_MEASUREMENT_TYPE_SSSINR: 651 return ran == AccessNetworkConstants.AccessNetworkType.NGRAN; 652 default: 653 return false; 654 } 655 } 656 657 private void validateRanWithMeasurementType( 658 @AccessNetworkConstants.RadioAccessNetworkType int ran, 659 @SignalMeasurementType int signalMeasurement) { 660 if (!isValidRanWithMeasurementType(ran, signalMeasurement)) { 661 throw new IllegalArgumentException( 662 "invalid RAN: " + ran + " with signal measurement type: " + signalMeasurement); 663 } 664 } 665 666 private void validateThresholdRange(@SignalMeasurementType int signalMeasurement, 667 int[] thresholds) { 668 for (int threshold : thresholds) { 669 if (!isValidThreshold(signalMeasurement, threshold)) { 670 throw new IllegalArgumentException( 671 "invalid signal measurement type: " + signalMeasurement 672 + " with threshold: " + threshold); 673 } 674 } 675 } 676 } 677