1 /* 2 * Copyright (C) 2012 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.IntRange; 20 import android.compat.annotation.UnsupportedAppUsage; 21 import android.os.Build; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 import android.os.PersistableBundle; 25 26 import com.android.telephony.Rlog; 27 28 import java.util.Arrays; 29 import java.util.Objects; 30 31 /** 32 * LTE signal strength related information. 33 */ 34 public final class CellSignalStrengthLte extends CellSignalStrength implements Parcelable { 35 36 private static final String LOG_TAG = "CellSignalStrengthLte"; 37 private static final boolean DBG = false; 38 39 /** 40 * Indicates the unknown or undetectable RSSI value in ASU. 41 * 42 * Reference: TS 27.007 8.5 - Signal quality +CSQ 43 */ 44 private static final int SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN = 99; 45 /** 46 * Indicates the maximum valid RSSI value in ASU. 47 * 48 * Reference: TS 27.007 8.5 - Signal quality +CSQ 49 */ 50 private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE = 31; 51 /** 52 * Indicates the minimum valid RSSI value in ASU. 53 * 54 * Reference: TS 27.007 8.5 - Signal quality +CSQ 55 */ 56 private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE = 0; 57 58 private static final int MAX_LTE_RSRP = -44; 59 private static final int MIN_LTE_RSRP = -140; 60 61 /** 62 * Indicates RSRP is considered for {@link #getLevel()} and reported from modem. 63 * 64 * @hide 65 */ 66 public static final int USE_RSRP = 1 << 0; 67 /** 68 * Indicates RSRQ is considered for {@link #getLevel()} and reported from modem. 69 * 70 * @hide 71 */ 72 public static final int USE_RSRQ = 1 << 1; 73 /** 74 * Indicates RSSNR is considered for {@link #getLevel()} and reported from modem. 75 * 76 * @hide 77 */ 78 public static final int USE_RSSNR = 1 << 2; 79 80 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 81 private int mSignalStrength; // To be removed 82 private int mRssi; 83 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 84 private int mRsrp; 85 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 86 private int mRsrq; 87 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 88 private int mRssnr; 89 /** 90 * CSI channel quality indicator (CQI) table index. There are multiple CQI tables. 91 * The definition of CQI in each table is different. 92 * 93 * Reference: 3GPP TS 136.213 section 7.2.3. 94 * 95 * Range [1, 6]. 96 */ 97 private int mCqiTableIndex; 98 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 99 private int mCqi; 100 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) 101 private int mTimingAdvance; 102 private int mLevel; 103 104 /** 105 * Bit-field integer to determine whether to use Reference Signal Received Power (RSRP), 106 * Reference Signal Received Quality (RSRQ), and/or Reference Signal Signal to Noise Ratio 107 * (RSSNR) for the number of LTE signal bars. If multiple measures are set, the parameter 108 * whose signal level value is smallest is used to indicate the signal level. 109 * 110 * RSRP = 1 << 0, 111 * RSRQ = 1 << 1, 112 * RSSNR = 1 << 2, 113 * 114 * For example, if both RSRP and RSRQ are used, the value of key is 3 (1 << 0 | 1 << 1). 115 * If the key is invalid or not configured, a default value (RSRP = 1 << 0) will apply. 116 */ 117 private int mParametersUseForLevel; 118 119 /** @hide */ 120 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) CellSignalStrengthLte()121 public CellSignalStrengthLte() { 122 setDefaultValues(); 123 } 124 125 /** 126 * Construct a cell signal strength 127 * 128 * @param rssi in dBm [-113,-51], UNKNOWN 129 * @param rsrp in dBm [-140,-43], UNKNOWN 130 * @param rsrq in dB [-34, 3], UNKNOWN 131 * @param rssnr in dB [-20, +30], UNKNOWN 132 * @param cqiTableIndex [1, 6], UNKNOWN 133 * @param cqi [0, 15], UNKNOWN 134 * @param timingAdvance [0, 1282], UNKNOWN 135 * 136 */ 137 /** @hide */ CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqiTableIndex, int cqi, int timingAdvance)138 public CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqiTableIndex, 139 int cqi, int timingAdvance) { 140 mRssi = inRangeOrUnavailable(rssi, -113, -51); 141 mSignalStrength = mRssi; 142 mRsrp = inRangeOrUnavailable(rsrp, -140, -43); 143 mRsrq = inRangeOrUnavailable(rsrq, -34, 3); 144 mRssnr = inRangeOrUnavailable(rssnr, -20, 30); 145 mCqiTableIndex = inRangeOrUnavailable(cqiTableIndex, 1, 6); 146 mCqi = inRangeOrUnavailable(cqi, 0, 15); 147 mTimingAdvance = inRangeOrUnavailable(timingAdvance, 0, 1282); 148 updateLevel(null, null); 149 } 150 151 /** 152 * Construct a cell signal strength 153 * 154 * @param rssi in dBm [-113,-51], UNKNOWN 155 * @param rsrp in dBm [-140,-43], UNKNOWN 156 * @param rsrq in dB [-34, 3], UNKNOWN 157 * @param rssnr in dB [-20, +30], UNKNOWN 158 * @param cqi [0, 15], UNKNOWN 159 * @param timingAdvance [0, 1282], UNKNOWN 160 * 161 */ 162 /** @hide */ CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqi, int timingAdvance)163 public CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqi, 164 int timingAdvance) { 165 this(rssi, rsrp, rsrq, rssnr, CellInfo.UNAVAILABLE, cqi, timingAdvance); 166 } 167 168 /** @hide */ CellSignalStrengthLte(android.hardware.radio.V1_0.LteSignalStrength lte)169 public CellSignalStrengthLte(android.hardware.radio.V1_0.LteSignalStrength lte) { 170 // Convert from HAL values as part of construction. 171 this(convertRssiAsuToDBm(lte.signalStrength), 172 lte.rsrp != CellInfo.UNAVAILABLE ? -lte.rsrp : lte.rsrp, 173 lte.rsrq != CellInfo.UNAVAILABLE ? -lte.rsrq : lte.rsrq, 174 convertRssnrUnitFromTenDbToDB(lte.rssnr), lte.cqi, lte.timingAdvance); 175 } 176 177 /** @hide */ CellSignalStrengthLte(android.hardware.radio.V1_6.LteSignalStrength lte)178 public CellSignalStrengthLte(android.hardware.radio.V1_6.LteSignalStrength lte) { 179 // Convert from HAL values as part of construction. 180 this(convertRssiAsuToDBm(lte.base.signalStrength), 181 lte.base.rsrp != CellInfo.UNAVAILABLE ? -lte.base.rsrp : lte.base.rsrp, 182 lte.base.rsrq != CellInfo.UNAVAILABLE ? -lte.base.rsrq : lte.base.rsrq, 183 convertRssnrUnitFromTenDbToDB(lte.base.rssnr), lte.cqiTableIndex, lte.base.cqi, 184 lte.base.timingAdvance); 185 } 186 187 /** @hide */ CellSignalStrengthLte(CellSignalStrengthLte s)188 public CellSignalStrengthLte(CellSignalStrengthLte s) { 189 copyFrom(s); 190 } 191 192 /** @hide */ copyFrom(CellSignalStrengthLte s)193 protected void copyFrom(CellSignalStrengthLte s) { 194 mSignalStrength = s.mSignalStrength; 195 mRssi = s.mRssi; 196 mRsrp = s.mRsrp; 197 mRsrq = s.mRsrq; 198 mRssnr = s.mRssnr; 199 mCqiTableIndex = s.mCqiTableIndex; 200 mCqi = s.mCqi; 201 mTimingAdvance = s.mTimingAdvance; 202 mLevel = s.mLevel; 203 mParametersUseForLevel = s.mParametersUseForLevel; 204 } 205 206 /** @hide */ 207 @Override copy()208 public CellSignalStrengthLte copy() { 209 return new CellSignalStrengthLte(this); 210 } 211 212 /** @hide */ 213 @Override setDefaultValues()214 public void setDefaultValues() { 215 mSignalStrength = CellInfo.UNAVAILABLE; 216 mRssi = CellInfo.UNAVAILABLE; 217 mRsrp = CellInfo.UNAVAILABLE; 218 mRsrq = CellInfo.UNAVAILABLE; 219 mRssnr = CellInfo.UNAVAILABLE; 220 mCqiTableIndex = CellInfo.UNAVAILABLE; 221 mCqi = CellInfo.UNAVAILABLE; 222 mTimingAdvance = CellInfo.UNAVAILABLE; 223 mLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 224 mParametersUseForLevel = USE_RSRP; 225 } 226 227 /** {@inheritDoc} */ 228 @Override 229 @IntRange(from = SIGNAL_STRENGTH_NONE_OR_UNKNOWN, to = SIGNAL_STRENGTH_GREAT) getLevel()230 public int getLevel() { 231 return mLevel; 232 } 233 234 // Lifted from Default carrier configs and max range of RSRP 235 private static final int[] sRsrpThresholds = new int[] { 236 -115, /* SIGNAL_STRENGTH_POOR */ 237 -105, /* SIGNAL_STRENGTH_MODERATE */ 238 -95, /* SIGNAL_STRENGTH_GOOD */ 239 -85 /* SIGNAL_STRENGTH_GREAT */ 240 }; 241 242 // Lifted from Default carrier configs and max range of RSRQ 243 private static final int[] sRsrqThresholds = new int[] { 244 -19, /* SIGNAL_STRENGTH_POOR */ 245 -17, /* SIGNAL_STRENGTH_MODERATE */ 246 -14, /* SIGNAL_STRENGTH_GOOD */ 247 -12 /* SIGNAL_STRENGTH_GREAT */ 248 }; 249 // Lifted from Default carrier configs and max range of RSSNR 250 private static final int[] sRssnrThresholds = new int[] { 251 -3, /* SIGNAL_STRENGTH_POOR */ 252 1, /* SIGNAL_STRENGTH_MODERATE */ 253 5, /* SIGNAL_STRENGTH_GOOD */ 254 13 /* SIGNAL_STRENGTH_GREAT */ 255 }; 256 private static final int sRsrpBoost = 0; 257 258 /** 259 * Checks if the given parameter type is considered to use for {@link #getLevel()}. 260 * 261 * Note: if multiple parameter types are considered, the smaller level for one of the 262 * parameters would be returned by {@link #getLevel()} 263 * 264 * @param parameterType bitwise OR of {@link #USE_RSRP}, {@link #USE_RSRQ}, 265 * {@link #USE_RSSNR} 266 * @return {@code true} if the level is calculated based on the given parameter type; 267 * {@code false} otherwise. 268 */ isLevelForParameter(int parameterType)269 private boolean isLevelForParameter(int parameterType) { 270 return (parameterType & mParametersUseForLevel) == parameterType; 271 } 272 273 /** @hide */ 274 @Override updateLevel(PersistableBundle cc, ServiceState ss)275 public void updateLevel(PersistableBundle cc, ServiceState ss) { 276 int[] rsrpThresholds, rsrqThresholds, rssnrThresholds; 277 boolean rsrpOnly; 278 if (cc == null) { 279 mParametersUseForLevel = USE_RSRP; 280 rsrpThresholds = sRsrpThresholds; 281 rsrqThresholds = sRsrqThresholds; 282 rssnrThresholds = sRssnrThresholds; 283 rsrpOnly = false; 284 } else { 285 mParametersUseForLevel = cc.getInt( 286 CarrierConfigManager.KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT); 287 if (DBG) { 288 Rlog.i(LOG_TAG, "Using signal strength level: " + mParametersUseForLevel); 289 } 290 rsrpThresholds = cc.getIntArray( 291 CarrierConfigManager.KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY); 292 if (rsrpThresholds == null) rsrpThresholds = sRsrpThresholds; 293 if (DBG) { 294 Rlog.i(LOG_TAG, "Applying LTE RSRP Thresholds: " 295 + Arrays.toString(rsrpThresholds)); 296 } 297 rsrqThresholds = cc.getIntArray( 298 CarrierConfigManager.KEY_LTE_RSRQ_THRESHOLDS_INT_ARRAY); 299 if (rsrqThresholds == null) rsrqThresholds = sRsrqThresholds; 300 if (DBG) { 301 Rlog.i(LOG_TAG, "Applying LTE RSRQ Thresholds: " 302 + Arrays.toString(rsrqThresholds)); 303 } 304 rssnrThresholds = cc.getIntArray( 305 CarrierConfigManager.KEY_LTE_RSSNR_THRESHOLDS_INT_ARRAY); 306 if (rssnrThresholds == null) rssnrThresholds = sRssnrThresholds; 307 if (DBG) { 308 Rlog.i(LOG_TAG, "Applying LTE RSSNR Thresholds: " 309 + Arrays.toString(rssnrThresholds)); 310 } 311 rsrpOnly = cc.getBoolean( 312 CarrierConfigManager.KEY_USE_ONLY_RSRP_FOR_LTE_SIGNAL_BAR_BOOL, false); 313 } 314 315 int rsrpBoost = 0; 316 if (ss != null) { 317 rsrpBoost = ss.getArfcnRsrpBoost(); 318 } 319 320 int rsrp = inRangeOrUnavailable(mRsrp + rsrpBoost, MIN_LTE_RSRP, MAX_LTE_RSRP); 321 322 if (rsrpOnly) { 323 int level = updateLevelWithMeasure(rsrp, rsrpThresholds); 324 if (DBG) log("updateLevel() - rsrp = " + level); 325 if (level != SignalStrength.INVALID) { 326 mLevel = level; 327 return; 328 } 329 } 330 331 int rsrpLevel = SignalStrength.INVALID; 332 int rsrqLevel = SignalStrength.INVALID; 333 int rssnrLevel = SignalStrength.INVALID; 334 335 if (isLevelForParameter(USE_RSRP)) { 336 rsrpLevel = updateLevelWithMeasure(rsrp, rsrpThresholds); 337 if (DBG) { 338 Rlog.i(LOG_TAG, "Updated 4G LTE RSRP Level: " + rsrpLevel); 339 } 340 } 341 if (isLevelForParameter(USE_RSRQ)) { 342 rsrqLevel = updateLevelWithMeasure(mRsrq, rsrqThresholds); 343 if (DBG) { 344 Rlog.i(LOG_TAG, "Updated 4G LTE RSRQ Level: " + rsrqLevel); 345 } 346 } 347 if (isLevelForParameter(USE_RSSNR)) { 348 rssnrLevel = updateLevelWithMeasure(mRssnr, rssnrThresholds); 349 if (DBG) { 350 Rlog.i(LOG_TAG, "Updated 4G LTE RSSNR Level: " + rssnrLevel); 351 } 352 } 353 // Apply the smaller value among three levels of three measures. 354 mLevel = Math.min(Math.min(rsrpLevel, rsrqLevel), rssnrLevel); 355 356 if (mLevel == SignalStrength.INVALID) { 357 int rssiLevel; 358 if (mRssi > -51) { 359 rssiLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 360 } else if (mRssi >= -89) { 361 rssiLevel = SIGNAL_STRENGTH_GREAT; 362 } else if (mRssi >= -97) { 363 rssiLevel = SIGNAL_STRENGTH_GOOD; 364 } else if (mRssi >= -103) { 365 rssiLevel = SIGNAL_STRENGTH_MODERATE; 366 } else if (mRssi >= -113) { 367 rssiLevel = SIGNAL_STRENGTH_POOR; 368 } else { 369 rssiLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 370 } 371 if (DBG) log("getLteLevel - rssi:" + mRssi + " rssiIconLevel:" + rssiLevel); 372 mLevel = rssiLevel; 373 } 374 } 375 376 /** 377 * Update level with corresponding measure and thresholds. 378 * 379 * @param measure corresponding signal measure 380 * @param thresholds corresponding signal thresholds 381 * @return level of the signal strength 382 */ updateLevelWithMeasure(int measure, int[] thresholds)383 private int updateLevelWithMeasure(int measure, int[] thresholds) { 384 int level; 385 if (measure == CellInfo.UNAVAILABLE) { 386 level = SignalStrength.INVALID; 387 } else if (measure >= thresholds[3]) { 388 level = SIGNAL_STRENGTH_GREAT; 389 } else if (measure >= thresholds[2]) { 390 level = SIGNAL_STRENGTH_GOOD; 391 } else if (measure >= thresholds[1]) { 392 level = SIGNAL_STRENGTH_MODERATE; 393 } else if (measure >= thresholds[0]) { 394 level = SIGNAL_STRENGTH_POOR; 395 } else { 396 level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 397 } 398 return level; 399 } 400 401 /** 402 * Get reference signal received quality 403 * 404 * @return the RSRQ if available or 405 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. 406 */ getRsrq()407 public int getRsrq() { 408 return mRsrq; 409 } 410 411 /** 412 * Get Received Signal Strength Indication (RSSI) in dBm 413 * 414 * The value range is [-113, -51] inclusively or {@link CellInfo#UNAVAILABLE} if unavailable. 415 * 416 * Reference: TS 27.007 8.5 Signal quality +CSQ 417 * 418 * @return the RSSI if available or {@link CellInfo#UNAVAILABLE} if unavailable. 419 */ getRssi()420 public int getRssi() { 421 return mRssi; 422 } 423 424 /** 425 * Get reference signal signal-to-noise ratio 426 * 427 * @return the RSSNR if available or 428 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. 429 */ getRssnr()430 public int getRssnr() { 431 return mRssnr; 432 } 433 434 /** 435 * Get reference signal received power in dBm 436 * 437 * @return the RSRP of the measured cell. 438 */ getRsrp()439 public int getRsrp() { 440 return mRsrp; 441 } 442 443 /** 444 * Get table index for channel quality indicator 445 * 446 * Reference: 3GPP TS 136.213 section 7.2.3. 447 * 448 * @return the CQI table index if available or 449 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. 450 */ 451 @IntRange(from = 1, to = 6) getCqiTableIndex()452 public int getCqiTableIndex() { 453 return mCqiTableIndex; 454 } 455 456 /** 457 * Get channel quality indicator 458 * 459 * Reference: 3GPP TS 136.213 section 7.2.3. 460 * 461 * @return the CQI if available or 462 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. 463 */ 464 @IntRange(from = 0, to = 15) getCqi()465 public int getCqi() { 466 return mCqi; 467 } 468 469 /** 470 * Get signal strength in dBm 471 * 472 * @return the RSRP of the measured cell. 473 */ 474 @Override getDbm()475 public int getDbm() { 476 return mRsrp; 477 } 478 479 /** 480 * Get the RSRP in ASU. 481 * 482 * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 483 * 484 * @return RSCP in ASU 0..97, 255, or UNAVAILABLE 485 */ 486 @Override getAsuLevel()487 public int getAsuLevel() { 488 int lteAsuLevel = 99; 489 int lteDbm = mRsrp; 490 if (lteDbm == CellInfo.UNAVAILABLE) lteAsuLevel = 99; 491 else if (lteDbm <= -140) lteAsuLevel = 0; 492 else if (lteDbm >= -43) lteAsuLevel = 97; 493 else lteAsuLevel = lteDbm + 140; 494 if (DBG) log("Lte Asu level: "+lteAsuLevel); 495 return lteAsuLevel; 496 } 497 498 /** 499 * Get the timing advance value for LTE, as a value in range of 0..1282. 500 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} is reported when there is no 501 * active RRC connection. Refer to 3GPP 36.213 Sec 4.2.3 502 * 503 * @return the LTE timing advance if available or 504 * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. 505 */ getTimingAdvance()506 public int getTimingAdvance() { 507 return mTimingAdvance; 508 } 509 510 @Override hashCode()511 public int hashCode() { 512 return Objects.hash(mRssi, mRsrp, mRsrq, mRssnr, mCqiTableIndex, mCqi, mTimingAdvance, 513 mLevel); 514 } 515 516 private static final CellSignalStrengthLte sInvalid = new CellSignalStrengthLte(); 517 518 /** @hide */ 519 @Override isValid()520 public boolean isValid() { 521 return !this.equals(sInvalid); 522 } 523 524 @Override equals(Object o)525 public boolean equals (Object o) { 526 CellSignalStrengthLte s; 527 528 if (!(o instanceof CellSignalStrengthLte)) return false; 529 s = (CellSignalStrengthLte) o; 530 531 return mRssi == s.mRssi 532 && mRsrp == s.mRsrp 533 && mRsrq == s.mRsrq 534 && mRssnr == s.mRssnr 535 && mCqiTableIndex == s.mCqiTableIndex 536 && mCqi == s.mCqi 537 && mTimingAdvance == s.mTimingAdvance 538 && mLevel == s.mLevel; 539 } 540 541 /** 542 * @return string representation. 543 */ 544 @Override toString()545 public String toString() { 546 return "CellSignalStrengthLte:" 547 + " rssi=" + mRssi 548 + " rsrp=" + mRsrp 549 + " rsrq=" + mRsrq 550 + " rssnr=" + mRssnr 551 + " cqiTableIndex=" + mCqiTableIndex 552 + " cqi=" + mCqi 553 + " ta=" + mTimingAdvance 554 + " level=" + mLevel 555 + " parametersUseForLevel=" + mParametersUseForLevel; 556 } 557 558 /** Implement the Parcelable interface */ 559 @Override writeToParcel(Parcel dest, int flags)560 public void writeToParcel(Parcel dest, int flags) { 561 if (DBG) log("writeToParcel(Parcel, int): " + toString()); 562 dest.writeInt(mRssi); 563 // Need to multiply rsrp and rsrq by -1 564 // to ensure consistency when reading values written here 565 // unless the values are invalid 566 dest.writeInt(mRsrp); 567 dest.writeInt(mRsrq); 568 dest.writeInt(mRssnr); 569 dest.writeInt(mCqiTableIndex); 570 dest.writeInt(mCqi); 571 dest.writeInt(mTimingAdvance); 572 dest.writeInt(mLevel); 573 } 574 575 /** 576 * Construct a SignalStrength object from the given parcel 577 * where the token is already been processed. 578 */ CellSignalStrengthLte(Parcel in)579 private CellSignalStrengthLte(Parcel in) { 580 mRssi = in.readInt(); 581 mSignalStrength = mRssi; 582 mRsrp = in.readInt(); 583 mRsrq = in.readInt(); 584 mRssnr = in.readInt(); 585 mCqiTableIndex = in.readInt(); 586 mCqi = in.readInt(); 587 mTimingAdvance = in.readInt(); 588 mLevel = in.readInt(); 589 if (DBG) log("CellSignalStrengthLte(Parcel): " + toString()); 590 } 591 592 /** Implement the Parcelable interface */ 593 @Override describeContents()594 public int describeContents() { 595 return 0; 596 } 597 598 /** Implement the Parcelable interface */ 599 @SuppressWarnings("hiding") 600 public static final @android.annotation.NonNull Parcelable.Creator<CellSignalStrengthLte> CREATOR = 601 new Parcelable.Creator<CellSignalStrengthLte>() { 602 @Override 603 public CellSignalStrengthLte createFromParcel(Parcel in) { 604 return new CellSignalStrengthLte(in); 605 } 606 607 @Override 608 public CellSignalStrengthLte[] newArray(int size) { 609 return new CellSignalStrengthLte[size]; 610 } 611 }; 612 613 /** 614 * log 615 */ log(String s)616 private static void log(String s) { 617 Rlog.w(LOG_TAG, s); 618 } 619 convertRssnrUnitFromTenDbToDB(int rssnr)620 private static int convertRssnrUnitFromTenDbToDB(int rssnr) { 621 return rssnr / 10; 622 } 623 convertRssiAsuToDBm(int rssiAsu)624 private static int convertRssiAsuToDBm(int rssiAsu) { 625 if (rssiAsu == SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN) { 626 return CellInfo.UNAVAILABLE; 627 } 628 if ((rssiAsu < SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE 629 || rssiAsu > SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE)) { 630 Rlog.e(LOG_TAG, "convertRssiAsuToDBm: invalid RSSI in ASU=" + rssiAsu); 631 return CellInfo.UNAVAILABLE; 632 } 633 return -113 + (2 * rssiAsu); 634 } 635 } 636