Skip to content Skip to sidebar Skip to footer

What Is The Value Of Sim State When "airplane Mode" Is Turned On

I wonder what is the value of SIM state returned by TelephonyManager.getSimState() when 'airplane mode' is turned on? This seems to be not directly specified anywhere in the SDK sp

Solution 1:

After searching Android 4.1 sources I found the following code in one of the private classes com.android.internal.telephony.IccCard:

public State getState() {
  if (mState == null) {
      switch(mPhone.mCM.getRadioState()) {
          /* This switch block must not return anything in
           * State.isLocked() or State.ABSENT.
           * If it does, handleSimStatus() may break
           */case RADIO_OFF:
          case RADIO_UNAVAILABLE:
          case SIM_NOT_READY:
          case RUIM_NOT_READY:
              return State.UNKNOWN;
          case SIM_LOCKED_OR_ABSENT:
          case RUIM_LOCKED_OR_ABSENT:
              //this should be transient-onlyreturn State.UNKNOWN;
          case SIM_READY:
          case RUIM_READY:
          case NV_READY:
              return State.READY;
          case NV_NOT_READY:
              return State.ABSENT;
      }
  } else {
      return mState;
  }

  Log.e(mLogTag, "IccCard.getState(): case should never be reached");
  return State.UNKNOWN;
}  

So State.UNKNOWN would be returned whenever radio state is one of RADIO_OFF or RADIO_UNAVAILABLE. Then State.UNKNOWN will be converted to SIM_STATE_UNKNOWN constant by TelephonyManager.getSimState() method.

As the conclusion: when airplane mode is turned on getSimState will return SIM_STATE_UNKNOWN.

Solution 2:

yes, this is the common behavior on android phones. see the implementation of the getSimState() method from the TelephonyManager class:

publicintgetSimState() {
    String prop = SystemProperties.get(TelephonyProperties.PROPERTY_SIM_STATE);
    if ("ABSENT".equals(prop)) {
        return SIM_STATE_ABSENT;
    }
    elseif ("PIN_REQUIRED".equals(prop)) {
        return SIM_STATE_PIN_REQUIRED;
    }
    elseif ("PUK_REQUIRED".equals(prop)) {
        return SIM_STATE_PUK_REQUIRED;
    }
    elseif ("NETWORK_LOCKED".equals(prop)) {
        return SIM_STATE_NETWORK_LOCKED;
    }
    elseif ("READY".equals(prop)) {
        return SIM_STATE_READY;
    }
    else {
        return SIM_STATE_UNKNOWN;
    }
}

Post a Comment for "What Is The Value Of Sim State When "airplane Mode" Is Turned On"