@Test public void testXfer_timeoutExtensionReply() throws Exception { CcidTransceiver ccidTransceiver = new CcidTransceiver(usbConnection, usbBulkIn, usbBulkOut, null); String commandData = "010203"; byte[] command = Hex.decode("6F030000000000000000" + commandData); byte[] timeExtensionResponse = Hex.decode("80000000000000800000"); String responseData = "0304"; byte[] response = Hex.decode("80020000000000000000" + responseData); expect(command, timeExtensionResponse); expect(null, response); CcidDataBlock ccidDataBlock = ccidTransceiver.sendXfrBlock(Hex.decode(commandData)); verifyDialog(); assertArrayEquals(Hex.decode(responseData), ccidDataBlock.getData()); }
@WorkerThread public synchronized CcidDataBlock sendXfrBlock(byte[] payload) throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); int l = payload.length; byte sequenceNumber = currentSequenceNumber++; byte[] headerData = { MESSAGE_TYPE_PC_TO_RDR_XFR_BLOCK, (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), SLOT_NUMBER, sequenceNumber, 0x00, 0x00, 0x00 }; byte[] data = Arrays.concatenate(headerData, payload); int sentBytes = 0; while (sentBytes < data.length) { int bytesToSend = Math.min(usbBulkOut.getMaxPacketSize(), data.length - sentBytes); sendRaw(data, sentBytes, bytesToSend); sentBytes += bytesToSend; } CcidDataBlock ccidDataBlock = receiveDataBlock(sequenceNumber); long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("USB XferBlock call took " + elapsedTime + "ms"); return ccidDataBlock; }
CcidTransceiver { @WorkerThread public synchronized CcidDataBlock sendXfrBlock(byte[] payload) throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); int l = payload.length; byte sequenceNumber = currentSequenceNumber++; byte[] headerData = { MESSAGE_TYPE_PC_TO_RDR_XFR_BLOCK, (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), SLOT_NUMBER, sequenceNumber, 0x00, 0x00, 0x00 }; byte[] data = Arrays.concatenate(headerData, payload); int sentBytes = 0; while (sentBytes < data.length) { int bytesToSend = Math.min(usbBulkOut.getMaxPacketSize(), data.length - sentBytes); sendRaw(data, sentBytes, bytesToSend); sentBytes += bytesToSend; } CcidDataBlock ccidDataBlock = receiveDataBlock(sequenceNumber); long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("USB XferBlock call took " + elapsedTime + "ms"); return ccidDataBlock; } }
CcidTransceiver { @WorkerThread public synchronized CcidDataBlock sendXfrBlock(byte[] payload) throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); int l = payload.length; byte sequenceNumber = currentSequenceNumber++; byte[] headerData = { MESSAGE_TYPE_PC_TO_RDR_XFR_BLOCK, (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), SLOT_NUMBER, sequenceNumber, 0x00, 0x00, 0x00 }; byte[] data = Arrays.concatenate(headerData, payload); int sentBytes = 0; while (sentBytes < data.length) { int bytesToSend = Math.min(usbBulkOut.getMaxPacketSize(), data.length - sentBytes); sendRaw(data, sentBytes, bytesToSend); sentBytes += bytesToSend; } CcidDataBlock ccidDataBlock = receiveDataBlock(sequenceNumber); long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("USB XferBlock call took " + elapsedTime + "ms"); return ccidDataBlock; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); }
CcidTransceiver { @WorkerThread public synchronized CcidDataBlock sendXfrBlock(byte[] payload) throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); int l = payload.length; byte sequenceNumber = currentSequenceNumber++; byte[] headerData = { MESSAGE_TYPE_PC_TO_RDR_XFR_BLOCK, (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), SLOT_NUMBER, sequenceNumber, 0x00, 0x00, 0x00 }; byte[] data = Arrays.concatenate(headerData, payload); int sentBytes = 0; while (sentBytes < data.length) { int bytesToSend = Math.min(usbBulkOut.getMaxPacketSize(), data.length - sentBytes); sendRaw(data, sentBytes, bytesToSend); sentBytes += bytesToSend; } CcidDataBlock ccidDataBlock = receiveDataBlock(sequenceNumber); long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("USB XferBlock call took " + elapsedTime + "ms"); return ccidDataBlock; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); @NonNull @WorkerThread synchronized CcidDataBlock iccPowerOn(); @WorkerThread synchronized CcidDataBlock sendXfrBlock(byte[] payload); boolean hasAutomaticPps(); }
CcidTransceiver { @WorkerThread public synchronized CcidDataBlock sendXfrBlock(byte[] payload) throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); int l = payload.length; byte sequenceNumber = currentSequenceNumber++; byte[] headerData = { MESSAGE_TYPE_PC_TO_RDR_XFR_BLOCK, (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), SLOT_NUMBER, sequenceNumber, 0x00, 0x00, 0x00 }; byte[] data = Arrays.concatenate(headerData, payload); int sentBytes = 0; while (sentBytes < data.length) { int bytesToSend = Math.min(usbBulkOut.getMaxPacketSize(), data.length - sentBytes); sendRaw(data, sentBytes, bytesToSend); sentBytes += bytesToSend; } CcidDataBlock ccidDataBlock = receiveDataBlock(sequenceNumber); long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("USB XferBlock call took " + elapsedTime + "ms"); return ccidDataBlock; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); @NonNull @WorkerThread synchronized CcidDataBlock iccPowerOn(); @WorkerThread synchronized CcidDataBlock sendXfrBlock(byte[] payload); boolean hasAutomaticPps();  }