java.lang.Object | |
↳ | android.hardware.usb.UsbDeviceConnection |
This class is used for sending and receiving data and control messages to a USB device.
Instances of this class are created by openDevice(UsbDevice)
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Performs a bulk transaction on the given endpoint.
| |||||||||||
Performs a bulk transaction on the given endpoint.
| |||||||||||
Claims exclusive access to a
UsbInterface .
| |||||||||||
Releases all system resources related to the device.
| |||||||||||
Performs a control transaction on endpoint zero for this device.
| |||||||||||
Performs a control transaction on endpoint zero for this device.
| |||||||||||
Returns the native file descriptor for the device, or
-1 if the device is not opened.
| |||||||||||
Returns the raw USB descriptors for the device.
| |||||||||||
Returns the serial number for the device.
| |||||||||||
Releases exclusive access to a
UsbInterface .
| |||||||||||
Waits for the result of a
queue(ByteBuffer, int) operation
Note that this may return requests queued on multiple
UsbEndpoint s.
| |||||||||||
Sets the device's current
UsbConfiguration .
| |||||||||||
Sets the current
UsbInterface .
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Performs a bulk transaction on the given endpoint. The direction of the transfer is determined by the direction of the endpoint.
This method transfers data starting from index 0 in the buffer.
To specify a different offset, use
bulkTransfer(UsbEndpoint, byte[], int, int, int)
.
endpoint | the endpoint for this transaction |
---|---|
buffer | buffer for data to send or receive |
length | the length of the data to send or receive |
timeout | in milliseconds |
Performs a bulk transaction on the given endpoint. The direction of the transfer is determined by the direction of the endpoint.
endpoint | the endpoint for this transaction |
---|---|
buffer | buffer for data to send or receive |
offset | the index of the first byte in the buffer to send or receive |
length | the length of the data to send or receive |
timeout | in milliseconds |
Claims exclusive access to a UsbInterface
.
This must be done before sending or receiving data on any
UsbEndpoint
s belonging to the interface.
intf | the interface to claim |
---|---|
force | true to disconnect kernel driver if necessary |
Releases all system resources related to the device.
Once the object is closed it cannot be used again.
The client must call openDevice(UsbDevice)
again
to retrieve a new instance to reestablish communication with the device.
Performs a control transaction on endpoint zero for this device.
The direction of the transfer is determined by the request type.
If requestType & USB_ENDPOINT_DIR_MASK
is
USB_DIR_OUT
, then the transfer is a write,
and if it is USB_DIR_IN
, then the transfer
is a read.
This method transfers data starting from index 0 in the buffer.
To specify a different offset, use
controlTransfer(int, int, int, int, byte[], int, int, int)
.
requestType | request type for this transaction |
---|---|
request | request ID for this transaction |
value | value field for this transaction |
index | index field for this transaction |
buffer | buffer for data portion of transaction, or null if no data needs to be sent or received |
length | the length of the data to send or receive |
timeout | in milliseconds |
Performs a control transaction on endpoint zero for this device.
The direction of the transfer is determined by the request type.
If requestType & USB_ENDPOINT_DIR_MASK
is
USB_DIR_OUT
, then the transfer is a write,
and if it is USB_DIR_IN
, then the transfer
is a read.
requestType | request type for this transaction |
---|---|
request | request ID for this transaction |
value | value field for this transaction |
index | index field for this transaction |
buffer | buffer for data portion of transaction, or null if no data needs to be sent or received |
offset | the index of the first byte in the buffer to send or receive |
length | the length of the data to send or receive |
timeout | in milliseconds |
Returns the native file descriptor for the device, or -1 if the device is not opened. This is intended for passing to native code to access the device.
Returns the raw USB descriptors for the device. This can be used to access descriptors not supported directly via the higher level APIs.
Returns the serial number for the device. This will return null if the device has not been opened.
Releases exclusive access to a UsbInterface
.
Waits for the result of a queue(ByteBuffer, int)
operation
Note that this may return requests queued on multiple
UsbEndpoint
s.
When multiple endpoints are in use, getEndpoint()
and
getClientData()
can be useful in determining
how to process the result of this function.
Sets the device's current UsbConfiguration
.
Sets the current UsbInterface
.
Used to select between two interfaces with the same ID but different alternate setting.