Loading api/current.xml +11 −0 Original line number Diff line number Diff line Loading @@ -95449,6 +95449,17 @@ visibility="public" > </method> <method name="getRawDescriptors" return="byte[]" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getSerial" return="java.lang.String" abstract="false" core/java/android/hardware/usb/UsbDeviceConnection.java +12 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,17 @@ public class UsbDeviceConnection { return native_get_fd(); } /** * Returns the raw USB descriptors for the device. * This can be used to access descriptors not supported directly * via the higher level APIs. * * @return raw USB descriptors */ public byte[] getRawDescriptors() { return native_get_desc(); } /** * Claims exclusive access to a {@link android.hardware.usb.UsbInterface}. * This must be done before sending or receiving data on any Loading Loading @@ -160,6 +171,7 @@ public class UsbDeviceConnection { private native boolean native_open(String deviceName, FileDescriptor pfd); private native void native_close(); private native int native_get_fd(); private native byte[] native_get_desc(); 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, Loading core/jni/android_hardware_UsbDeviceConnection.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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", Loading Loading
api/current.xml +11 −0 Original line number Diff line number Diff line Loading @@ -95449,6 +95449,17 @@ visibility="public" > </method> <method name="getRawDescriptors" return="byte[]" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getSerial" return="java.lang.String" abstract="false"
core/java/android/hardware/usb/UsbDeviceConnection.java +12 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,17 @@ public class UsbDeviceConnection { return native_get_fd(); } /** * Returns the raw USB descriptors for the device. * This can be used to access descriptors not supported directly * via the higher level APIs. * * @return raw USB descriptors */ public byte[] getRawDescriptors() { return native_get_desc(); } /** * Claims exclusive access to a {@link android.hardware.usb.UsbInterface}. * This must be done before sending or receiving data on any Loading Loading @@ -160,6 +171,7 @@ public class UsbDeviceConnection { private native boolean native_open(String deviceName, FileDescriptor pfd); private native void native_close(); private native int native_get_fd(); private native byte[] native_get_desc(); 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, Loading
core/jni/android_hardware_UsbDeviceConnection.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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", Loading