summaryrefslogtreecommitdiffstats
path: root/core/jni/android_hardware_UsbDeviceConnection.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-05-19 13:34:44 -0400
committerMike Lockwood <lockwood@android.com>2011-05-19 13:34:44 -0400
commit90f902afde7ac92cdb60363d517e9d142e1f1977 (patch)
tree5f98f00537d26214ae7d42f95f05e98761765413 /core/jni/android_hardware_UsbDeviceConnection.cpp
parent191c1fbb7465dc6ba0cb2fa40c96b690ea73d68c (diff)
parentc1730dcf8971950a0e32e3f4fc6e3fb08b7395cd (diff)
downloadframeworks_base-90f902afde7ac92cdb60363d517e9d142e1f1977.zip
frameworks_base-90f902afde7ac92cdb60363d517e9d142e1f1977.tar.gz
frameworks_base-90f902afde7ac92cdb60363d517e9d142e1f1977.tar.bz2
resolved conflicts for merge of c1730dcf to master
Change-Id: I9e0f9740930c7d3acb51235dd4c67cf2ed54a486
Diffstat (limited to 'core/jni/android_hardware_UsbDeviceConnection.cpp')
-rw-r--r--core/jni/android_hardware_UsbDeviceConnection.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/jni/android_hardware_UsbDeviceConnection.cpp b/core/jni/android_hardware_UsbDeviceConnection.cpp
index 4d73bf3..68be9e1 100644
--- a/core/jni/android_hardware_UsbDeviceConnection.cpp
+++ b/core/jni/android_hardware_UsbDeviceConnection.cpp
@@ -83,6 +83,27 @@ android_hardware_UsbDeviceConnection_get_fd(JNIEnv *env, jobject thiz)
return usb_device_get_fd(device);
}
+static jbyteArray
+android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz)
+{
+ char buffer[16384];
+ int fd = android_hardware_UsbDeviceConnection_get_fd(env, thiz);
+ if (fd < 0) return NULL;
+ lseek(fd, 0, SEEK_SET);
+ int length = read(fd, buffer, sizeof(buffer));
+ if (length < 0) return NULL;
+
+ jbyteArray ret = env->NewByteArray(length);
+ if (ret) {
+ jbyte* bytes = (jbyte*)env->GetPrimitiveArrayCritical(ret, 0);
+ if (bytes) {
+ memcpy(bytes, buffer, length);
+ env->ReleasePrimitiveArrayCritical(ret, bytes, 0);
+ }
+ }
+ return ret;
+}
+
static jboolean
android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz,
int interfaceID, jboolean force)
@@ -211,6 +232,7 @@ static JNINativeMethod method_table[] = {
(void *)android_hardware_UsbDeviceConnection_open},
{"native_close", "()V", (void *)android_hardware_UsbDeviceConnection_close},
{"native_get_fd", "()I", (void *)android_hardware_UsbDeviceConnection_get_fd},
+ {"native_get_desc", "()[B", (void *)android_hardware_UsbDeviceConnection_get_desc},
{"native_claim_interface", "(IZ)Z",(void *)android_hardware_UsbDeviceConnection_claim_interface},
{"native_release_interface","(I)Z", (void *)android_hardware_UsbDeviceConnection_release_interface},
{"native_control_request", "(IIII[BII)I",