summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-01-27 16:25:26 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-27 16:25:26 -0800
commitdd8b64c0a5b13c6606782d467beb48fd11bb36e0 (patch)
treefadc82722c1dd8ebe43b096821c94e0866095b27 /core/java/android
parent89316a2f2a0f351b22c7195c385b0c4f4de7bdb7 (diff)
parent1fce24b241e386af19ba7c5bc29af5d18461f4ff (diff)
downloadframeworks_base-dd8b64c0a5b13c6606782d467beb48fd11bb36e0.zip
frameworks_base-dd8b64c0a5b13c6606782d467beb48fd11bb36e0.tar.gz
frameworks_base-dd8b64c0a5b13c6606782d467beb48fd11bb36e0.tar.bz2
Merge "Add support for synchronous bulk USB transfers"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/hardware/UsbDevice.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/core/java/android/hardware/UsbDevice.java b/core/java/android/hardware/UsbDevice.java
index e6b38be..ca7dae3 100644
--- a/core/java/android/hardware/UsbDevice.java
+++ b/core/java/android/hardware/UsbDevice.java
@@ -193,6 +193,11 @@ public final class UsbDevice implements Parcelable {
/**
* Performs a control transaction on endpoint zero for this device.
+ * The direction of the transfer is determined by the request type.
+ * If requestType & {@link UsbConstants#USB_ENDPOINT_DIR_MASK} is
+ * {@link UsbConstants#USB_DIR_OUT}, then the transfer is a write,
+ * and if it is {@link UsbConstants#USB_DIR_IN}, then the transfer
+ * is a read.
*
* @param requestType request type for this transaction
* @param request request ID for this transaction
@@ -201,12 +206,28 @@ public final class UsbDevice implements Parcelable {
* @param buffer buffer for data portion of transaction,
* or null if no data needs to be sent or received
* @param length the length of the data to send or receive
+ * @param timeout in milliseconds
* @return length of data transferred (or zero) for success,
* or negative value for failure
*/
- public int sendControlRequest(int requestType, int request, int value,
- int index, byte[] buffer, int length) {
- return native_control_request(requestType, request, value, index, buffer, length);
+ public int controlTransfer(int requestType, int request, int value,
+ int index, byte[] buffer, int length, int timeout) {
+ return native_control_request(requestType, request, value, index, buffer, length, timeout);
+ }
+
+ /**
+ * Performs a bulk transaction on the given endpoint.
+ * The direction of the transfer is determined by the direction of the endpoint
+ *
+ * @param endpoint the endpoint for this transaction
+ * @param buffer buffer for data to send or receive,
+ * @param length the length of the data to send or receive
+ * @param timeout in milliseconds
+ * @return length of data transferred (or zero) for success,
+ * or negative value for failure
+ */
+ public int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout) {
+ return native_bulk_request(endpoint.getAddress(), buffer, length, timeout);
}
/**
@@ -305,7 +326,8 @@ public final class UsbDevice implements Parcelable {
private native boolean native_claim_interface(int interfaceID, boolean force);
private native boolean native_release_interface(int interfaceID);
private native int native_control_request(int requestType, int request, int value,
- int index, byte[] buffer, int length);
+ int index, byte[] buffer, int length, int timeout);
+ private native int native_bulk_request(int endpoint, byte[] buffer, int length, int timeout);
private native UsbRequest native_request_wait();
private native String native_get_serial();