1 /* 2 * Copyright (C) 2006 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.os.Bundle; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 import android.telephony.Rlog; 23 import android.text.TextUtils; 24 25 /** 26 * Contains phone state and service related information. 27 * 28 * The following phone information is included in returned ServiceState: 29 * 30 * <ul> 31 * <li>Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF 32 * <li>Roaming indicator 33 * <li>Operator name, short name and numeric id 34 * <li>Network selection mode 35 * </ul> 36 */ 37 public class ServiceState implements Parcelable { 38 39 static final String LOG_TAG = "PHONE"; 40 static final boolean DBG = false; 41 static final boolean VDBG = false; // STOPSHIP if true 42 43 /** 44 * Normal operation condition, the phone is registered 45 * with an operator either in home network or in roaming. 46 */ 47 public static final int STATE_IN_SERVICE = 0; 48 49 /** 50 * Phone is not registered with any operator, the phone 51 * can be currently searching a new operator to register to, or not 52 * searching to registration at all, or registration is denied, or radio 53 * signal is not available. 54 */ 55 public static final int STATE_OUT_OF_SERVICE = 1; 56 57 /** 58 * The phone is registered and locked. Only emergency numbers are allowed. {@more} 59 */ 60 public static final int STATE_EMERGENCY_ONLY = 2; 61 62 /** 63 * Radio of telephony is explicitly powered off. 64 */ 65 public static final int STATE_POWER_OFF = 3; 66 67 /** 68 * RIL level registration state values from ril.h 69 * ((const char **)response)[0] is registration state 0-6, 70 * 0 - Not registered, MT is not currently searching 71 * a new operator to register 72 * 1 - Registered, home network 73 * 2 - Not registered, but MT is currently searching 74 * a new operator to register 75 * 3 - Registration denied 76 * 4 - Unknown 77 * 5 - Registered, roaming 78 * 10 - Same as 0, but indicates that emergency calls 79 * are enabled. 80 * 12 - Same as 2, but indicates that emergency calls 81 * are enabled. 82 * 13 - Same as 3, but indicates that emergency calls 83 * are enabled. 84 * 14 - Same as 4, but indicates that emergency calls 85 * are enabled. 86 * @hide 87 */ 88 public static final int RIL_REG_STATE_NOT_REG = 0; 89 /** @hide */ 90 public static final int RIL_REG_STATE_HOME = 1; 91 /** @hide */ 92 public static final int RIL_REG_STATE_SEARCHING = 2; 93 /** @hide */ 94 public static final int RIL_REG_STATE_DENIED = 3; 95 /** @hide */ 96 public static final int RIL_REG_STATE_UNKNOWN = 4; 97 /** @hide */ 98 public static final int RIL_REG_STATE_ROAMING = 5; 99 /** @hide */ 100 public static final int RIL_REG_STATE_NOT_REG_EMERGENCY_CALL_ENABLED = 10; 101 /** @hide */ 102 public static final int RIL_REG_STATE_SEARCHING_EMERGENCY_CALL_ENABLED = 12; 103 /** @hide */ 104 public static final int RIL_REG_STATE_DENIED_EMERGENCY_CALL_ENABLED = 13; 105 /** @hide */ 106 public static final int RIL_REG_STATE_UNKNOWN_EMERGENCY_CALL_ENABLED = 14; 107 108 /** 109 * Available radio technologies for GSM, UMTS and CDMA. 110 * Duplicates the constants from hardware/radio/include/ril.h 111 * This should only be used by agents working with the ril. Others 112 * should use the equivalent TelephonyManager.NETWORK_TYPE_* 113 */ 114 /** @hide */ 115 public static final int RIL_RADIO_TECHNOLOGY_UNKNOWN = 0; 116 /** @hide */ 117 public static final int RIL_RADIO_TECHNOLOGY_GPRS = 1; 118 /** @hide */ 119 public static final int RIL_RADIO_TECHNOLOGY_EDGE = 2; 120 /** @hide */ 121 public static final int RIL_RADIO_TECHNOLOGY_UMTS = 3; 122 /** @hide */ 123 public static final int RIL_RADIO_TECHNOLOGY_IS95A = 4; 124 /** @hide */ 125 public static final int RIL_RADIO_TECHNOLOGY_IS95B = 5; 126 /** @hide */ 127 public static final int RIL_RADIO_TECHNOLOGY_1xRTT = 6; 128 /** @hide */ 129 public static final int RIL_RADIO_TECHNOLOGY_EVDO_0 = 7; 130 /** @hide */ 131 public static final int RIL_RADIO_TECHNOLOGY_EVDO_A = 8; 132 /** @hide */ 133 public static final int RIL_RADIO_TECHNOLOGY_HSDPA = 9; 134 /** @hide */ 135 public static final int RIL_RADIO_TECHNOLOGY_HSUPA = 10; 136 /** @hide */ 137 public static final int RIL_RADIO_TECHNOLOGY_HSPA = 11; 138 /** @hide */ 139 public static final int RIL_RADIO_TECHNOLOGY_EVDO_B = 12; 140 /** @hide */ 141 public static final int RIL_RADIO_TECHNOLOGY_EHRPD = 13; 142 /** @hide */ 143 public static final int RIL_RADIO_TECHNOLOGY_LTE = 14; 144 /** @hide */ 145 public static final int RIL_RADIO_TECHNOLOGY_HSPAP = 15; 146 /** 147 * GSM radio technology only supports voice. It does not support data. 148 * @hide 149 */ 150 public static final int RIL_RADIO_TECHNOLOGY_GSM = 16; 151 /** @hide */ 152 public static final int RIL_RADIO_TECHNOLOGY_TD_SCDMA = 17; 153 /** 154 * IWLAN 155 * @hide 156 */ 157 public static final int RIL_RADIO_TECHNOLOGY_IWLAN = 18; 158 159 /** 160 * LTE_CA 161 * @hide 162 */ 163 public static final int RIL_RADIO_TECHNOLOGY_LTE_CA = 19; 164 165 /** @hide */ 166 public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK = 167 (1 << (RIL_RADIO_TECHNOLOGY_IS95A - 1)) 168 | (1 << (RIL_RADIO_TECHNOLOGY_IS95B - 1)) 169 | (1 << (RIL_RADIO_TECHNOLOGY_1xRTT - 1)) 170 | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_0 - 1)) 171 | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_A - 1)) 172 | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_B - 1)) 173 | (1 << (RIL_RADIO_TECHNOLOGY_EHRPD - 1)); 174 175 /** 176 * Available registration states for GSM, UMTS and CDMA. 177 */ 178 /** @hide */ 179 public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_NOT_SEARCHING = 0; 180 /** @hide */ 181 public static final int REGISTRATION_STATE_HOME_NETWORK = 1; 182 /** @hide */ 183 public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_SEARCHING = 2; 184 /** @hide */ 185 public static final int REGISTRATION_STATE_REGISTRATION_DENIED = 3; 186 /** @hide */ 187 public static final int REGISTRATION_STATE_UNKNOWN = 4; 188 /** @hide */ 189 public static final int REGISTRATION_STATE_ROAMING = 5; 190 191 private int mVoiceRegState = STATE_OUT_OF_SERVICE; 192 private int mDataRegState = STATE_OUT_OF_SERVICE; 193 194 /** 195 * Roaming type 196 * HOME : in home network 197 * @hide 198 */ 199 public static final int ROAMING_TYPE_NOT_ROAMING = 0; 200 /** 201 * Roaming type 202 * UNKNOWN : in a roaming network, but we can not tell if it's domestic or international 203 * @hide 204 */ 205 public static final int ROAMING_TYPE_UNKNOWN = 1; 206 /** 207 * Roaming type 208 * DOMESTIC : in domestic roaming network 209 * @hide 210 */ 211 public static final int ROAMING_TYPE_DOMESTIC = 2; 212 /** 213 * Roaming type 214 * INTERNATIONAL : in international roaming network 215 * @hide 216 */ 217 public static final int ROAMING_TYPE_INTERNATIONAL = 3; 218 219 private int mVoiceRoamingType; 220 private int mDataRoamingType; 221 private String mVoiceOperatorAlphaLong; 222 private String mVoiceOperatorAlphaShort; 223 private String mVoiceOperatorNumeric; 224 private String mDataOperatorAlphaLong; 225 private String mDataOperatorAlphaShort; 226 private String mDataOperatorNumeric; 227 private boolean mIsManualNetworkSelection; 228 229 private boolean mIsEmergencyOnly; 230 231 private int mRilVoiceRadioTechnology; 232 private int mRilDataRadioTechnology; 233 234 private boolean mCssIndicator; 235 private int mNetworkId; 236 private int mSystemId; 237 private int mCdmaRoamingIndicator; 238 private int mCdmaDefaultRoamingIndicator; 239 private int mCdmaEriIconIndex; 240 private int mCdmaEriIconMode; 241 242 private boolean mIsDataRoamingFromRegistration; 243 244 private boolean mIsUsingCarrierAggregation; 245 246 /* EARFCN stands for E-UTRA Absolute Radio Frequency Channel Number, 247 * Reference: 3GPP TS 36.104 5.4.3 */ 248 private int mLteEarfcnRsrpBoost = 0; 249 250 /** 251 * get String description of roaming type 252 * @hide 253 */ getRoamingLogString(int roamingType)254 public static final String getRoamingLogString(int roamingType) { 255 switch (roamingType) { 256 case ROAMING_TYPE_NOT_ROAMING: 257 return "home"; 258 259 case ROAMING_TYPE_UNKNOWN: 260 return "roaming"; 261 262 case ROAMING_TYPE_DOMESTIC: 263 return "Domestic Roaming"; 264 265 case ROAMING_TYPE_INTERNATIONAL: 266 return "International Roaming"; 267 268 default: 269 return "UNKNOWN"; 270 } 271 } 272 273 /** 274 * Create a new ServiceState from a intent notifier Bundle 275 * 276 * This method is used by PhoneStateIntentReceiver and maybe by 277 * external applications. 278 * 279 * @param m Bundle from intent notifier 280 * @return newly created ServiceState 281 * @hide 282 */ newFromBundle(Bundle m)283 public static ServiceState newFromBundle(Bundle m) { 284 ServiceState ret; 285 ret = new ServiceState(); 286 ret.setFromNotifierBundle(m); 287 return ret; 288 } 289 290 /** 291 * Empty constructor 292 */ ServiceState()293 public ServiceState() { 294 } 295 296 /** 297 * Copy constructors 298 * 299 * @param s Source service state 300 */ ServiceState(ServiceState s)301 public ServiceState(ServiceState s) { 302 copyFrom(s); 303 } 304 copyFrom(ServiceState s)305 protected void copyFrom(ServiceState s) { 306 mVoiceRegState = s.mVoiceRegState; 307 mDataRegState = s.mDataRegState; 308 mVoiceRoamingType = s.mVoiceRoamingType; 309 mDataRoamingType = s.mDataRoamingType; 310 mVoiceOperatorAlphaLong = s.mVoiceOperatorAlphaLong; 311 mVoiceOperatorAlphaShort = s.mVoiceOperatorAlphaShort; 312 mVoiceOperatorNumeric = s.mVoiceOperatorNumeric; 313 mDataOperatorAlphaLong = s.mDataOperatorAlphaLong; 314 mDataOperatorAlphaShort = s.mDataOperatorAlphaShort; 315 mDataOperatorNumeric = s.mDataOperatorNumeric; 316 mIsManualNetworkSelection = s.mIsManualNetworkSelection; 317 mRilVoiceRadioTechnology = s.mRilVoiceRadioTechnology; 318 mRilDataRadioTechnology = s.mRilDataRadioTechnology; 319 mCssIndicator = s.mCssIndicator; 320 mNetworkId = s.mNetworkId; 321 mSystemId = s.mSystemId; 322 mCdmaRoamingIndicator = s.mCdmaRoamingIndicator; 323 mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator; 324 mCdmaEriIconIndex = s.mCdmaEriIconIndex; 325 mCdmaEriIconMode = s.mCdmaEriIconMode; 326 mIsEmergencyOnly = s.mIsEmergencyOnly; 327 mIsDataRoamingFromRegistration = s.mIsDataRoamingFromRegistration; 328 mIsUsingCarrierAggregation = s.mIsUsingCarrierAggregation; 329 mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost; 330 } 331 332 /** 333 * Construct a ServiceState object from the given parcel. 334 */ ServiceState(Parcel in)335 public ServiceState(Parcel in) { 336 mVoiceRegState = in.readInt(); 337 mDataRegState = in.readInt(); 338 mVoiceRoamingType = in.readInt(); 339 mDataRoamingType = in.readInt(); 340 mVoiceOperatorAlphaLong = in.readString(); 341 mVoiceOperatorAlphaShort = in.readString(); 342 mVoiceOperatorNumeric = in.readString(); 343 mDataOperatorAlphaLong = in.readString(); 344 mDataOperatorAlphaShort = in.readString(); 345 mDataOperatorNumeric = in.readString(); 346 mIsManualNetworkSelection = in.readInt() != 0; 347 mRilVoiceRadioTechnology = in.readInt(); 348 mRilDataRadioTechnology = in.readInt(); 349 mCssIndicator = (in.readInt() != 0); 350 mNetworkId = in.readInt(); 351 mSystemId = in.readInt(); 352 mCdmaRoamingIndicator = in.readInt(); 353 mCdmaDefaultRoamingIndicator = in.readInt(); 354 mCdmaEriIconIndex = in.readInt(); 355 mCdmaEriIconMode = in.readInt(); 356 mIsEmergencyOnly = in.readInt() != 0; 357 mIsDataRoamingFromRegistration = in.readInt() != 0; 358 mIsUsingCarrierAggregation = in.readInt() != 0; 359 mLteEarfcnRsrpBoost = in.readInt(); 360 } 361 writeToParcel(Parcel out, int flags)362 public void writeToParcel(Parcel out, int flags) { 363 out.writeInt(mVoiceRegState); 364 out.writeInt(mDataRegState); 365 out.writeInt(mVoiceRoamingType); 366 out.writeInt(mDataRoamingType); 367 out.writeString(mVoiceOperatorAlphaLong); 368 out.writeString(mVoiceOperatorAlphaShort); 369 out.writeString(mVoiceOperatorNumeric); 370 out.writeString(mDataOperatorAlphaLong); 371 out.writeString(mDataOperatorAlphaShort); 372 out.writeString(mDataOperatorNumeric); 373 out.writeInt(mIsManualNetworkSelection ? 1 : 0); 374 out.writeInt(mRilVoiceRadioTechnology); 375 out.writeInt(mRilDataRadioTechnology); 376 out.writeInt(mCssIndicator ? 1 : 0); 377 out.writeInt(mNetworkId); 378 out.writeInt(mSystemId); 379 out.writeInt(mCdmaRoamingIndicator); 380 out.writeInt(mCdmaDefaultRoamingIndicator); 381 out.writeInt(mCdmaEriIconIndex); 382 out.writeInt(mCdmaEriIconMode); 383 out.writeInt(mIsEmergencyOnly ? 1 : 0); 384 out.writeInt(mIsDataRoamingFromRegistration ? 1 : 0); 385 out.writeInt(mIsUsingCarrierAggregation ? 1 : 0); 386 out.writeInt(mLteEarfcnRsrpBoost); 387 } 388 describeContents()389 public int describeContents() { 390 return 0; 391 } 392 393 public static final Parcelable.Creator<ServiceState> CREATOR = 394 new Parcelable.Creator<ServiceState>() { 395 public ServiceState createFromParcel(Parcel in) { 396 return new ServiceState(in); 397 } 398 399 public ServiceState[] newArray(int size) { 400 return new ServiceState[size]; 401 } 402 }; 403 404 /** 405 * Get current voice service state 406 */ getState()407 public int getState() { 408 return getVoiceRegState(); 409 } 410 411 /** 412 * Get current voice service state 413 * 414 * @see #STATE_IN_SERVICE 415 * @see #STATE_OUT_OF_SERVICE 416 * @see #STATE_EMERGENCY_ONLY 417 * @see #STATE_POWER_OFF 418 * 419 * @hide 420 */ getVoiceRegState()421 public int getVoiceRegState() { 422 return mVoiceRegState; 423 } 424 425 /** 426 * Get current data service state 427 * 428 * @see #STATE_IN_SERVICE 429 * @see #STATE_OUT_OF_SERVICE 430 * @see #STATE_EMERGENCY_ONLY 431 * @see #STATE_POWER_OFF 432 * 433 * @hide 434 */ getDataRegState()435 public int getDataRegState() { 436 return mDataRegState; 437 } 438 439 /** 440 * Get current roaming indicator of phone 441 * (note: not just decoding from TS 27.007 7.2) 442 * 443 * @return true if TS 27.007 7.2 roaming is true 444 * and ONS is different from SPN 445 */ getRoaming()446 public boolean getRoaming() { 447 return getVoiceRoaming() || getDataRoaming(); 448 } 449 450 /** 451 * Get current voice network roaming status 452 * @return roaming status 453 * @hide 454 */ getVoiceRoaming()455 public boolean getVoiceRoaming() { 456 return mVoiceRoamingType != ROAMING_TYPE_NOT_ROAMING; 457 } 458 459 /** 460 * Get current voice network roaming type 461 * @return roaming type 462 * @hide 463 */ getVoiceRoamingType()464 public int getVoiceRoamingType() { 465 return mVoiceRoamingType; 466 } 467 468 /** 469 * Get current data network roaming type 470 * @return roaming type 471 * @hide 472 */ getDataRoaming()473 public boolean getDataRoaming() { 474 return mDataRoamingType != ROAMING_TYPE_NOT_ROAMING; 475 } 476 477 /** 478 * Set whether data network registration state is roaming 479 * 480 * This should only be set to the roaming value received 481 * once the data registration phase has completed. 482 * @hide 483 */ setDataRoamingFromRegistration(boolean dataRoaming)484 public void setDataRoamingFromRegistration(boolean dataRoaming) { 485 mIsDataRoamingFromRegistration = dataRoaming; 486 } 487 488 /** 489 * Get whether data network registration state is roaming 490 * @return true if registration indicates roaming, false otherwise 491 * @hide 492 */ getDataRoamingFromRegistration()493 public boolean getDataRoamingFromRegistration() { 494 return mIsDataRoamingFromRegistration; 495 } 496 497 /** 498 * Get current data network roaming type 499 * @return roaming type 500 * @hide 501 */ getDataRoamingType()502 public int getDataRoamingType() { 503 return mDataRoamingType; 504 } 505 506 /** 507 * @hide 508 */ isEmergencyOnly()509 public boolean isEmergencyOnly() { 510 return mIsEmergencyOnly; 511 } 512 513 /** 514 * @hide 515 */ getCdmaRoamingIndicator()516 public int getCdmaRoamingIndicator(){ 517 return this.mCdmaRoamingIndicator; 518 } 519 520 /** 521 * @hide 522 */ getCdmaDefaultRoamingIndicator()523 public int getCdmaDefaultRoamingIndicator(){ 524 return this.mCdmaDefaultRoamingIndicator; 525 } 526 527 /** 528 * @hide 529 */ getCdmaEriIconIndex()530 public int getCdmaEriIconIndex() { 531 return this.mCdmaEriIconIndex; 532 } 533 534 /** 535 * @hide 536 */ getCdmaEriIconMode()537 public int getCdmaEriIconMode() { 538 return this.mCdmaEriIconMode; 539 } 540 541 /** 542 * Get current registered operator name in long alphanumeric format. 543 * 544 * In GSM/UMTS, long format can be up to 16 characters long. 545 * In CDMA, returns the ERI text, if set. Otherwise, returns the ONS. 546 * 547 * @return long name of operator, null if unregistered or unknown 548 */ getOperatorAlphaLong()549 public String getOperatorAlphaLong() { 550 return mVoiceOperatorAlphaLong; 551 } 552 553 /** 554 * Get current registered voice network operator name in long alphanumeric format. 555 * @return long name of operator 556 * @hide 557 */ getVoiceOperatorAlphaLong()558 public String getVoiceOperatorAlphaLong() { 559 return mVoiceOperatorAlphaLong; 560 } 561 562 /** 563 * Get current registered data network operator name in long alphanumeric format. 564 * @return long name of voice operator 565 * @hide 566 */ getDataOperatorAlphaLong()567 public String getDataOperatorAlphaLong() { 568 return mDataOperatorAlphaLong; 569 } 570 571 /** 572 * Get current registered operator name in short alphanumeric format. 573 * 574 * In GSM/UMTS, short format can be up to 8 characters long. 575 * 576 * @return short name of operator, null if unregistered or unknown 577 */ getOperatorAlphaShort()578 public String getOperatorAlphaShort() { 579 return mVoiceOperatorAlphaShort; 580 } 581 582 /** 583 * Get current registered voice network operator name in short alphanumeric format. 584 * @return short name of operator, null if unregistered or unknown 585 * @hide 586 */ getVoiceOperatorAlphaShort()587 public String getVoiceOperatorAlphaShort() { 588 return mVoiceOperatorAlphaShort; 589 } 590 591 /** 592 * Get current registered data network operator name in short alphanumeric format. 593 * @return short name of operator, null if unregistered or unknown 594 * @hide 595 */ getDataOperatorAlphaShort()596 public String getDataOperatorAlphaShort() { 597 return mDataOperatorAlphaShort; 598 } 599 600 /** 601 * Get current registered operator name in long alphanumeric format if 602 * available or short otherwise. 603 * 604 * @see #getOperatorAlphaLong 605 * @see #getOperatorAlphaShort 606 * 607 * @return name of operator, null if unregistered or unknown 608 * @hide 609 */ getOperatorAlpha()610 public String getOperatorAlpha() { 611 if (TextUtils.isEmpty(mVoiceOperatorAlphaLong)) { 612 return mVoiceOperatorAlphaShort; 613 } 614 615 return mVoiceOperatorAlphaLong; 616 } 617 618 /** 619 * Get current registered operator numeric id. 620 * 621 * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit 622 * network code. 623 * 624 * @return numeric format of operator, null if unregistered or unknown 625 */ 626 /* 627 * The country code can be decoded using 628 * {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}. 629 */ getOperatorNumeric()630 public String getOperatorNumeric() { 631 return mVoiceOperatorNumeric; 632 } 633 634 /** 635 * Get current registered voice network operator numeric id. 636 * @return numeric format of operator, null if unregistered or unknown 637 * @hide 638 */ getVoiceOperatorNumeric()639 public String getVoiceOperatorNumeric() { 640 return mVoiceOperatorNumeric; 641 } 642 643 /** 644 * Get current registered data network operator numeric id. 645 * @return numeric format of operator, null if unregistered or unknown 646 * @hide 647 */ getDataOperatorNumeric()648 public String getDataOperatorNumeric() { 649 return mDataOperatorNumeric; 650 } 651 652 /** 653 * Get current network selection mode. 654 * 655 * @return true if manual mode, false if automatic mode 656 */ getIsManualSelection()657 public boolean getIsManualSelection() { 658 return mIsManualNetworkSelection; 659 } 660 661 @Override hashCode()662 public int hashCode() { 663 return ((mVoiceRegState * 31) 664 + (mDataRegState * 37) 665 + mVoiceRoamingType 666 + mDataRoamingType 667 + (mIsManualNetworkSelection ? 1 : 0) 668 + ((null == mVoiceOperatorAlphaLong) ? 0 : mVoiceOperatorAlphaLong.hashCode()) 669 + ((null == mVoiceOperatorAlphaShort) ? 0 : mVoiceOperatorAlphaShort.hashCode()) 670 + ((null == mVoiceOperatorNumeric) ? 0 : mVoiceOperatorNumeric.hashCode()) 671 + ((null == mDataOperatorAlphaLong) ? 0 : mDataOperatorAlphaLong.hashCode()) 672 + ((null == mDataOperatorAlphaShort) ? 0 : mDataOperatorAlphaShort.hashCode()) 673 + ((null == mDataOperatorNumeric) ? 0 : mDataOperatorNumeric.hashCode()) 674 + mCdmaRoamingIndicator 675 + mCdmaDefaultRoamingIndicator 676 + (mIsEmergencyOnly ? 1 : 0) 677 + (mIsDataRoamingFromRegistration ? 1 : 0)); 678 } 679 680 @Override equals(Object o)681 public boolean equals (Object o) { 682 ServiceState s; 683 684 try { 685 s = (ServiceState) o; 686 } catch (ClassCastException ex) { 687 return false; 688 } 689 690 if (o == null) { 691 return false; 692 } 693 694 return (mVoiceRegState == s.mVoiceRegState 695 && mDataRegState == s.mDataRegState 696 && mIsManualNetworkSelection == s.mIsManualNetworkSelection 697 && mVoiceRoamingType == s.mVoiceRoamingType 698 && mDataRoamingType == s.mDataRoamingType 699 && equalsHandlesNulls(mVoiceOperatorAlphaLong, s.mVoiceOperatorAlphaLong) 700 && equalsHandlesNulls(mVoiceOperatorAlphaShort, s.mVoiceOperatorAlphaShort) 701 && equalsHandlesNulls(mVoiceOperatorNumeric, s.mVoiceOperatorNumeric) 702 && equalsHandlesNulls(mDataOperatorAlphaLong, s.mDataOperatorAlphaLong) 703 && equalsHandlesNulls(mDataOperatorAlphaShort, s.mDataOperatorAlphaShort) 704 && equalsHandlesNulls(mDataOperatorNumeric, s.mDataOperatorNumeric) 705 && equalsHandlesNulls(mRilVoiceRadioTechnology, s.mRilVoiceRadioTechnology) 706 && equalsHandlesNulls(mRilDataRadioTechnology, s.mRilDataRadioTechnology) 707 && equalsHandlesNulls(mCssIndicator, s.mCssIndicator) 708 && equalsHandlesNulls(mNetworkId, s.mNetworkId) 709 && equalsHandlesNulls(mSystemId, s.mSystemId) 710 && equalsHandlesNulls(mCdmaRoamingIndicator, s.mCdmaRoamingIndicator) 711 && equalsHandlesNulls(mCdmaDefaultRoamingIndicator, 712 s.mCdmaDefaultRoamingIndicator) 713 && mIsEmergencyOnly == s.mIsEmergencyOnly 714 && mIsDataRoamingFromRegistration == s.mIsDataRoamingFromRegistration 715 && mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation); 716 } 717 718 /** 719 * Convert radio technology to String 720 * 721 * @param radioTechnology 722 * @return String representation of the RAT 723 * 724 * @hide 725 */ rilRadioTechnologyToString(int rt)726 public static String rilRadioTechnologyToString(int rt) { 727 String rtString; 728 729 switch(rt) { 730 case RIL_RADIO_TECHNOLOGY_UNKNOWN: 731 rtString = "Unknown"; 732 break; 733 case RIL_RADIO_TECHNOLOGY_GPRS: 734 rtString = "GPRS"; 735 break; 736 case RIL_RADIO_TECHNOLOGY_EDGE: 737 rtString = "EDGE"; 738 break; 739 case RIL_RADIO_TECHNOLOGY_UMTS: 740 rtString = "UMTS"; 741 break; 742 case RIL_RADIO_TECHNOLOGY_IS95A: 743 rtString = "CDMA-IS95A"; 744 break; 745 case RIL_RADIO_TECHNOLOGY_IS95B: 746 rtString = "CDMA-IS95B"; 747 break; 748 case RIL_RADIO_TECHNOLOGY_1xRTT: 749 rtString = "1xRTT"; 750 break; 751 case RIL_RADIO_TECHNOLOGY_EVDO_0: 752 rtString = "EvDo-rev.0"; 753 break; 754 case RIL_RADIO_TECHNOLOGY_EVDO_A: 755 rtString = "EvDo-rev.A"; 756 break; 757 case RIL_RADIO_TECHNOLOGY_HSDPA: 758 rtString = "HSDPA"; 759 break; 760 case RIL_RADIO_TECHNOLOGY_HSUPA: 761 rtString = "HSUPA"; 762 break; 763 case RIL_RADIO_TECHNOLOGY_HSPA: 764 rtString = "HSPA"; 765 break; 766 case RIL_RADIO_TECHNOLOGY_EVDO_B: 767 rtString = "EvDo-rev.B"; 768 break; 769 case RIL_RADIO_TECHNOLOGY_EHRPD: 770 rtString = "eHRPD"; 771 break; 772 case RIL_RADIO_TECHNOLOGY_LTE: 773 rtString = "LTE"; 774 break; 775 case RIL_RADIO_TECHNOLOGY_HSPAP: 776 rtString = "HSPAP"; 777 break; 778 case RIL_RADIO_TECHNOLOGY_GSM: 779 rtString = "GSM"; 780 break; 781 case RIL_RADIO_TECHNOLOGY_IWLAN: 782 rtString = "IWLAN"; 783 break; 784 case RIL_RADIO_TECHNOLOGY_TD_SCDMA: 785 rtString = "TD-SCDMA"; 786 break; 787 case RIL_RADIO_TECHNOLOGY_LTE_CA: 788 rtString = "LTE_CA"; 789 break; 790 default: 791 rtString = "Unexpected"; 792 Rlog.w(LOG_TAG, "Unexpected radioTechnology=" + rt); 793 break; 794 } 795 return rtString; 796 } 797 798 @Override toString()799 public String toString() { 800 String radioTechnology = rilRadioTechnologyToString(mRilVoiceRadioTechnology); 801 String dataRadioTechnology = rilRadioTechnologyToString(mRilDataRadioTechnology); 802 803 return (mVoiceRegState + " " + mDataRegState 804 + " " 805 + "voice " + getRoamingLogString(mVoiceRoamingType) 806 + " " 807 + "data " + getRoamingLogString(mDataRoamingType) 808 + " " + mVoiceOperatorAlphaLong 809 + " " + mVoiceOperatorAlphaShort 810 + " " + mVoiceOperatorNumeric 811 + " " + mDataOperatorAlphaLong 812 + " " + mDataOperatorAlphaShort 813 + " " + mDataOperatorNumeric 814 + " " + (mIsManualNetworkSelection ? "(manual)" : "") 815 + " " + radioTechnology 816 + " " + dataRadioTechnology 817 + " " + (mCssIndicator ? "CSS supported" : "CSS not supported") 818 + " " + mNetworkId 819 + " " + mSystemId 820 + " RoamInd=" + mCdmaRoamingIndicator 821 + " DefRoamInd=" + mCdmaDefaultRoamingIndicator 822 + " EmergOnly=" + mIsEmergencyOnly 823 + " IsDataRoamingFromRegistration=" + mIsDataRoamingFromRegistration 824 + " IsUsingCarrierAggregation=" + mIsUsingCarrierAggregation 825 + " mLteEarfcnRsrpBoost=" + mLteEarfcnRsrpBoost); 826 } 827 setNullState(int state)828 private void setNullState(int state) { 829 if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setNullState=" + state); 830 mVoiceRegState = state; 831 mDataRegState = state; 832 mVoiceRoamingType = ROAMING_TYPE_NOT_ROAMING; 833 mDataRoamingType = ROAMING_TYPE_NOT_ROAMING; 834 mVoiceOperatorAlphaLong = null; 835 mVoiceOperatorAlphaShort = null; 836 mVoiceOperatorNumeric = null; 837 mDataOperatorAlphaLong = null; 838 mDataOperatorAlphaShort = null; 839 mDataOperatorNumeric = null; 840 mIsManualNetworkSelection = false; 841 mRilVoiceRadioTechnology = 0; 842 mRilDataRadioTechnology = 0; 843 mCssIndicator = false; 844 mNetworkId = -1; 845 mSystemId = -1; 846 mCdmaRoamingIndicator = -1; 847 mCdmaDefaultRoamingIndicator = -1; 848 mCdmaEriIconIndex = -1; 849 mCdmaEriIconMode = -1; 850 mIsEmergencyOnly = false; 851 mIsDataRoamingFromRegistration = false; 852 mIsUsingCarrierAggregation = false; 853 mLteEarfcnRsrpBoost = 0; 854 } 855 setStateOutOfService()856 public void setStateOutOfService() { 857 setNullState(STATE_OUT_OF_SERVICE); 858 } 859 setStateOff()860 public void setStateOff() { 861 setNullState(STATE_POWER_OFF); 862 } 863 setState(int state)864 public void setState(int state) { 865 setVoiceRegState(state); 866 if (DBG) Rlog.e(LOG_TAG, "[ServiceState] setState deprecated use setVoiceRegState()"); 867 } 868 869 /** @hide */ setVoiceRegState(int state)870 public void setVoiceRegState(int state) { 871 mVoiceRegState = state; 872 if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setVoiceRegState=" + mVoiceRegState); 873 } 874 875 /** @hide */ setDataRegState(int state)876 public void setDataRegState(int state) { 877 mDataRegState = state; 878 if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRegState=" + mDataRegState); 879 } 880 setRoaming(boolean roaming)881 public void setRoaming(boolean roaming) { 882 mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); 883 mDataRoamingType = mVoiceRoamingType; 884 } 885 886 /** @hide */ setVoiceRoaming(boolean roaming)887 public void setVoiceRoaming(boolean roaming) { 888 mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); 889 } 890 891 /** @hide */ setVoiceRoamingType(int type)892 public void setVoiceRoamingType(int type) { 893 mVoiceRoamingType = type; 894 } 895 896 /** @hide */ setDataRoaming(boolean dataRoaming)897 public void setDataRoaming(boolean dataRoaming) { 898 mDataRoamingType = (dataRoaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); 899 } 900 901 /** @hide */ setDataRoamingType(int type)902 public void setDataRoamingType(int type) { 903 mDataRoamingType = type; 904 } 905 906 /** 907 * @hide 908 */ setEmergencyOnly(boolean emergencyOnly)909 public void setEmergencyOnly(boolean emergencyOnly) { 910 mIsEmergencyOnly = emergencyOnly; 911 } 912 913 /** 914 * @hide 915 */ setCdmaRoamingIndicator(int roaming)916 public void setCdmaRoamingIndicator(int roaming) { 917 this.mCdmaRoamingIndicator = roaming; 918 } 919 920 /** 921 * @hide 922 */ setCdmaDefaultRoamingIndicator(int roaming)923 public void setCdmaDefaultRoamingIndicator (int roaming) { 924 this.mCdmaDefaultRoamingIndicator = roaming; 925 } 926 927 /** 928 * @hide 929 */ setCdmaEriIconIndex(int index)930 public void setCdmaEriIconIndex(int index) { 931 this.mCdmaEriIconIndex = index; 932 } 933 934 /** 935 * @hide 936 */ setCdmaEriIconMode(int mode)937 public void setCdmaEriIconMode(int mode) { 938 this.mCdmaEriIconMode = mode; 939 } 940 setOperatorName(String longName, String shortName, String numeric)941 public void setOperatorName(String longName, String shortName, String numeric) { 942 mVoiceOperatorAlphaLong = longName; 943 mVoiceOperatorAlphaShort = shortName; 944 mVoiceOperatorNumeric = numeric; 945 mDataOperatorAlphaLong = longName; 946 mDataOperatorAlphaShort = shortName; 947 mDataOperatorNumeric = numeric; 948 } 949 950 /** @hide */ setVoiceOperatorName(String longName, String shortName, String numeric)951 public void setVoiceOperatorName(String longName, String shortName, String numeric) { 952 mVoiceOperatorAlphaLong = longName; 953 mVoiceOperatorAlphaShort = shortName; 954 mVoiceOperatorNumeric = numeric; 955 } 956 957 /** @hide */ setDataOperatorName(String longName, String shortName, String numeric)958 public void setDataOperatorName(String longName, String shortName, String numeric) { 959 mDataOperatorAlphaLong = longName; 960 mDataOperatorAlphaShort = shortName; 961 mDataOperatorNumeric = numeric; 962 } 963 964 /** 965 * In CDMA, mOperatorAlphaLong can be set from the ERI text. 966 * This is done from the GsmCdmaPhone and not from the ServiceStateTracker. 967 * 968 * @hide 969 */ setOperatorAlphaLong(String longName)970 public void setOperatorAlphaLong(String longName) { 971 mVoiceOperatorAlphaLong = longName; 972 mDataOperatorAlphaLong = longName; 973 } 974 975 /** @hide */ setVoiceOperatorAlphaLong(String longName)976 public void setVoiceOperatorAlphaLong(String longName) { 977 mVoiceOperatorAlphaLong = longName; 978 } 979 980 /** @hide */ setDataOperatorAlphaLong(String longName)981 public void setDataOperatorAlphaLong(String longName) { 982 mDataOperatorAlphaLong = longName; 983 } 984 setIsManualSelection(boolean isManual)985 public void setIsManualSelection(boolean isManual) { 986 mIsManualNetworkSelection = isManual; 987 } 988 989 /** 990 * Test whether two objects hold the same data values or both are null. 991 * 992 * @param a first obj 993 * @param b second obj 994 * @return true if two objects equal or both are null 995 */ equalsHandlesNulls(Object a, Object b)996 private static boolean equalsHandlesNulls (Object a, Object b) { 997 return (a == null) ? (b == null) : a.equals (b); 998 } 999 1000 /** 1001 * Set ServiceState based on intent notifier map. 1002 * 1003 * @param m intent notifier map 1004 * @hide 1005 */ setFromNotifierBundle(Bundle m)1006 private void setFromNotifierBundle(Bundle m) { 1007 mVoiceRegState = m.getInt("voiceRegState"); 1008 mDataRegState = m.getInt("dataRegState"); 1009 mVoiceRoamingType = m.getInt("voiceRoamingType"); 1010 mDataRoamingType = m.getInt("dataRoamingType"); 1011 mVoiceOperatorAlphaLong = m.getString("operator-alpha-long"); 1012 mVoiceOperatorAlphaShort = m.getString("operator-alpha-short"); 1013 mVoiceOperatorNumeric = m.getString("operator-numeric"); 1014 mDataOperatorAlphaLong = m.getString("data-operator-alpha-long"); 1015 mDataOperatorAlphaShort = m.getString("data-operator-alpha-short"); 1016 mDataOperatorNumeric = m.getString("data-operator-numeric"); 1017 mIsManualNetworkSelection = m.getBoolean("manual"); 1018 mRilVoiceRadioTechnology = m.getInt("radioTechnology"); 1019 mRilDataRadioTechnology = m.getInt("dataRadioTechnology"); 1020 mCssIndicator = m.getBoolean("cssIndicator"); 1021 mNetworkId = m.getInt("networkId"); 1022 mSystemId = m.getInt("systemId"); 1023 mCdmaRoamingIndicator = m.getInt("cdmaRoamingIndicator"); 1024 mCdmaDefaultRoamingIndicator = m.getInt("cdmaDefaultRoamingIndicator"); 1025 mIsEmergencyOnly = m.getBoolean("emergencyOnly"); 1026 mIsDataRoamingFromRegistration = m.getBoolean("isDataRoamingFromRegistration"); 1027 mIsUsingCarrierAggregation = m.getBoolean("isUsingCarrierAggregation"); 1028 mLteEarfcnRsrpBoost = m.getInt("LteEarfcnRsrpBoost"); 1029 } 1030 1031 /** 1032 * Set intent notifier Bundle based on service state. 1033 * 1034 * @param m intent notifier Bundle 1035 * @hide 1036 */ fillInNotifierBundle(Bundle m)1037 public void fillInNotifierBundle(Bundle m) { 1038 m.putInt("voiceRegState", mVoiceRegState); 1039 m.putInt("dataRegState", mDataRegState); 1040 m.putInt("voiceRoamingType", mVoiceRoamingType); 1041 m.putInt("dataRoamingType", mDataRoamingType); 1042 m.putString("operator-alpha-long", mVoiceOperatorAlphaLong); 1043 m.putString("operator-alpha-short", mVoiceOperatorAlphaShort); 1044 m.putString("operator-numeric", mVoiceOperatorNumeric); 1045 m.putString("data-operator-alpha-long", mDataOperatorAlphaLong); 1046 m.putString("data-operator-alpha-short", mDataOperatorAlphaShort); 1047 m.putString("data-operator-numeric", mDataOperatorNumeric); 1048 m.putBoolean("manual", mIsManualNetworkSelection); 1049 m.putInt("radioTechnology", mRilVoiceRadioTechnology); 1050 m.putInt("dataRadioTechnology", mRilDataRadioTechnology); 1051 m.putBoolean("cssIndicator", mCssIndicator); 1052 m.putInt("networkId", mNetworkId); 1053 m.putInt("systemId", mSystemId); 1054 m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator); 1055 m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator); 1056 m.putBoolean("emergencyOnly", mIsEmergencyOnly); 1057 m.putBoolean("isDataRoamingFromRegistration", mIsDataRoamingFromRegistration); 1058 m.putBoolean("isUsingCarrierAggregation", mIsUsingCarrierAggregation); 1059 m.putInt("LteEarfcnRsrpBoost", mLteEarfcnRsrpBoost); 1060 } 1061 1062 /** @hide */ setRilVoiceRadioTechnology(int rt)1063 public void setRilVoiceRadioTechnology(int rt) { 1064 if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) { 1065 rt = RIL_RADIO_TECHNOLOGY_LTE; 1066 } 1067 1068 this.mRilVoiceRadioTechnology = rt; 1069 } 1070 1071 /** @hide */ setRilDataRadioTechnology(int rt)1072 public void setRilDataRadioTechnology(int rt) { 1073 if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) { 1074 rt = RIL_RADIO_TECHNOLOGY_LTE; 1075 this.mIsUsingCarrierAggregation = true; 1076 } else { 1077 this.mIsUsingCarrierAggregation = false; 1078 } 1079 this.mRilDataRadioTechnology = rt; 1080 if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setRilDataRadioTechnology=" + 1081 mRilDataRadioTechnology); 1082 } 1083 1084 /** @hide */ isUsingCarrierAggregation()1085 public boolean isUsingCarrierAggregation() { 1086 return mIsUsingCarrierAggregation; 1087 } 1088 1089 /** @hide */ setIsUsingCarrierAggregation(boolean ca)1090 public void setIsUsingCarrierAggregation(boolean ca) { 1091 mIsUsingCarrierAggregation = ca; 1092 } 1093 1094 /** @hide */ getLteEarfcnRsrpBoost()1095 public int getLteEarfcnRsrpBoost() { 1096 return mLteEarfcnRsrpBoost; 1097 } 1098 1099 /** @hide */ setLteEarfcnRsrpBoost(int LteEarfcnRsrpBoost)1100 public void setLteEarfcnRsrpBoost(int LteEarfcnRsrpBoost) { 1101 mLteEarfcnRsrpBoost = LteEarfcnRsrpBoost; 1102 } 1103 1104 /** @hide */ setCssIndicator(int css)1105 public void setCssIndicator(int css) { 1106 this.mCssIndicator = (css != 0); 1107 } 1108 1109 /** @hide */ setSystemAndNetworkId(int systemId, int networkId)1110 public void setSystemAndNetworkId(int systemId, int networkId) { 1111 this.mSystemId = systemId; 1112 this.mNetworkId = networkId; 1113 } 1114 1115 /** @hide */ getRilVoiceRadioTechnology()1116 public int getRilVoiceRadioTechnology() { 1117 return this.mRilVoiceRadioTechnology; 1118 } 1119 /** @hide */ getRilDataRadioTechnology()1120 public int getRilDataRadioTechnology() { 1121 return this.mRilDataRadioTechnology; 1122 } 1123 /** 1124 * @hide 1125 * @Deprecated to be removed Q3 2013 use {@link #getRilDataRadioTechnology} or 1126 * {@link #getRilVoiceRadioTechnology} 1127 */ getRadioTechnology()1128 public int getRadioTechnology() { 1129 Rlog.e(LOG_TAG, "ServiceState.getRadioTechnology() DEPRECATED will be removed *******"); 1130 return getRilDataRadioTechnology(); 1131 } 1132 rilRadioTechnologyToNetworkType(int rt)1133 private int rilRadioTechnologyToNetworkType(int rt) { 1134 switch(rt) { 1135 case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: 1136 return TelephonyManager.NETWORK_TYPE_GPRS; 1137 case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE: 1138 return TelephonyManager.NETWORK_TYPE_EDGE; 1139 case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: 1140 return TelephonyManager.NETWORK_TYPE_UMTS; 1141 case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: 1142 return TelephonyManager.NETWORK_TYPE_HSDPA; 1143 case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: 1144 return TelephonyManager.NETWORK_TYPE_HSUPA; 1145 case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: 1146 return TelephonyManager.NETWORK_TYPE_HSPA; 1147 case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A: 1148 case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B: 1149 return TelephonyManager.NETWORK_TYPE_CDMA; 1150 case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT: 1151 return TelephonyManager.NETWORK_TYPE_1xRTT; 1152 case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0: 1153 return TelephonyManager.NETWORK_TYPE_EVDO_0; 1154 case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A: 1155 return TelephonyManager.NETWORK_TYPE_EVDO_A; 1156 case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B: 1157 return TelephonyManager.NETWORK_TYPE_EVDO_B; 1158 case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD: 1159 return TelephonyManager.NETWORK_TYPE_EHRPD; 1160 case ServiceState.RIL_RADIO_TECHNOLOGY_LTE: 1161 return TelephonyManager.NETWORK_TYPE_LTE; 1162 case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: 1163 return TelephonyManager.NETWORK_TYPE_HSPAP; 1164 case ServiceState.RIL_RADIO_TECHNOLOGY_GSM: 1165 return TelephonyManager.NETWORK_TYPE_GSM; 1166 case ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA: 1167 return TelephonyManager.NETWORK_TYPE_TD_SCDMA; 1168 case ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN: 1169 return TelephonyManager.NETWORK_TYPE_IWLAN; 1170 case ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA: 1171 return TelephonyManager.NETWORK_TYPE_LTE_CA; 1172 default: 1173 return TelephonyManager.NETWORK_TYPE_UNKNOWN; 1174 } 1175 } 1176 1177 /** 1178 * @Deprecated to be removed Q3 2013 use {@link #getVoiceNetworkType} 1179 * @hide 1180 */ getNetworkType()1181 public int getNetworkType() { 1182 Rlog.e(LOG_TAG, "ServiceState.getNetworkType() DEPRECATED will be removed *******"); 1183 return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology); 1184 } 1185 1186 /** @hide */ getDataNetworkType()1187 public int getDataNetworkType() { 1188 return rilRadioTechnologyToNetworkType(mRilDataRadioTechnology); 1189 } 1190 1191 /** @hide */ getVoiceNetworkType()1192 public int getVoiceNetworkType() { 1193 return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology); 1194 } 1195 1196 /** @hide */ getCssIndicator()1197 public int getCssIndicator() { 1198 return this.mCssIndicator ? 1 : 0; 1199 } 1200 1201 /** @hide */ getNetworkId()1202 public int getNetworkId() { 1203 return this.mNetworkId; 1204 } 1205 1206 /** @hide */ getSystemId()1207 public int getSystemId() { 1208 return this.mSystemId; 1209 } 1210 1211 /** @hide */ isGsm(int radioTechnology)1212 public static boolean isGsm(int radioTechnology) { 1213 return radioTechnology == RIL_RADIO_TECHNOLOGY_GPRS 1214 || radioTechnology == RIL_RADIO_TECHNOLOGY_EDGE 1215 || radioTechnology == RIL_RADIO_TECHNOLOGY_UMTS 1216 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSDPA 1217 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSUPA 1218 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPA 1219 || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE 1220 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP 1221 || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM 1222 || radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA 1223 || radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN 1224 || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA; 1225 1226 } 1227 1228 /** @hide */ isCdma(int radioTechnology)1229 public static boolean isCdma(int radioTechnology) { 1230 return radioTechnology == RIL_RADIO_TECHNOLOGY_IS95A 1231 || radioTechnology == RIL_RADIO_TECHNOLOGY_IS95B 1232 || radioTechnology == RIL_RADIO_TECHNOLOGY_1xRTT 1233 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_0 1234 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_A 1235 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B 1236 || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD; 1237 } 1238 1239 /** @hide */ isLte(int radioTechnology)1240 public static boolean isLte(int radioTechnology) { 1241 return radioTechnology == RIL_RADIO_TECHNOLOGY_LTE || 1242 radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA; 1243 } 1244 1245 /** @hide */ bearerBitmapHasCdma(int radioTechnologyBitmap)1246 public static boolean bearerBitmapHasCdma(int radioTechnologyBitmap) { 1247 return (RIL_RADIO_CDMA_TECHNOLOGY_BITMASK & radioTechnologyBitmap) != 0; 1248 } 1249 1250 /** @hide */ bitmaskHasTech(int bearerBitmask, int radioTech)1251 public static boolean bitmaskHasTech(int bearerBitmask, int radioTech) { 1252 if (bearerBitmask == 0) { 1253 return true; 1254 } else if (radioTech >= 1) { 1255 return ((bearerBitmask & (1 << (radioTech - 1))) != 0); 1256 } 1257 return false; 1258 } 1259 1260 /** @hide */ getBitmaskForTech(int radioTech)1261 public static int getBitmaskForTech(int radioTech) { 1262 if (radioTech >= 1) { 1263 return (1 << (radioTech - 1)); 1264 } 1265 return 0; 1266 } 1267 1268 /** @hide */ getBitmaskFromString(String bearerList)1269 public static int getBitmaskFromString(String bearerList) { 1270 String[] bearers = bearerList.split("\\|"); 1271 int bearerBitmask = 0; 1272 for (String bearer : bearers) { 1273 int bearerInt = 0; 1274 try { 1275 bearerInt = Integer.parseInt(bearer.trim()); 1276 } catch (NumberFormatException nfe) { 1277 return 0; 1278 } 1279 1280 if (bearerInt == 0) { 1281 return 0; 1282 } 1283 1284 bearerBitmask |= getBitmaskForTech(bearerInt); 1285 } 1286 return bearerBitmask; 1287 } 1288 1289 /** 1290 * Returns a merged ServiceState consisting of the base SS with voice settings from the 1291 * voice SS. The voice SS is only used if it is IN_SERVICE (otherwise the base SS is returned). 1292 * @hide 1293 * */ mergeServiceStates(ServiceState baseSs, ServiceState voiceSs)1294 public static ServiceState mergeServiceStates(ServiceState baseSs, ServiceState voiceSs) { 1295 if (voiceSs.mVoiceRegState != STATE_IN_SERVICE) { 1296 return baseSs; 1297 } 1298 1299 ServiceState newSs = new ServiceState(baseSs); 1300 1301 // voice overrides 1302 newSs.mVoiceRegState = voiceSs.mVoiceRegState; 1303 newSs.mIsEmergencyOnly = false; // only get here if voice is IN_SERVICE 1304 1305 return newSs; 1306 } 1307 } 1308