@Override public void format(ByteArrayOutputStream buf) { // Item identifier object int tag = 0x80 | ComprehensionTlvTag.ITEM_ID.value(); buf.write(tag); // tag buf.write(1); // length buf.write(mId); // identifier of item chosen }
private void sendMenuSelection(int menuId, boolean helpRequired) { ByteArrayOutputStream buf = new ByteArrayOutputStream(); // tag int tag = BerTlv.BER_MENU_SELECTION_TAG; buf.write(tag); // length buf.write(0x00); // place holder // device identities tag = 0x80 | ComprehensionTlvTag.DEVICE_IDENTITIES.value(); buf.write(tag); buf.write(0x02); // length buf.write(DEV_ID_KEYPAD); // source device id buf.write(DEV_ID_UICC); // destination device id // item identifier tag = 0x80 | ComprehensionTlvTag.ITEM_ID.value(); buf.write(tag); buf.write(0x01); // length buf.write(menuId); // menu identifier chosen // help request if (helpRequired) { tag = ComprehensionTlvTag.HELP_REQUEST.value(); buf.write(tag); buf.write(0x00); // length } byte[] rawData = buf.toByteArray(); // write real length int len = rawData.length - 2; // minus (tag + length) rawData[1] = (byte) len; String hexString = IccUtils.bytesToHexString(rawData); mCmdIf.sendEnvelope(hexString, null); }