|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.acs.smartcard.Reader
public class Reader
This class represents a smart card reader attached to the android device.
| Nested Class Summary | |
|---|---|
static interface |
Reader.OnStateChangeListener
Interface definition for a callback to be invoked when the state of reader is changed. |
| Field Summary | |
|---|---|
static int |
CARD_ABSENT
There is no card in the reader. |
static int |
CARD_COLD_RESET
Cycle power and reset the card. |
static int |
CARD_NEGOTIABLE
The card has been reset and is awaiting PTS negotiation. |
static int |
CARD_POWER_DOWN
Power down the card. |
static int |
CARD_POWERED
Power is being provided to the card, but the library is unaware of the mode of the card. |
static int |
CARD_PRESENT
There is a card in the reader, but it has not been moved into position for use. |
static int |
CARD_SPECIFIC
The card has been reset and specific communication protocols have been established. |
static int |
CARD_SWALLOWED
There is a card in the reader in position for use. |
static int |
CARD_UNKNOWN
The library is unaware of the current state of the reader. |
static int |
CARD_WARM_RESET
Force a reset on the card. |
static int |
IOCTL_ACR128_READER_COMMAND
Control code for sending command to ACR128 reader. |
static int |
IOCTL_ACR83_DISPLAY_LCD_MESSAGE
Control code for displaying LCD message on ACR83/APG8201 reader. |
static int |
IOCTL_ACR83_GET_FIRMWARE_VERSION
Control code for getting firmware version from ACR83/APG8201 reader. |
static int |
IOCTL_ACR83_READ_KEY
Control code for reading key from ACR83/APG8201 reader. |
static int |
IOCTL_CCID_ESCAPE
Control code for sending escape command to the reader. |
static int |
IOCTL_GET_FEATURE_REQUEST
Control code for getting supported features (PC/SC 2.0 Part 10). |
static int |
PROTOCOL_DEFAULT
Use the default transmission parameters or card clock frequency. |
static int |
PROTOCOL_OPTIMAL
Use optimal transmission parameters or card clock frequency. |
static int |
PROTOCOL_RAW
Raw is the active protocol. |
static int |
PROTOCOL_T0
T=0 is the active protocol. |
static int |
PROTOCOL_T1
T=1 is the active protocol. |
static int |
PROTOCOL_TX
This is the mask of ISO defined transmission protocols. |
static int |
PROTOCOL_UNDEFINED
There is no active protocol. |
| Constructor Summary | |
|---|---|
Reader(android.hardware.usb.UsbManager manager)
Creates an instance of Reader. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the reader. |
int |
control(int slotNum,
int controlCode,
byte[] inBuffer,
int inBufferLength,
byte[] outBuffer,
int outBufferLength)
Controls the reader. |
byte[] |
getAtr(int slotNum)
Gets the ATR string. |
android.hardware.usb.UsbDevice |
getDevice()
Gets the device. |
int |
getNumSlots()
Gets the number of slots. |
int |
getProtocol(int slotNum)
Gets the active protocol. |
java.lang.String |
getReaderName()
Gets the reader name. |
int |
getState(int slotNum)
Gets the card state. |
boolean |
isOpened()
Returns true if the reader is opened. |
boolean |
isSupported(android.hardware.usb.UsbDevice device)
Returns true if the reader is supported. |
void |
open(android.hardware.usb.UsbDevice device)
Opens the reader. |
byte[] |
power(int slotNum,
int action)
Performs the power action on the card. |
void |
setOnStateChangeListener(Reader.OnStateChangeListener listener)
Registers a callback to be invoked when the state of reader is changed. |
int |
setProtocol(int slotNum,
int preferredProtocols)
Sets the protocol. |
int |
transmit(int slotNum,
byte[] sendBuffer,
int sendBufferLength,
byte[] recvBuffer,
int recvBufferLength)
Transmits the APDU. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int CARD_POWER_DOWN
public static final int CARD_COLD_RESET
public static final int CARD_WARM_RESET
public static final int PROTOCOL_UNDEFINED
public static final int PROTOCOL_T0
public static final int PROTOCOL_T1
public static final int PROTOCOL_RAW
public static final int PROTOCOL_TX
public static final int PROTOCOL_DEFAULT
public static final int PROTOCOL_OPTIMAL
public static final int CARD_UNKNOWN
public static final int CARD_ABSENT
public static final int CARD_PRESENT
public static final int CARD_SWALLOWED
public static final int CARD_POWERED
public static final int CARD_NEGOTIABLE
public static final int CARD_SPECIFIC
public static final int IOCTL_CCID_ESCAPE
public static final int IOCTL_ACR128_READER_COMMAND
public static final int IOCTL_ACR83_GET_FIRMWARE_VERSION
public static final int IOCTL_ACR83_DISPLAY_LCD_MESSAGE
public static final int IOCTL_ACR83_READ_KEY
public static final int IOCTL_GET_FEATURE_REQUEST
| Constructor Detail |
|---|
public Reader(android.hardware.usb.UsbManager manager)
manager - the USB manager.| Method Detail |
|---|
public boolean isSupported(android.hardware.usb.UsbDevice device)
device - the USB device.
public void open(android.hardware.usb.UsbDevice device)
device - the USB device.public void close()
public boolean isOpened()
public android.hardware.usb.UsbDevice getDevice()
public int getNumSlots()
public java.lang.String getReaderName()
public void setOnStateChangeListener(Reader.OnStateChangeListener listener)
listener - the callback that will run.
public byte[] power(int slotNum,
int action)
throws ReaderException
slotNum - the slot number.action - the action to be performed on the card:
CARD_POWER_DOWN, CARD_COLD_RESET or
CARD_WARM_RESET.
ReaderException - if the reader is not opened or the reader is failed to
perform the power action on the card.public byte[] getAtr(int slotNum)
slotNum - the slot number.
public int setProtocol(int slotNum,
int preferredProtocols)
throws ReaderException
slotNum - the slot number.preferredProtocols - the preferred protocols. It can be combined with OR operation.
For example, PROTOCOL_T0 | PROTOCOL_T1.
PROTOCOL_T0 or
PROTOCOL_T1.
ReaderException - if the reader is failed to set protocol.public int getProtocol(int slotNum)
slotNum - the slot number.
PROTOCOL_UNDEFINED,
PROTOCOL_T0 or PROTOCOL_T1.public int getState(int slotNum)
slotNum - the slot number.
CARD_ABSENT, CARD_PRESENT,
CARD_SWALLOWED, CARD_POWERED,
CARD_NEGOTIABLE or CARD_SPECIFIC.
public int transmit(int slotNum,
byte[] sendBuffer,
int sendBufferLength,
byte[] recvBuffer,
int recvBufferLength)
throws ReaderException
slotNum - the slot number.sendBuffer - the send buffer.sendBufferLength - the send buffer length.recvBuffer - the receive buffer.recvBufferLength - the receive buffer length.
ReaderException - if the reader is not opened or the reader is failed to
transmit the APDU.
public int control(int slotNum,
int controlCode,
byte[] inBuffer,
int inBufferLength,
byte[] outBuffer,
int outBufferLength)
throws ReaderException
slotNum - the slot number.controlCode - the control code.inBuffer - the input buffer.inBufferLength - the input buffer length.outBuffer - the output buffer.outBufferLength - the output buffer length.
ReaderException - if the reader is not opened or the reader does not accept the
control.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||