@Test public void testAutoVoltageSelection() throws Exception { CcidDescription description = CcidDescription.fromValues((byte) 0, (byte) 1, 2, 132218); CcidTransceiver ccidTransceiver = new CcidTransceiver(usbConnection, usbBulkIn, usbBulkOut, description); byte[] iccPowerOnVoltageAutoCommand = Hex.decode("62000000000000000000"); byte[] iccPowerOnReply = Hex.decode("80150000000000000000" + ATR); expectReadPreamble(); expect(iccPowerOnVoltageAutoCommand, iccPowerOnReply); CcidDataBlock ccidDataBlock = ccidTransceiver.iccPowerOn(); verifyDialog(); assertArrayEquals(Hex.decode(ATR), ccidDataBlock.getData()); }
@NonNull @WorkerThread public synchronized CcidDataBlock iccPowerOn() throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); skipAvailableInput(); CcidDataBlock response = null; for (CcidDescription.Voltage v : usbCcidDescription.getVoltages()) { Timber.v("CCID: attempting to power on with voltage " + v.toString()); try { response = iccPowerOnVoltage(v.powerOnValue); } catch (UsbCcidErrorException e) { if (e.getErrorResponse().getError() == 7) { Timber.v("CCID: failed to power on with voltage " + v.toString()); iccPowerOff(); Timber.v("CCID: powered off"); continue; } throw e; } break; } if (response == null) { throw new UsbTransportException("Couldn't power up ICC2"); } long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("Usb transport connected, took " + elapsedTime + "ms, ATR=" + toHexString(response.getData())); return response; }
CcidTransceiver { @NonNull @WorkerThread public synchronized CcidDataBlock iccPowerOn() throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); skipAvailableInput(); CcidDataBlock response = null; for (CcidDescription.Voltage v : usbCcidDescription.getVoltages()) { Timber.v("CCID: attempting to power on with voltage " + v.toString()); try { response = iccPowerOnVoltage(v.powerOnValue); } catch (UsbCcidErrorException e) { if (e.getErrorResponse().getError() == 7) { Timber.v("CCID: failed to power on with voltage " + v.toString()); iccPowerOff(); Timber.v("CCID: powered off"); continue; } throw e; } break; } if (response == null) { throw new UsbTransportException("Couldn't power up ICC2"); } long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("Usb transport connected, took " + elapsedTime + "ms, ATR=" + toHexString(response.getData())); return response; } }
CcidTransceiver { @NonNull @WorkerThread public synchronized CcidDataBlock iccPowerOn() throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); skipAvailableInput(); CcidDataBlock response = null; for (CcidDescription.Voltage v : usbCcidDescription.getVoltages()) { Timber.v("CCID: attempting to power on with voltage " + v.toString()); try { response = iccPowerOnVoltage(v.powerOnValue); } catch (UsbCcidErrorException e) { if (e.getErrorResponse().getError() == 7) { Timber.v("CCID: failed to power on with voltage " + v.toString()); iccPowerOff(); Timber.v("CCID: powered off"); continue; } throw e; } break; } if (response == null) { throw new UsbTransportException("Couldn't power up ICC2"); } long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("Usb transport connected, took " + elapsedTime + "ms, ATR=" + toHexString(response.getData())); return response; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); }
CcidTransceiver { @NonNull @WorkerThread public synchronized CcidDataBlock iccPowerOn() throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); skipAvailableInput(); CcidDataBlock response = null; for (CcidDescription.Voltage v : usbCcidDescription.getVoltages()) { Timber.v("CCID: attempting to power on with voltage " + v.toString()); try { response = iccPowerOnVoltage(v.powerOnValue); } catch (UsbCcidErrorException e) { if (e.getErrorResponse().getError() == 7) { Timber.v("CCID: failed to power on with voltage " + v.toString()); iccPowerOff(); Timber.v("CCID: powered off"); continue; } throw e; } break; } if (response == null) { throw new UsbTransportException("Couldn't power up ICC2"); } long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("Usb transport connected, took " + elapsedTime + "ms, ATR=" + toHexString(response.getData())); return response; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); @NonNull @WorkerThread synchronized CcidDataBlock iccPowerOn(); @WorkerThread synchronized CcidDataBlock sendXfrBlock(byte[] payload); boolean hasAutomaticPps(); }
CcidTransceiver { @NonNull @WorkerThread public synchronized CcidDataBlock iccPowerOn() throws UsbTransportException { long startTime = SystemClock.elapsedRealtime(); skipAvailableInput(); CcidDataBlock response = null; for (CcidDescription.Voltage v : usbCcidDescription.getVoltages()) { Timber.v("CCID: attempting to power on with voltage " + v.toString()); try { response = iccPowerOnVoltage(v.powerOnValue); } catch (UsbCcidErrorException e) { if (e.getErrorResponse().getError() == 7) { Timber.v("CCID: failed to power on with voltage " + v.toString()); iccPowerOff(); Timber.v("CCID: powered off"); continue; } throw e; } break; } if (response == null) { throw new UsbTransportException("Couldn't power up ICC2"); } long elapsedTime = SystemClock.elapsedRealtime() - startTime; Timber.d("Usb transport connected, took " + elapsedTime + "ms, ATR=" + toHexString(response.getData())); return response; } CcidTransceiver(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut,
            CcidDescription ccidDescription); @NonNull @WorkerThread synchronized CcidDataBlock iccPowerOn(); @WorkerThread synchronized CcidDataBlock sendXfrBlock(byte[] payload); boolean hasAutomaticPps();  }