Methods Summary |
---|
public boolean | cancel()Cancels a pending queue operation.
return native_cancel();
|
public void | close()Releases all resources related to this request.
mEndpoint = null;
native_close();
|
void | dequeue()
boolean out = (mEndpoint.getDirection() == UsbConstants.USB_DIR_OUT);
int bytesRead;
if (mBuffer.isDirect()) {
bytesRead = native_dequeue_direct();
} else {
bytesRead = native_dequeue_array(mBuffer.array(), mLength, out);
}
if (bytesRead >= 0) {
mBuffer.position(Math.min(bytesRead, mLength));
}
mBuffer = null;
mLength = 0;
|
protected void | finalize()
try {
if (mEndpoint != null) {
Log.v(TAG, "endpoint still open in finalize(): " + this);
close();
}
} finally {
super.finalize();
}
|
public java.lang.Object | getClientData()Returns the client data for the request.
This can be used in conjunction with {@link #setClientData}
to associate another object with this request, which can be useful for
maintaining state between calls to {@link #queue} and
{@link android.hardware.usb.UsbDeviceConnection#requestWait}
return mClientData;
|
public UsbEndpoint | getEndpoint()Returns the endpoint for the request, or null if the request is not opened.
return mEndpoint;
|
public boolean | initialize(UsbDeviceConnection connection, UsbEndpoint endpoint)Initializes the request so it can read or write data on the given endpoint.
Whether the request allows reading or writing depends on the direction of the endpoint.
mEndpoint = endpoint;
return native_init(connection, endpoint.getAddress(), endpoint.getAttributes(),
endpoint.getMaxPacketSize(), endpoint.getInterval());
|
private native boolean | native_cancel()
|
private native void | native_close()
|
private native int | native_dequeue_array(byte[] buffer, int length, boolean out)
|
private native int | native_dequeue_direct()
|
private native boolean | native_init(UsbDeviceConnection connection, int ep_address, int ep_attributes, int ep_max_packet_size, int ep_interval)
|
private native boolean | native_queue_array(byte[] buffer, int length, boolean out)
|
private native boolean | native_queue_direct(java.nio.ByteBuffer buffer, int length, boolean out)
|
public boolean | queue(java.nio.ByteBuffer buffer, int length)Queues the request to send or receive data on its endpoint.
For OUT endpoints, the given buffer data will be sent on the endpoint.
For IN endpoints, the endpoint will attempt to read the given number of bytes
into the specified buffer.
If the queueing operation is successful, we return true and the result will be
returned via {@link android.hardware.usb.UsbDeviceConnection#requestWait}
boolean out = (mEndpoint.getDirection() == UsbConstants.USB_DIR_OUT);
boolean result;
if (buffer.isDirect()) {
result = native_queue_direct(buffer, length, out);
} else if (buffer.hasArray()) {
result = native_queue_array(buffer.array(), length, out);
} else {
throw new IllegalArgumentException("buffer is not direct and has no array");
}
if (result) {
// save our buffer for when the request has completed
mBuffer = buffer;
mLength = length;
}
return result;
|
public void | setClientData(java.lang.Object data)Sets the client data for the request.
This can be used in conjunction with {@link #getClientData}
to associate another object with this request, which can be useful for
maintaining state between calls to {@link #queue} and
{@link android.hardware.usb.UsbDeviceConnection#requestWait}
mClientData = data;
|