Loading core/jni/android_hardware_UsbDeviceConnection.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -190,21 +190,17 @@ android_hardware_UsbDeviceConnection_bulk_request(JNIEnv *env, jobject thiz, return -1; } bool is_dir_in = (endpoint & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; jbyte *bufferBytes = (jbyte *)malloc(length); if (!is_dir_in && buffer) { env->GetByteArrayRegion(buffer, start, length, bufferBytes); jbyte* bufferBytes = NULL; if (buffer) { bufferBytes = (jbyte*)env->GetPrimitiveArrayCritical(buffer, NULL); } jint result = usb_device_bulk_transfer(device, endpoint, bufferBytes, length, timeout); jint result = usb_device_bulk_transfer(device, endpoint, bufferBytes + start, length, timeout); if (is_dir_in && buffer) { env->SetByteArrayRegion(buffer, start, length, bufferBytes); if (bufferBytes) { env->ReleasePrimitiveArrayCritical(buffer, bufferBytes, 0); } free(bufferBytes); return result; } Loading Loading
core/jni/android_hardware_UsbDeviceConnection.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -190,21 +190,17 @@ android_hardware_UsbDeviceConnection_bulk_request(JNIEnv *env, jobject thiz, return -1; } bool is_dir_in = (endpoint & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; jbyte *bufferBytes = (jbyte *)malloc(length); if (!is_dir_in && buffer) { env->GetByteArrayRegion(buffer, start, length, bufferBytes); jbyte* bufferBytes = NULL; if (buffer) { bufferBytes = (jbyte*)env->GetPrimitiveArrayCritical(buffer, NULL); } jint result = usb_device_bulk_transfer(device, endpoint, bufferBytes, length, timeout); jint result = usb_device_bulk_transfer(device, endpoint, bufferBytes + start, length, timeout); if (is_dir_in && buffer) { env->SetByteArrayRegion(buffer, start, length, bufferBytes); if (bufferBytes) { env->ReleasePrimitiveArrayCritical(buffer, bufferBytes, 0); } free(bufferBytes); return result; } Loading