/**
   * Processes GET_INKEY proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processGetInkey(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process GetInkey");

    Input input = new Input();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      input.text = ValueParser.retrieveTextString(ctlv);
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
    }

    // parse duration
    ctlv = searchForTag(ComprehensionTlvTag.DURATION, ctlvs);
    if (ctlv != null) {
      input.duration = ValueParser.retrieveDuration(ctlv);
    }

    input.minLen = 1;
    input.maxLen = 1;

    input.digitOnly = (cmdDet.commandQualifier & 0x01) == 0;
    input.ucs2 = (cmdDet.commandQualifier & 0x02) != 0;
    input.yesNo = (cmdDet.commandQualifier & 0x04) != 0;
    input.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0;
    input.echo = true;

    mCmdParams = new GetInputParams(cmdDet, input);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }
  /**
   * Processes GET_INPUT proactive command from the SIM card.
   *
   * @param cmdDet Command Details container object.
   * @param ctlvs List of ComprehensionTlv objects following Command Details object and Device
   *     Identities object within the proactive command
   * @return true if the command is processing is pending and additional asynchronous processing is
   *     required.
   * @throws ResultException
   */
  private boolean processGetInput(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs)
      throws ResultException {

    CatLog.d(this, "process GetInput");

    Input input = new Input();
    IconId iconId = null;

    ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.TEXT_STRING, ctlvs);
    if (ctlv != null) {
      input.text = ValueParser.retrieveTextString(ctlv);
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }

    ctlv = searchForTag(ComprehensionTlvTag.RESPONSE_LENGTH, ctlvs);
    if (ctlv != null) {
      try {
        byte[] rawValue = ctlv.getRawValue();
        int valueIndex = ctlv.getValueIndex();
        input.minLen = rawValue[valueIndex] & 0xff;
        input.maxLen = rawValue[valueIndex + 1] & 0xff;
      } catch (IndexOutOfBoundsException e) {
        throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
      }
    } else {
      throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
    }

    ctlv = searchForTag(ComprehensionTlvTag.DEFAULT_TEXT, ctlvs);
    if (ctlv != null) {
      input.defaultText = ValueParser.retrieveTextString(ctlv);
    }
    // parse icon identifier
    ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
    if (ctlv != null) {
      iconId = ValueParser.retrieveIconId(ctlv);
    }

    input.digitOnly = (cmdDet.commandQualifier & 0x01) == 0;
    input.ucs2 = (cmdDet.commandQualifier & 0x02) != 0;
    input.echo = (cmdDet.commandQualifier & 0x04) == 0;
    input.packed = (cmdDet.commandQualifier & 0x08) != 0;
    input.helpAvailable = (cmdDet.commandQualifier & 0x80) != 0;

    // Truncate the maxLen if it exceeds the max number of chars that can
    // be encoded. Limit depends on DCS in Command Qualifier.
    if (input.ucs2 && input.maxLen > MAX_UCS2_CHARS) {
      CatLog.d(
          this, "UCS2: received maxLen = " + input.maxLen + ", truncating to " + MAX_UCS2_CHARS);
      input.maxLen = MAX_UCS2_CHARS;
    } else if (!input.packed && input.maxLen > MAX_GSM7_DEFAULT_CHARS) {
      CatLog.d(
          this,
          "GSM 7Bit Default: received maxLen = "
              + input.maxLen
              + ", truncating to "
              + MAX_GSM7_DEFAULT_CHARS);
      input.maxLen = MAX_GSM7_DEFAULT_CHARS;
    }

    mCmdParams = new GetInputParams(cmdDet, input);

    if (iconId != null) {
      mloadIcon = true;
      mIconLoadState = LOAD_SINGLE_ICON;
      mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
      return true;
    }
    return false;
  }