public interface SmartCardReaderDevice extends Device, TimeConstants
SmartCardReaderDevice
interface defines the API for smart card operations to be used by applications.
A smart card device object is obtained from the POSTerminal
as follows:
SmartCardReaderDevice smartCardReaderDevice = (SmartCardReaderDevice) POSTerminal.getInstance().getDevice("com.cloudpos.device.smartcardreader");
The identifier "com.cloudpos.device.smartcardreader" is used to specify the smart card device, as defined by the specific implementation.
Applications can use this interface to control smart card operations and must request the necessary permissions:
<uses-permission android:name="android.permission.CLOUDPOS_SMARTCARD"/>
Device
Modifier and Type | Field and Description |
---|---|
static int |
ID_PSAMCARD |
static int |
ID_SMARTCARD |
FOREVER, IMMEDIATE, MilliSECOND, SECOND
Modifier and Type | Method and Description |
---|---|
void |
listenForCardAbsent(OperationListener listener,
int timeout)
Asynchronously listens for a smart card to be removed from the reader.
|
void |
listenForCardPresent(OperationListener listener,
int timeout)
Asynchronously listens for a smart card to be inserted into the reader.
|
void |
open(int logicalID)
Opens the smart card reader device.
|
void |
open(int logicalID,
int cardEmvMode)
Opens the smart card reader device with a specified EMV mode.
|
SmartCardReaderOperationResult |
waitForCardAbsent(int timeout)
Synchronously waits for a smart card to be removed from the reader.
|
SmartCardReaderOperationResult |
waitForCardPresent(int timeout)
Synchronously waits for a smart card to be present in the reader.
|
cancelRequest, close, getFailCount, getUsageCount, open
static final int ID_SMARTCARD
static final int ID_PSAMCARD
void open(int logicalID) throws DeviceException
logicalID
- Logical ID of the device to open. Can be either ID_SMARTCARD
or ID_PSAMCARD
.DeviceException
- for standard errors as documented in DeviceException
.void open(int logicalID, int cardEmvMode) throws DeviceException
logicalID
- Logical ID of the device to open. Can be either ID_SMARTCARD
or ID_PSAMCARD
.cardEmvMode
- 1 for EMV mode, 0 for non-EMV mode.DeviceException
- for standard errors as documented in DeviceException
.void listenForCardPresent(OperationListener listener, int timeout) throws DeviceException
This method is asynchronous. OperationListener.handleResult(OperationResult)
is called upon card detection or timeout.
The method supports a timeout mechanism, requiring the ability to respond to Device.cancelRequest()
to abort the operation if needed.
In case of timeout, the operation result will contain the error code OperationResult.ERR_TIMEOUT
, with no card information available.
listener
- The listener to handle operation results.timeout
- The maximum time to wait for a card, in milliseconds.DeviceException
- for standard errors as documented in DeviceException
.OperationListener.handleResult(com.cloudpos.OperationResult)
SmartCardReaderOperationResult waitForCardPresent(int timeout) throws DeviceException
timeout
- The maximum time to wait for a card, in milliseconds.SmartCardReaderOperationResult
object representing the result of the wait operation.DeviceException
- for standard errors as documented in DeviceException
.void listenForCardAbsent(OperationListener listener, int timeout) throws DeviceException
This method is asynchronous and supports a timeout mechanism, requiring the ability to respond to Device.cancelRequest()
.
In case of timeout, the operation result will contain the error code OperationResult.ERR_TIMEOUT
, with no card information available.
listener
- The listener to handle operation results.timeout
- The maximum time to wait for card removal, in milliseconds.DeviceException
- for standard errors as documented in DeviceException
.SmartCardReaderOperationResult waitForCardAbsent(int timeout) throws DeviceException
timeout
- The maximum time to wait for card removal, in milliseconds.SmartCardReaderOperationResult
object representing the result of the wait operation.DeviceException
- for standard errors as documented in DeviceException
.