SignalStrength.java revision 5e39519396918f9e2312d1c355a9b6889851d887
1/* 2 * Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved. 3 * Copyright (C) 2009 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package android.telephony; 19 20import android.os.Bundle; 21import android.os.Parcel; 22import android.os.Parcelable; 23import android.util.Log; 24 25/** 26 * Contains phone signal strength related information. 27 */ 28public class SignalStrength implements Parcelable { 29 30 private static final String LOG_TAG = "SignalStrength"; 31 private static final boolean DBG = false; 32 33 /** @hide */ 34 public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; 35 /** @hide */ 36 public static final int SIGNAL_STRENGTH_POOR = 1; 37 /** @hide */ 38 public static final int SIGNAL_STRENGTH_MODERATE = 2; 39 /** @hide */ 40 public static final int SIGNAL_STRENGTH_GOOD = 3; 41 /** @hide */ 42 public static final int SIGNAL_STRENGTH_GREAT = 4; 43 /** @hide */ 44 public static final int NUM_SIGNAL_STRENGTH_BINS = 5; 45 /** @hide */ 46 public static final String[] SIGNAL_STRENGTH_NAMES = { 47 "none", "poor", "moderate", "good", "great" 48 }; 49 50 /** @hide */ 51 public static final int INVALID_SNR = 0x7FFFFFFF; 52 53 private int mGsmSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5 54 private int mGsmBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5 55 private int mCdmaDbm; // This value is the RSSI value 56 private int mCdmaEcio; // This value is the Ec/Io 57 private int mEvdoDbm; // This value is the EVDO RSSI value 58 private int mEvdoEcio; // This value is the EVDO Ec/Io 59 private int mEvdoSnr; // Valid values are 0-8. 8 is the highest signal to noise ratio 60 private int mLteSignalStrength; 61 private int mLteRsrp; 62 private int mLteRsrq; 63 private int mLteRssnr; 64 private int mLteCqi; 65 66 private boolean isGsm; // This value is set by the ServiceStateTracker onSignalStrengthResult 67 68 /** 69 * Create a new SignalStrength from a intent notifier Bundle 70 * 71 * This method is used by PhoneStateIntentReceiver and maybe by 72 * external applications. 73 * 74 * @param m Bundle from intent notifier 75 * @return newly created SignalStrength 76 * 77 * @hide 78 */ 79 public static SignalStrength newFromBundle(Bundle m) { 80 SignalStrength ret; 81 ret = new SignalStrength(); 82 ret.setFromNotifierBundle(m); 83 return ret; 84 } 85 86 /** 87 * Empty constructor 88 * 89 * @hide 90 */ 91 public SignalStrength() { 92 mGsmSignalStrength = 99; 93 mGsmBitErrorRate = -1; 94 mCdmaDbm = -1; 95 mCdmaEcio = -1; 96 mEvdoDbm = -1; 97 mEvdoEcio = -1; 98 mEvdoSnr = -1; 99 mLteSignalStrength = -1; 100 mLteRsrp = -1; 101 mLteRsrq = -1; 102 mLteRssnr = INVALID_SNR; 103 mLteCqi = -1; 104 isGsm = true; 105 } 106 107 /** 108 * Constructor 109 * 110 * @hide 111 */ 112 public SignalStrength(int gsmSignalStrength, int gsmBitErrorRate, 113 int cdmaDbm, int cdmaEcio, 114 int evdoDbm, int evdoEcio, int evdoSnr, 115 int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi, 116 boolean gsm) { 117 mGsmSignalStrength = gsmSignalStrength; 118 mGsmBitErrorRate = gsmBitErrorRate; 119 mCdmaDbm = cdmaDbm; 120 mCdmaEcio = cdmaEcio; 121 mEvdoDbm = evdoDbm; 122 mEvdoEcio = evdoEcio; 123 mEvdoSnr = evdoSnr; 124 mLteSignalStrength = lteSignalStrength; 125 mLteRsrp = lteRsrp; 126 mLteRsrq = lteRsrq; 127 mLteRssnr = lteRssnr; 128 mLteCqi = lteCqi; 129 isGsm = gsm; 130 } 131 132 /** 133 * Constructor 134 * 135 * @hide 136 */ 137 public SignalStrength(int gsmSignalStrength, int gsmBitErrorRate, 138 int cdmaDbm, int cdmaEcio, 139 int evdoDbm, int evdoEcio, int evdoSnr, 140 boolean gsm) { 141 this(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio, 142 evdoDbm, evdoEcio, evdoSnr, -1, -1, 143 -1, INVALID_SNR, -1, gsm); 144 } 145 146 /** 147 * Copy constructors 148 * 149 * @param s Source SignalStrength 150 * 151 * @hide 152 */ 153 public SignalStrength(SignalStrength s) { 154 copyFrom(s); 155 } 156 157 /** 158 * @hide 159 */ 160 protected void copyFrom(SignalStrength s) { 161 mGsmSignalStrength = s.mGsmSignalStrength; 162 mGsmBitErrorRate = s.mGsmBitErrorRate; 163 mCdmaDbm = s.mCdmaDbm; 164 mCdmaEcio = s.mCdmaEcio; 165 mEvdoDbm = s.mEvdoDbm; 166 mEvdoEcio = s.mEvdoEcio; 167 mEvdoSnr = s.mEvdoSnr; 168 mLteSignalStrength = s.mLteSignalStrength; 169 mLteRsrp = s.mLteRsrp; 170 mLteRsrq = s.mLteRsrq; 171 mLteRssnr = s.mLteRssnr; 172 mLteCqi = s.mLteCqi; 173 isGsm = s.isGsm; 174 } 175 176 /** 177 * Construct a SignalStrength object from the given parcel. 178 * 179 * @hide 180 */ 181 public SignalStrength(Parcel in) { 182 mGsmSignalStrength = in.readInt(); 183 mGsmBitErrorRate = in.readInt(); 184 mCdmaDbm = in.readInt(); 185 mCdmaEcio = in.readInt(); 186 mEvdoDbm = in.readInt(); 187 mEvdoEcio = in.readInt(); 188 mEvdoSnr = in.readInt(); 189 mLteSignalStrength = in.readInt(); 190 mLteRsrp = in.readInt(); 191 mLteRsrq = in.readInt(); 192 mLteRssnr = in.readInt(); 193 mLteCqi = in.readInt(); 194 isGsm = (in.readInt() != 0); 195 } 196 197 /** 198 * {@link Parcelable#writeToParcel} 199 */ 200 public void writeToParcel(Parcel out, int flags) { 201 out.writeInt(mGsmSignalStrength); 202 out.writeInt(mGsmBitErrorRate); 203 out.writeInt(mCdmaDbm); 204 out.writeInt(mCdmaEcio); 205 out.writeInt(mEvdoDbm); 206 out.writeInt(mEvdoEcio); 207 out.writeInt(mEvdoSnr); 208 out.writeInt(mLteSignalStrength); 209 out.writeInt(mLteRsrp); 210 out.writeInt(mLteRsrq); 211 out.writeInt(mLteRssnr); 212 out.writeInt(mLteCqi); 213 out.writeInt(isGsm ? 1 : 0); 214 } 215 216 /** 217 * {@link Parcelable#describeContents} 218 */ 219 public int describeContents() { 220 return 0; 221 } 222 223 /** 224 * {@link Parcelable.Creator} 225 * 226 * @hide 227 */ 228 public static final Parcelable.Creator<SignalStrength> CREATOR = new Parcelable.Creator() { 229 public SignalStrength createFromParcel(Parcel in) { 230 return new SignalStrength(in); 231 } 232 233 public SignalStrength[] newArray(int size) { 234 return new SignalStrength[size]; 235 } 236 }; 237 238 /** 239 * Get the GSM Signal Strength, valid values are (0-31, 99) as defined in TS 27.007 8.5 240 */ 241 public int getGsmSignalStrength() { 242 return this.mGsmSignalStrength; 243 } 244 245 /** 246 * Get the GSM bit error rate (0-7, 99) as defined in TS 27.007 8.5 247 */ 248 public int getGsmBitErrorRate() { 249 return this.mGsmBitErrorRate; 250 } 251 252 /** 253 * Get the CDMA RSSI value in dBm 254 */ 255 public int getCdmaDbm() { 256 return this.mCdmaDbm; 257 } 258 259 /** 260 * Get the CDMA Ec/Io value in dB*10 261 */ 262 public int getCdmaEcio() { 263 return this.mCdmaEcio; 264 } 265 266 /** 267 * Get the EVDO RSSI value in dBm 268 */ 269 public int getEvdoDbm() { 270 return this.mEvdoDbm; 271 } 272 273 /** 274 * Get the EVDO Ec/Io value in dB*10 275 */ 276 public int getEvdoEcio() { 277 return this.mEvdoEcio; 278 } 279 280 /** 281 * Get the signal to noise ratio. Valid values are 0-8. 8 is the highest. 282 */ 283 public int getEvdoSnr() { 284 return this.mEvdoSnr; 285 } 286 287 /** 288 * Get signal level as an int from 0..4 289 * 290 * @hide 291 */ 292 public int getLevel() { 293 int level; 294 295 if (isGsm) { 296 if ((mLteSignalStrength == -1) 297 && (mLteRsrp == -1) 298 && (mLteRsrq == -1) 299 && (mLteRssnr == INVALID_SNR) 300 && (mLteCqi == -1)) { 301 level = getGsmLevel(); 302 } else { 303 level = getLteLevel(); 304 } 305 } else { 306 int cdmaLevel = getCdmaLevel(); 307 int evdoLevel = getEvdoLevel(); 308 if (evdoLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { 309 /* We don't know evdo, use cdma */ 310 level = getCdmaLevel(); 311 } else if (cdmaLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { 312 /* We don't know cdma, use evdo */ 313 level = getEvdoLevel(); 314 } else { 315 /* We know both, use the lowest level */ 316 level = cdmaLevel < evdoLevel ? cdmaLevel : evdoLevel; 317 } 318 } 319 if (DBG) log("getLevel=" + level); 320 return level; 321 } 322 323 /** 324 * Get the signal level as an asu value between 0..31, 99 is unknown 325 * 326 * @hide 327 */ 328 public int getAsuLevel() { 329 int asuLevel; 330 if (isGsm) { 331 if ((mLteSignalStrength == -1) 332 && (mLteRsrp == -1) 333 && (mLteRsrq == -1) 334 && (mLteRssnr == INVALID_SNR) 335 && (mLteCqi == -1)) { 336 asuLevel = getGsmAsuLevel(); 337 } else { 338 asuLevel = getLteAsuLevel(); 339 } 340 } else { 341 int cdmaAsuLevel = getCdmaAsuLevel(); 342 int evdoAsuLevel = getEvdoAsuLevel(); 343 if (evdoAsuLevel == 0) { 344 /* We don't know evdo use, cdma */ 345 asuLevel = cdmaAsuLevel; 346 } else if (cdmaAsuLevel == 0) { 347 /* We don't know cdma use, evdo */ 348 asuLevel = evdoAsuLevel; 349 } else { 350 /* We know both, use the lowest level */ 351 asuLevel = cdmaAsuLevel < evdoAsuLevel ? cdmaAsuLevel : evdoAsuLevel; 352 } 353 } 354 if (DBG) log("getAsuLevel=" + asuLevel); 355 return asuLevel; 356 } 357 358 /** 359 * Get the signal strength as dBm 360 * 361 * @hide 362 */ 363 public int getDbm() { 364 int dBm; 365 366 if(isGsm()) { 367 if ((mLteSignalStrength == -1) 368 && (mLteRsrp == -1) 369 && (mLteRsrq == -1) 370 && (mLteRssnr == INVALID_SNR) 371 && (mLteCqi == -1)) { 372 dBm = getGsmDbm(); 373 } else { 374 dBm = getLteDbm(); 375 } 376 } else { 377 dBm = getCdmaDbm(); 378 } 379 if (DBG) log("getDbm=" + dBm); 380 return dBm; 381 } 382 383 /** 384 * Get Gsm signal strength as dBm 385 * 386 * @hide 387 */ 388 public int getGsmDbm() { 389 int dBm; 390 391 int gsmSignalStrength = getGsmSignalStrength(); 392 int asu = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength); 393 if (asu != -1) { 394 dBm = -113 + (2 * asu); 395 } else { 396 dBm = -1; 397 } 398 if (DBG) log("getGsmDbm=" + dBm); 399 return dBm; 400 } 401 402 /** 403 * Get gsm as level 0..4 404 * 405 * @hide 406 */ 407 public int getGsmLevel() { 408 int level; 409 410 // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5 411 // asu = 0 (-113dB or less) is very weak 412 // signal, its better to show 0 bars to the user in such cases. 413 // asu = 99 is a special case, where the signal strength is unknown. 414 int asu = getGsmSignalStrength(); 415 if (asu <= 2 || asu == 99) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 416 else if (asu >= 12) level = SIGNAL_STRENGTH_GREAT; 417 else if (asu >= 8) level = SIGNAL_STRENGTH_GOOD; 418 else if (asu >= 5) level = SIGNAL_STRENGTH_MODERATE; 419 else level = SIGNAL_STRENGTH_POOR; 420 if (DBG) log("getGsmLevel=" + level); 421 return level; 422 } 423 424 /** 425 * Get the gsm signal level as an asu value between 0..31, 99 is unknown 426 * 427 * @hide 428 */ 429 public int getGsmAsuLevel() { 430 // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5 431 // asu = 0 (-113dB or less) is very weak 432 // signal, its better to show 0 bars to the user in such cases. 433 // asu = 99 is a special case, where the signal strength is unknown. 434 int level = getGsmSignalStrength(); 435 if (DBG) log("getGsmAsuLevel=" + level); 436 return level; 437 } 438 439 /** 440 * Get cdma as level 0..4 441 * 442 * @hide 443 */ 444 public int getCdmaLevel() { 445 final int cdmaDbm = getCdmaDbm(); 446 final int cdmaEcio = getCdmaEcio(); 447 int levelDbm; 448 int levelEcio; 449 450 if (cdmaDbm >= -75) levelDbm = SIGNAL_STRENGTH_GREAT; 451 else if (cdmaDbm >= -85) levelDbm = SIGNAL_STRENGTH_GOOD; 452 else if (cdmaDbm >= -95) levelDbm = SIGNAL_STRENGTH_MODERATE; 453 else if (cdmaDbm >= -100) levelDbm = SIGNAL_STRENGTH_POOR; 454 else levelDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 455 456 // Ec/Io are in dB*10 457 if (cdmaEcio >= -90) levelEcio = SIGNAL_STRENGTH_GREAT; 458 else if (cdmaEcio >= -110) levelEcio = SIGNAL_STRENGTH_GOOD; 459 else if (cdmaEcio >= -130) levelEcio = SIGNAL_STRENGTH_MODERATE; 460 else if (cdmaEcio >= -150) levelEcio = SIGNAL_STRENGTH_POOR; 461 else levelEcio = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 462 463 int level = (levelDbm < levelEcio) ? levelDbm : levelEcio; 464 if (DBG) log("getCdmaLevel=" + level); 465 return level; 466 } 467 468 /** 469 * Get the cdma signal level as an asu value between 0..31, 99 is unknown 470 * 471 * @hide 472 */ 473 public int getCdmaAsuLevel() { 474 final int cdmaDbm = getCdmaDbm(); 475 final int cdmaEcio = getCdmaEcio(); 476 int cdmaAsuLevel; 477 int ecioAsuLevel; 478 479 if (cdmaDbm >= -75) cdmaAsuLevel = 16; 480 else if (cdmaDbm >= -82) cdmaAsuLevel = 8; 481 else if (cdmaDbm >= -90) cdmaAsuLevel = 4; 482 else if (cdmaDbm >= -95) cdmaAsuLevel = 2; 483 else if (cdmaDbm >= -100) cdmaAsuLevel = 1; 484 else cdmaAsuLevel = 99; 485 486 // Ec/Io are in dB*10 487 if (cdmaEcio >= -90) ecioAsuLevel = 16; 488 else if (cdmaEcio >= -100) ecioAsuLevel = 8; 489 else if (cdmaEcio >= -115) ecioAsuLevel = 4; 490 else if (cdmaEcio >= -130) ecioAsuLevel = 2; 491 else if (cdmaEcio >= -150) ecioAsuLevel = 1; 492 else ecioAsuLevel = 99; 493 494 int level = (cdmaAsuLevel < ecioAsuLevel) ? cdmaAsuLevel : ecioAsuLevel; 495 if (DBG) log("getCdmaAsuLevel=" + level); 496 return level; 497 } 498 499 /** 500 * Get Evdo as level 0..4 501 * 502 * @hide 503 */ 504 public int getEvdoLevel() { 505 int evdoDbm = getEvdoDbm(); 506 int evdoSnr = getEvdoSnr(); 507 int levelEvdoDbm; 508 int levelEvdoSnr; 509 510 if (evdoDbm >= -65) levelEvdoDbm = SIGNAL_STRENGTH_GREAT; 511 else if (evdoDbm >= -75) levelEvdoDbm = SIGNAL_STRENGTH_GOOD; 512 else if (evdoDbm >= -90) levelEvdoDbm = SIGNAL_STRENGTH_MODERATE; 513 else if (evdoDbm >= -105) levelEvdoDbm = SIGNAL_STRENGTH_POOR; 514 else levelEvdoDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 515 516 if (evdoSnr >= 7) levelEvdoSnr = SIGNAL_STRENGTH_GREAT; 517 else if (evdoSnr >= 5) levelEvdoSnr = SIGNAL_STRENGTH_GOOD; 518 else if (evdoSnr >= 3) levelEvdoSnr = SIGNAL_STRENGTH_MODERATE; 519 else if (evdoSnr >= 1) levelEvdoSnr = SIGNAL_STRENGTH_POOR; 520 else levelEvdoSnr = SIGNAL_STRENGTH_NONE_OR_UNKNOWN; 521 522 int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr; 523 if (DBG) log("getEvdoLevel=" + level); 524 return level; 525 } 526 527 /** 528 * Get the evdo signal level as an asu value between 0..31, 99 is unknown 529 * 530 * @hide 531 */ 532 public int getEvdoAsuLevel() { 533 int evdoDbm = getEvdoDbm(); 534 int evdoSnr = getEvdoSnr(); 535 int levelEvdoDbm; 536 int levelEvdoSnr; 537 538 if (evdoDbm >= -65) levelEvdoDbm = 16; 539 else if (evdoDbm >= -75) levelEvdoDbm = 8; 540 else if (evdoDbm >= -85) levelEvdoDbm = 4; 541 else if (evdoDbm >= -95) levelEvdoDbm = 2; 542 else if (evdoDbm >= -105) levelEvdoDbm = 1; 543 else levelEvdoDbm = 99; 544 545 if (evdoSnr >= 7) levelEvdoSnr = 16; 546 else if (evdoSnr >= 6) levelEvdoSnr = 8; 547 else if (evdoSnr >= 5) levelEvdoSnr = 4; 548 else if (evdoSnr >= 3) levelEvdoSnr = 2; 549 else if (evdoSnr >= 1) levelEvdoSnr = 1; 550 else levelEvdoSnr = 99; 551 552 int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr; 553 if (DBG) log("getEvdoAsuLevel=" + level); 554 return level; 555 } 556 557 /** 558 * Get LTE as dBm 559 * 560 * @hide 561 */ 562 public int getLteDbm() { 563 return mLteRsrp; 564 } 565 566 /** 567 * Get LTE as level 0..4 568 * 569 * @hide 570 */ 571 public int getLteLevel() { 572 int levelLteRsrp = 0; 573 int levelLteRssnr = 0; 574 575 if (mLteRsrp == -1) levelLteRsrp = 0; 576 else if (mLteRsrp >= -95) levelLteRsrp = SIGNAL_STRENGTH_GREAT; 577 else if (mLteRsrp >= -105) levelLteRsrp = SIGNAL_STRENGTH_GOOD; 578 else if (mLteRsrp >= -115) levelLteRsrp = SIGNAL_STRENGTH_MODERATE; 579 else levelLteRsrp = SIGNAL_STRENGTH_POOR; 580 581 if (mLteRssnr == INVALID_SNR) levelLteRssnr = 0; 582 else if (mLteRssnr >= 45) levelLteRssnr = SIGNAL_STRENGTH_GREAT; 583 else if (mLteRssnr >= 10) levelLteRssnr = SIGNAL_STRENGTH_GOOD; 584 else if (mLteRssnr >= -30) levelLteRssnr = SIGNAL_STRENGTH_MODERATE; 585 else levelLteRssnr = SIGNAL_STRENGTH_POOR; 586 587 int level; 588 if (mLteRsrp == -1) 589 level = levelLteRssnr; 590 else if (mLteRssnr == INVALID_SNR) 591 level = levelLteRsrp; 592 else 593 level = (levelLteRssnr < levelLteRsrp) ? levelLteRssnr : levelLteRsrp; 594 595 if (DBG) log("Lte rsrp level: "+levelLteRsrp 596 + " snr level: " + levelLteRssnr + " level: " + level); 597 return level; 598 } 599 600 /** 601 * Get the LTE signal level as an asu value between 0..97, 99 is unknown 602 * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 603 * 604 * @hide 605 */ 606 public int getLteAsuLevel() { 607 int lteAsuLevel = 99; 608 int lteDbm = getLteDbm(); 609 if (lteDbm <= -140) lteAsuLevel = 0; 610 else if (lteDbm >= -43) lteAsuLevel = 97; 611 else lteAsuLevel = lteDbm + 140; 612 if (DBG) log("Lte Asu level: "+lteAsuLevel); 613 return lteAsuLevel; 614 } 615 616 /** 617 * @return true if this is for GSM 618 */ 619 public boolean isGsm() { 620 return this.isGsm; 621 } 622 623 /** 624 * @return hash code 625 */ 626 @Override 627 public int hashCode() { 628 int primeNum = 31; 629 return ((mGsmSignalStrength * primeNum) 630 + (mGsmBitErrorRate * primeNum) 631 + (mCdmaDbm * primeNum) + (mCdmaEcio * primeNum) 632 + (mEvdoDbm * primeNum) + (mEvdoEcio * primeNum) + (mEvdoSnr * primeNum) 633 + (mLteSignalStrength * primeNum) + (mLteRsrp * primeNum) 634 + (mLteRsrq * primeNum) + (mLteRssnr * primeNum) + (mLteCqi * primeNum) 635 + (isGsm ? 1 : 0)); 636 } 637 638 /** 639 * @return true if the signal strengths are the same 640 */ 641 @Override 642 public boolean equals (Object o) { 643 SignalStrength s; 644 645 try { 646 s = (SignalStrength) o; 647 } catch (ClassCastException ex) { 648 return false; 649 } 650 651 if (o == null) { 652 return false; 653 } 654 655 return (mGsmSignalStrength == s.mGsmSignalStrength 656 && mGsmBitErrorRate == s.mGsmBitErrorRate 657 && mCdmaDbm == s.mCdmaDbm 658 && mCdmaEcio == s.mCdmaEcio 659 && mEvdoDbm == s.mEvdoDbm 660 && mEvdoEcio == s.mEvdoEcio 661 && mEvdoSnr == s.mEvdoSnr 662 && mLteSignalStrength == s.mLteSignalStrength 663 && mLteRsrp == s.mLteRsrp 664 && mLteRsrq == s.mLteRsrq 665 && mLteRssnr == s.mLteRssnr 666 && mLteCqi == s.mLteCqi 667 && isGsm == s.isGsm); 668 } 669 670 /** 671 * @return string representation. 672 */ 673 @Override 674 public String toString() { 675 return ("SignalStrength:" 676 + " " + mGsmSignalStrength 677 + " " + mGsmBitErrorRate 678 + " " + mCdmaDbm 679 + " " + mCdmaEcio 680 + " " + mEvdoDbm 681 + " " + mEvdoEcio 682 + " " + mEvdoSnr 683 + " " + mLteSignalStrength 684 + " " + mLteRsrp 685 + " " + mLteRsrq 686 + " " + mLteRssnr 687 + " " + mLteCqi 688 + " " + (isGsm ? "gsm|lte" : "cdma")); 689 } 690 691 /** 692 * Set SignalStrength based on intent notifier map 693 * 694 * @param m intent notifier map 695 * @hide 696 */ 697 private void setFromNotifierBundle(Bundle m) { 698 mGsmSignalStrength = m.getInt("GsmSignalStrength"); 699 mGsmBitErrorRate = m.getInt("GsmBitErrorRate"); 700 mCdmaDbm = m.getInt("CdmaDbm"); 701 mCdmaEcio = m.getInt("CdmaEcio"); 702 mEvdoDbm = m.getInt("EvdoDbm"); 703 mEvdoEcio = m.getInt("EvdoEcio"); 704 mEvdoSnr = m.getInt("EvdoSnr"); 705 mLteSignalStrength = m.getInt("LteSignalStrength"); 706 mLteRsrp = m.getInt("LteRsrp"); 707 mLteRsrq = m.getInt("LteRsrq"); 708 mLteRssnr = m.getInt("LteRssnr"); 709 mLteCqi = m.getInt("LteCqi"); 710 isGsm = m.getBoolean("isGsm"); 711 } 712 713 /** 714 * Set intent notifier Bundle based on SignalStrength 715 * 716 * @param m intent notifier Bundle 717 * @hide 718 */ 719 public void fillInNotifierBundle(Bundle m) { 720 m.putInt("GsmSignalStrength", mGsmSignalStrength); 721 m.putInt("GsmBitErrorRate", mGsmBitErrorRate); 722 m.putInt("CdmaDbm", mCdmaDbm); 723 m.putInt("CdmaEcio", mCdmaEcio); 724 m.putInt("EvdoDbm", mEvdoDbm); 725 m.putInt("EvdoEcio", mEvdoEcio); 726 m.putInt("EvdoSnr", mEvdoSnr); 727 m.putInt("LteSignalStrength", mLteSignalStrength); 728 m.putInt("LteRsrp", mLteRsrp); 729 m.putInt("LteRsrq", mLteRsrq); 730 m.putInt("LteRssnr", mLteRssnr); 731 m.putInt("LteCqi", mLteCqi); 732 m.putBoolean("isGsm", Boolean.valueOf(isGsm)); 733 } 734 735 /** 736 * log 737 */ 738 private static void log(String s) { 739 Log.w(LOG_TAG, s); 740 } 741} 742