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