public class AudioJackReader
extends java.lang.Object
AudioJackReader
class represents ACS audio jack readers.Modifier and Type | Class and Description |
---|---|
static interface |
AudioJackReader.OnAuthCompleteListener
Interface definition for a callback to be invoked when the reader
authentication is complete.
|
static interface |
AudioJackReader.OnCustomIdAvailableListener
Interface definition for a callback to be invoked when the reader sends
the custom ID.
|
static interface |
AudioJackReader.OnDeviceIdAvailableListener
Interface definition for a callback to be invoked when the reader sends
the device ID.
|
static interface |
AudioJackReader.OnDukptOptionAvailableListener
Interface definition for a callback to be invoked when the reader sends
the DUKPT option.
|
static interface |
AudioJackReader.OnFirmwareVersionAvailableListener
Interface definition for a callback to be invoked when the reader sends
the firmware version.
|
static interface |
AudioJackReader.OnPiccAtrAvailableListener
Interface definition for a callback to be invoked when the reader sends
the ATR from PICC.
|
static interface |
AudioJackReader.OnPiccResponseApduAvailableListener
Interface definition for a callback to be invoked when the reader sends
the response APDU from PICC.
|
static interface |
AudioJackReader.OnRawDataAvailableListener
Interface definition for a callback to be invoked when the reader sends
the raw data.
|
static interface |
AudioJackReader.OnResetCompleteListener
Interface definition for a callback to be invoked when the reader reset
is complete.
|
static interface |
AudioJackReader.OnResultAvailableListener
Interface definition for a callback to be invoked when the reader sends
the result.
|
static interface |
AudioJackReader.OnStatusAvailableListener
Interface definition for a callback to be invoked when the reader sends
the status.
|
static interface |
AudioJackReader.OnTrackDataAvailableListener
Interface definition for a callback to be invoked when the reader sends
the track data.
|
static interface |
AudioJackReader.OnTrackDataNotificationListener
Interface definition for a callback to be invoked when the reader
notifies the track data.
|
static interface |
AudioJackReader.OnTrackDataOptionAvailableListener
Interface definition for a callback to be invoked when the reader sends
the track data option.
|
Modifier and Type | Field and Description |
---|---|
static int |
AUTH_ERROR_FAILURE
Authentication failure.
|
static int |
AUTH_ERROR_SUCCESS
Authentication success.
|
static int |
AUTH_ERROR_TIMEOUT
Authentication timeout.
|
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_CCID_ESCAPE
Control code for sending escape command to the reader.
|
static int |
IOCTL_CCID_XFR_BLOCK
Control code for sending APDU to the reader.
|
static int |
PICC_CARD_TYPE_AUTO_RATS
Auto RATS.
|
static int |
PICC_CARD_TYPE_FELICA_212KBPS
FeliCa 212kbps.
|
static int |
PICC_CARD_TYPE_FELICA_424KBPS
FeliCa 424kbps.
|
static int |
PICC_CARD_TYPE_ISO14443_TYPE_A
ISO14443 Type A.
|
static int |
PICC_CARD_TYPE_ISO14443_TYPE_B
ISO14443 Type B.
|
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.
|
static int |
TRACK_DATA_OPTION_ENCRYPTED_TRACK1
Enable the encrypted track 1 data.
|
static int |
TRACK_DATA_OPTION_ENCRYPTED_TRACK2
Enable the encrypted track 2 data.
|
static int |
TRACK_DATA_OPTION_MASKED_TRACK1
Enable the masked track 1 data.
|
static int |
TRACK_DATA_OPTION_MASKED_TRACK2
Enable the masked track 2 data.
|
Constructor and Description |
---|
AudioJackReader(android.media.AudioManager audioManager)
Creates an instance of
AudioJackReader . |
AudioJackReader(android.media.AudioManager audioManager,
boolean mute)
Creates an instance of
AudioJackReader with the mute option. |
Modifier and Type | Method and Description |
---|---|
void |
authenticate(byte[] masterKey)
Authenticates the reader.
|
void |
authenticate(byte[] masterKey,
AudioJackReader.OnAuthCompleteListener listener)
Authenticates the reader.
|
byte[] |
control(int slotNum,
int controlCode,
byte[] command,
int timeout)
Transmits the control command.
|
byte[] |
createFrame(byte[] buffer)
Creates a frame.
|
byte[] |
createFrame(byte[] buffer,
int offset,
int byteCount)
Creates a frame.
|
byte[] |
getAtr(int slotNum)
Gets the ATR string.
|
int |
getCardState(int slotNum)
Gets the card state.
|
boolean |
getCustomId()
Gets the custom ID from the reader.
|
boolean |
getDeviceId()
Gets the device ID from the reader.
|
boolean |
getDukptOption()
Gets the DUKPT option from the reader.
|
boolean |
getFirmwareVersion()
Gets the firmware version.
|
int |
getProtocol(int slotNum)
Gets the active protocol.
|
boolean |
getStatus()
Gets the status.
|
boolean |
getTrackDataOption()
Gets the track data option from the reader.
|
boolean |
initializeDukpt(byte[] iksn,
byte[] ipek)
Initializes DUKPT to the reader.
|
boolean |
isMute()
Returns
true if the audio output is muted, otherwise
false . |
boolean |
piccPowerOff()
Powers off the PICC.
|
boolean |
piccPowerOn(int timeout,
int cardType)
Powers on the PICC.
|
boolean |
piccTransmit(int timeout,
byte[] commandApdu)
Transmits the command APDU to PICC.
|
boolean |
piccTransmit(int timeout,
byte[] commandApdu,
int offset,
int byteCount)
Transmits the command APDU to the PICC.
|
byte[] |
power(int slotNum,
int action,
int timeout)
Performs the power action on the card.
|
void |
reset()
Resets the reader.
|
void |
reset(AudioJackReader.OnResetCompleteListener listener)
Resets the reader.
|
boolean |
sendCommand(byte[] buffer)
Sends the command to the reader.
|
boolean |
sendCommand(byte[] buffer,
int offset,
int byteCount)
Sends a command to the reader.
|
boolean |
sendFrame(byte[] frame)
Sends a frame to the reader.
|
boolean |
setAesKey(byte[] aesKey)
Sets the AES key to the reader.
|
boolean |
setCustomId(byte[] customId)
Sets the custom ID to the reader.
|
boolean |
setDukptOption(boolean enabled)
Sets the DUKPT option to the reader.
|
boolean |
setMasterKey(byte[] masterKey)
Sets the master key to the reader.
|
void |
setMute(boolean mute)
Sets the mute option.
|
void |
setOnAuthCompleteListener(AudioJackReader.OnAuthCompleteListener listener)
Registers a callback to be invoked when the reader authentication is
complete.
|
void |
setOnCustomIdAvailableListener(AudioJackReader.OnCustomIdAvailableListener listener)
Registers a callback to be invoked when the reader sends the custom ID.
|
void |
setOnDeviceIdAvailableListener(AudioJackReader.OnDeviceIdAvailableListener listener)
Registers a callback to be invoked when the reader sends the device ID.
|
void |
setOnDukptOptionAvailableListener(AudioJackReader.OnDukptOptionAvailableListener listener)
Registers a callback to be invoked when the reader sends the DUKPT
option.
|
void |
setOnFirmwareVersionAvailableListener(AudioJackReader.OnFirmwareVersionAvailableListener listener)
Registers a callback to be invoked when the reader sends the firmware
version.
|
void |
setOnPiccAtrAvailableListener(AudioJackReader.OnPiccAtrAvailableListener listener)
Registers a callback to be invoked when the reader sends the ATR from
PICC.
|
void |
setOnPiccResponseApduAvailableListener(AudioJackReader.OnPiccResponseApduAvailableListener listener)
Registers a callback to be invoked when the reader sends the response
APDU from PICC.
|
void |
setOnRawDataAvailableListener(AudioJackReader.OnRawDataAvailableListener listener)
Registers a callback to be invoked when the reader sends the raw data.
|
void |
setOnResetCompleteListener(AudioJackReader.OnResetCompleteListener listener)
Registers a callback to be invoked when the reader reset is complete.
|
void |
setOnResultAvailableListener(AudioJackReader.OnResultAvailableListener listener)
Registers a callback to be invoked when the reader sends the result.
|
void |
setOnStatusAvailableListener(AudioJackReader.OnStatusAvailableListener listener)
Registers a callback to be invoked when the reader sends the status.
|
void |
setOnTrackDataAvailableListener(AudioJackReader.OnTrackDataAvailableListener listener)
Registers a callback to be invoked when the reader sends the track data.
|
void |
setOnTrackDataNotificationListener(AudioJackReader.OnTrackDataNotificationListener listener)
Registers a callback to be invoked when the reader notifies the track
data.
|
void |
setOnTrackDataOptionAvailableListener(AudioJackReader.OnTrackDataOptionAvailableListener listener)
Registers a callback to be invoked when the reader sends the track data
option.
|
boolean |
setPiccRfConfig(byte[] rfConfig)
Sets the PICC RF configuration.
|
int |
setProtocol(int slotNum,
int preferredProtocols,
int timeout)
Sets the protocol.
|
boolean |
setSleepTimeout(int timeout)
Sets the sleep timeout.
|
boolean |
setTrackDataOption(int option)
Sets the track data option to the reader.
|
boolean |
sleep()
Sets the reader to sleep.
|
void |
start()
Starts the reader.
|
void |
stop()
Stops the reader.
|
byte[] |
transmit(int slotNum,
byte[] command,
int timeout)
Transmits the APDU.
|
void |
updateCardState(int slotNum,
int timeout)
Updates the card state.
|
boolean |
verifyData(byte[] buffer)
Verifies the data using CRC16 checksum.
|
boolean |
verifyData(byte[] buffer,
int offset,
int byteCount)
Verifies the data using CRC16 checksum.
|
public static final int AUTH_ERROR_SUCCESS
public static final int AUTH_ERROR_FAILURE
public static final int AUTH_ERROR_TIMEOUT
public static final int PICC_CARD_TYPE_ISO14443_TYPE_A
public static final int PICC_CARD_TYPE_ISO14443_TYPE_B
public static final int PICC_CARD_TYPE_FELICA_212KBPS
public static final int PICC_CARD_TYPE_FELICA_424KBPS
public static final int PICC_CARD_TYPE_AUTO_RATS
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_CCID_XFR_BLOCK
public static final int TRACK_DATA_OPTION_ENCRYPTED_TRACK1
public static final int TRACK_DATA_OPTION_ENCRYPTED_TRACK2
public static final int TRACK_DATA_OPTION_MASKED_TRACK1
public static final int TRACK_DATA_OPTION_MASKED_TRACK2
public AudioJackReader(android.media.AudioManager audioManager)
AudioJackReader
.audioManager
- the audio manager.public AudioJackReader(android.media.AudioManager audioManager, boolean mute)
AudioJackReader
with the mute option.audioManager
- the audio manager.mute
- the mute option. true
to mute the audio output,
otherwise false
.public boolean isMute()
true
if the audio output is muted, otherwise
false
.true
or false
.public void setMute(boolean mute)
mute
- the mute option. true
to mute the audio output,
otherwise false
.public void setOnResetCompleteListener(AudioJackReader.OnResetCompleteListener listener)
listener
- the callback that will run.public void setOnResultAvailableListener(AudioJackReader.OnResultAvailableListener listener)
listener
- the callback that will run.public void setOnStatusAvailableListener(AudioJackReader.OnStatusAvailableListener listener)
listener
- the callback that will run.public void setOnFirmwareVersionAvailableListener(AudioJackReader.OnFirmwareVersionAvailableListener listener)
listener
- the callback that will run.public void setOnTrackDataNotificationListener(AudioJackReader.OnTrackDataNotificationListener listener)
listener
- the callback that will run.public void setOnTrackDataAvailableListener(AudioJackReader.OnTrackDataAvailableListener listener)
listener
- the callback that will run.public void setOnRawDataAvailableListener(AudioJackReader.OnRawDataAvailableListener listener)
listener
- the callback that will run.public void setOnAuthCompleteListener(AudioJackReader.OnAuthCompleteListener listener)
listener
- the callback that will run.public void setOnCustomIdAvailableListener(AudioJackReader.OnCustomIdAvailableListener listener)
listener
- the callback that will run.public void setOnDeviceIdAvailableListener(AudioJackReader.OnDeviceIdAvailableListener listener)
listener
- the callback that will run.public void setOnDukptOptionAvailableListener(AudioJackReader.OnDukptOptionAvailableListener listener)
listener
- the callback that will run.public void setOnTrackDataOptionAvailableListener(AudioJackReader.OnTrackDataOptionAvailableListener listener)
listener
- the callback that will run.public void setOnPiccAtrAvailableListener(AudioJackReader.OnPiccAtrAvailableListener listener)
listener
- the callback that will run.public void setOnPiccResponseApduAvailableListener(AudioJackReader.OnPiccResponseApduAvailableListener listener)
listener
- the callback that will run.public void start()
public void stop()
public void reset()
public void reset(AudioJackReader.OnResetCompleteListener listener)
listener
- the completion listener.public boolean sleep()
public boolean getFirmwareVersion()
public boolean getStatus()
public boolean setSleepTimeout(int timeout)
timeout
- the timeout value in seconds.public void authenticate(byte[] masterKey)
masterKey
- the master key. The length must be 16 bytes.public void authenticate(byte[] masterKey, AudioJackReader.OnAuthCompleteListener listener)
masterKey
- the master key. The length must be 16 bytes.listener
- the completion listener.public boolean getCustomId()
public boolean setCustomId(byte[] customId)
customId
- the custom ID. The length must be 10 bytes.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean getDeviceId()
public boolean setMasterKey(byte[] masterKey)
masterKey
- the master key. The length must be 16 bytes.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean setAesKey(byte[] aesKey)
aesKey
- the AES key. The length must be 16 bytes.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean getDukptOption()
public boolean setDukptOption(boolean enabled)
enabled
- set to true to enable DUKPT. Otherwise, set to false.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean initializeDukpt(byte[] iksn, byte[] ipek)
iksn
- the initial key serial number (IKSN). The length must be 10
bytes.ipek
- the initial PIN encryption key (IPEK). The length must be 16
bytes.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean getTrackDataOption()
public boolean setTrackDataOption(int option)
option
- the track data option. See
TRACK_DATA_OPTION_ENCRYPTED_TRACK1
,
TRACK_DATA_OPTION_ENCRYPTED_TRACK2
,
TRACK_DATA_OPTION_MASKED_TRACK1
and
TRACK_DATA_OPTION_MASKED_TRACK2
. It can be combined
with OR operation.authenticate(byte[])
,
authenticate(byte[], OnAuthCompleteListener)
public boolean piccPowerOn(int timeout, int cardType)
timeout
- the timeout value in seconds.cardType
- the card type. See PICC_CARD_TYPE_ISO14443_TYPE_A
,
PICC_CARD_TYPE_ISO14443_TYPE_B
,
PICC_CARD_TYPE_FELICA_212KBPS
,
PICC_CARD_TYPE_FELICA_424KBPS
and
PICC_CARD_TYPE_AUTO_RATS
. It can be combined with OR
operation.public boolean piccTransmit(int timeout, byte[] commandApdu)
timeout
- the timeout value in seconds.commandApdu
- the command APDU.public boolean piccTransmit(int timeout, byte[] commandApdu, int offset, int byteCount)
timeout
- the timeout value in seconds.commandApdu
- the command APDU.offset
- the offset.byteCount
- the number of bytes.public boolean piccPowerOff()
public boolean setPiccRfConfig(byte[] rfConfig)
rfConfig
- the RF configuration. The length must be 19 bytes.public byte[] power(int slotNum, int action, int timeout) throws ReaderNotStartedException, RequestQueueFullException, CommunicationTimeoutException, CommunicationErrorException, RemovedCardException, UnresponsiveCardException, UnsupportedCardException
slotNum
- the slot number.action
- the action to be performed on the card. See
CARD_POWER_DOWN
, CARD_COLD_RESET
and
CARD_WARM_RESET
.timeout
- the maximum time to wait in milliseconds.ReaderNotStartedException
- if the reader is not started.RequestQueueFullException
- if the request queue is full.CommunicationTimeoutException
- if there is timeout in the communication.CommunicationErrorException
- if there is an error occurred in the communication.RemovedCardException
- if the card is removed.UnresponsiveCardException
- if the card does not respond to the reset.UnsupportedCardException
- if the card is not supported.public int setProtocol(int slotNum, int preferredProtocols, int timeout) throws ReaderNotStartedException, ProtocolMismatchException, InvalidDeviceStateException, RequestQueueFullException, CommunicationTimeoutException, CommunicationErrorException, RemovedCardException, UnresponsiveCardException, UnsupportedCardException
slotNum
- the slot number.preferredProtocols
- the preferred protocols. It can be combined with OR operation.
For example, PROTOCOL_T0
| PROTOCOL_T1
.timeout
- the maximum time to wait in milliseconds.PROTOCOL_T0
or
PROTOCOL_T1
.ReaderNotStartedException
- if the reader is not started.InvalidDeviceStateException
- if the current state is not equal to negotiable.ProtocolMismatchException
- if the preferred protocols does not match with the card.RequestQueueFullException
- if the request queue is full.CommunicationTimeoutException
- if there is timeout in the communication.CommunicationErrorException
- if there is an error occurred in the communication.RemovedCardException
- if the card is removed.UnresponsiveCardException
- if the card does not respond to the reset.UnsupportedCardException
- if the card is not supported.public byte[] transmit(int slotNum, byte[] command, int timeout) throws ReaderNotStartedException, InvalidDeviceStateException, RequestQueueFullException, CommunicationTimeoutException, CommunicationErrorException, RemovedCardException, CardTimeoutException
slotNum
- the slot number.command
- the command APDU.timeout
- the maximum time to wait in milliseconds.ReaderNotStartedException
- if the reader is not started.InvalidDeviceStateException
- if the current state is not equal to specific or the active
protocol is not equal to either T=0 or T=1.RequestQueueFullException
- if the request queue is full.CommunicationTimeoutException
- if there is timeout in the communication.CommunicationErrorException
- if there is an error occurred in the communication.RemovedCardException
- if the card is removed.CardTimeoutException
- if the card operation timed out.public byte[] control(int slotNum, int controlCode, byte[] command, int timeout) throws ReaderNotStartedException, RequestQueueFullException, CommunicationTimeoutException, CommunicationErrorException, RemovedCardException, CardTimeoutException
slotNum
- the slot number.controlCode
- the control code.command
- the control command.timeout
- the maximum time to wait in milliseconds.ReaderNotStartedException
- if the reader is not started.RequestQueueFullException
- if the request queue is full.CommunicationTimeoutException
- if there is timeout in the communication.CommunicationErrorException
- if there is an error occurred in the communication.RemovedCardException
- if the card is removed.CardTimeoutException
- if the card operation timed out.public void updateCardState(int slotNum, int timeout) throws ReaderNotStartedException, RequestQueueFullException, CommunicationTimeoutException, CommunicationErrorException
slotNum
- the slot number.timeout
- the maximum time to wait in milliseconds.ReaderNotStartedException
- if the reader is not started.RequestQueueFullException
- if the request queue is full.CommunicationTimeoutException
- if there is timeout in the communication.CommunicationErrorException
- if there is an error occurred in the communication.public byte[] getAtr(int slotNum)
slotNum
- the slot number.public int getCardState(int slotNum)
slotNum
- the slot number.CARD_ABSENT
, CARD_PRESENT
,
CARD_SWALLOWED
, CARD_POWERED
,
CARD_NEGOTIABLE
and CARD_SPECIFIC
.public int getProtocol(int slotNum)
slotNum
- the slot number.PROTOCOL_UNDEFINED
,
PROTOCOL_T0
and PROTOCOL_T1
.public boolean sendCommand(byte[] buffer)
buffer
- the buffer.public boolean sendCommand(byte[] buffer, int offset, int byteCount)
buffer
- the buffer.offset
- the offset.byteCount
- the number of bytes.public byte[] createFrame(byte[] buffer)
buffer
- the buffer.public byte[] createFrame(byte[] buffer, int offset, int byteCount)
buffer
- the buffer.offset
- the offset.byteCount
- the number of bytes.public boolean sendFrame(byte[] frame)
frame
- the frame.public boolean verifyData(byte[] buffer)
buffer
- the buffer.public boolean verifyData(byte[] buffer, int offset, int byteCount)
buffer
- the buffer.offset
- the offset.byteCount
- the number of bytes.Copyright © 2013-2018, Advanced Card Systems Ltd. All rights reserved.