void updateIccAvailability() {
    if (null == mUiccController) {
      return;
    }

    CardState newState = CardState.CARDSTATE_ABSENT;
    UiccCard newCard = mUiccController.getUiccCard(mSlotId);
    if (newCard != null) {
      newState = newCard.getCardState();
    }
    CardState oldState = mCardState;
    mCardState = newState;
    CatLog.d(this, "New Card State = " + newState + " " + "Old Card State = " + oldState);
    if (oldState == CardState.CARDSTATE_PRESENT && newState != CardState.CARDSTATE_PRESENT) {
      broadcastCardStateAndIccRefreshResp(newState, null);
    } else if (oldState != CardState.CARDSTATE_PRESENT && newState == CardState.CARDSTATE_PRESENT) {
      // Card moved to PRESENT STATE.
      mCmdIf.reportStkServiceIsRunning(null);
    }
  }
  @Override
  public void handleMessage(Message msg) {

    switch (msg.what) {
      case MSG_ID_SESSION_END:
      case MSG_ID_PROACTIVE_COMMAND:
      case MSG_ID_EVENT_NOTIFY:
      case MSG_ID_REFRESH:
        CatLog.d(this, "ril message arrived");
        String data = null;
        if (msg.obj != null) {
          AsyncResult ar = (AsyncResult) msg.obj;
          if (ar != null && ar.result != null) {
            try {
              data = (String) ar.result;
            } catch (ClassCastException e) {
              break;
            }
          }
        }
        mMsgDecoder.sendStartDecodingMessageParams(new RilMessage(msg.what, data));
        break;
      case MSG_ID_CALL_SETUP:
        mMsgDecoder.sendStartDecodingMessageParams(new RilMessage(msg.what, null));
        break;
      case MSG_ID_ICC_RECORDS_LOADED:
        break;
      case MSG_ID_RIL_MSG_DECODED:
        handleRilMsg((RilMessage) msg.obj);
        break;
      case MSG_ID_RESPONSE:
        handleCmdResponse((CatResponseMessage) msg.obj);
        break;
      case MSG_ID_SIM_READY:
        CatLog.d(this, "SIM ready. Reporting STK service running now...");
        mCmdIf.reportStkServiceIsRunning(null);
        break;
      default:
        throw new AssertionError("Unrecognized CAT command: " + msg.what);
    }
  }