public abstract class UsbCloverManager<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
UsbCloverManager.InputResult |
static class |
UsbCloverManager.UsbConnectException |
static class |
UsbCloverManager.UsbDeviceNotFoundException |
| Modifier and Type | Field and Description |
|---|---|
protected static int |
CONNECTION_RETRY_WAIT_MS |
protected static int |
CONNECTION_TIMEOUT_MS |
protected android.hardware.usb.UsbDeviceConnection |
mConnection |
protected static int |
READ_TIMEOUT_MS |
protected static int |
SETUP_RETRY_WAIT_MS |
protected static int |
SETUP_TIMEOUT_MS |
protected static boolean |
VERBOSE |
protected static int |
WRITE_TIMEOUT_MS |
| Constructor and Description |
|---|
UsbCloverManager(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
disconnect() |
static android.hardware.usb.UsbDevice |
findDevice(android.hardware.usb.UsbManager usbManager,
android.util.Pair<java.lang.Integer,java.lang.Integer>[] vendorProductIds) |
protected abstract int |
getMaxWriteDataSize() |
protected abstract int |
getReadSize() |
protected int |
getReadTimeOut()
Returns the amount of time to wait before read fails, 0 means wait forever.
|
protected abstract android.util.Pair<java.lang.Integer,java.lang.Integer>[] |
getVendorProductIds() |
protected boolean |
isBulkInterface() |
boolean |
isConnected() |
protected boolean |
isInterfaceMatch(android.hardware.usb.UsbInterface usbInterface) |
static boolean |
isMatch(android.hardware.usb.UsbDevice device,
android.util.Pair<java.lang.Integer,java.lang.Integer>[] vendorProductIds) |
protected void |
onPostDisconnect()
Called after disconnect is complete, does nothing by default and may be overridden.
|
protected void |
onPreConnect()
Called before a connection is attempted, does nothing by default and may be overridden.
|
protected void |
onTransferError()
Called when a transfer error occurs, does nothing by default and may be overridden.
|
void |
open()
Open a connection to the USB device and begin a session.
|
protected com.clover.remote.client.transport.usb.UsbCloverManager.DeviceStatus |
postStatusChange(com.clover.remote.client.transport.usb.UsbCloverManager.DeviceStatus status) |
protected UsbCloverManager.InputResult |
processInputData(byte[] inputData,
java.io.ByteArrayOutputStream outputStream,
T params)
Optionally override this method to perform data processing on the input data bytes before they are returned.
|
protected byte[] |
processOutputData(byte[] outputData,
T params)
Optionally override this method to perform data processing on the output bytes before they are sent.
|
byte[] |
read(T params) |
protected byte[] |
unwrapReadPacket(java.nio.ByteBuffer inDataBuffer) |
protected byte[] |
wrapWritePacket(java.nio.ByteBuffer outDataBuffer,
int numBytesToTransfer) |
int |
write(byte[] outputData,
T params) |
protected static final boolean VERBOSE
protected static final int CONNECTION_TIMEOUT_MS
protected static final int CONNECTION_RETRY_WAIT_MS
protected static final int SETUP_TIMEOUT_MS
protected static final int SETUP_RETRY_WAIT_MS
protected static final int READ_TIMEOUT_MS
protected static final int WRITE_TIMEOUT_MS
protected android.hardware.usb.UsbDeviceConnection mConnection
public void open()
throws UsbCloverManager.UsbConnectException
UsbCloverManager.UsbConnectException - if connecting to the device failedprotected abstract int getReadSize()
protected abstract int getMaxWriteDataSize()
protected void onPreConnect()
public static android.hardware.usb.UsbDevice findDevice(android.hardware.usb.UsbManager usbManager,
android.util.Pair<java.lang.Integer,java.lang.Integer>[] vendorProductIds)
protected abstract android.util.Pair<java.lang.Integer,java.lang.Integer>[] getVendorProductIds()
public static boolean isMatch(android.hardware.usb.UsbDevice device,
android.util.Pair<java.lang.Integer,java.lang.Integer>[] vendorProductIds)
protected boolean isBulkInterface()
protected boolean isInterfaceMatch(android.hardware.usb.UsbInterface usbInterface)
public void disconnect()
protected void onPostDisconnect()
public final boolean isConnected()
public int write(byte[] outputData,
T params)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOExceptionjava.lang.InterruptedExceptionpublic byte[] read(T params) throws java.io.IOException, java.lang.InterruptedException
java.io.IOExceptionjava.lang.InterruptedExceptionprotected void onTransferError()
protected byte[] wrapWritePacket(java.nio.ByteBuffer outDataBuffer,
int numBytesToTransfer)
protected byte[] unwrapReadPacket(java.nio.ByteBuffer inDataBuffer)
protected int getReadTimeOut()
protected byte[] processOutputData(byte[] outputData,
T params)
protected UsbCloverManager.InputResult processInputData(byte[] inputData, java.io.ByteArrayOutputStream outputStream, T params)
#processOutputData(byte[], T) this function may be called multiple times in a single transfer depending on the
return value of this functioninputData - buffer containing bytes read from the USB deviceoutputStream - stream containing bytes that will be returned to the callerparams - additional parameters which may allow the implementation to modify the way the byte array is interpretedprotected final com.clover.remote.client.transport.usb.UsbCloverManager.DeviceStatus postStatusChange(com.clover.remote.client.transport.usb.UsbCloverManager.DeviceStatus status)