diff options
author | 2024-04-19 09:16:24 -0700 | |
---|---|---|
committer | 2024-09-19 21:02:25 +0000 | |
commit | 04cfe01ff73b929335cbbf2036cdac2cdd22f8ef (patch) | |
tree | e9e380fd0bd3c3751a9fdacee38f87cdf050764a /services/appfunctions/java | |
parent | 2e1a903f24a285faa888840a8fcf498bfdb6b6aa (diff) |
usb: Use Get/SetByteArrayRegion in bulkTransfer
This change fixes https://issuetracker.google.com/issues/335003907
This change replaces
GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical with
GetByteArrayRegion/SetByteArrayRegion.
This change is needed because the critical API variants are not
appropriate for this context. See the JNI docs:
After calling GetPrimitiveArrayCritical, the native code should not run
for an extended period of time before it calls
ReleasePrimitiveArrayCritical.
In bulkTransfer, we call usb_device_bulk_transfer between
GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical.
usb_device_bulk_transfer is a blocking call so this can lead to GC
hangs.
Instead, we allocate a new buffer with malloc and then call
GetByteArrayRegion/SetByteArrayRegion before/after
usb_device_bulk_transfer, depending on the direction of the endpoint.
Test: I ran UsbTests. I also sent a "TEST UNIT READY" to a USB drive and
verified the response.
Change-Id: I5c82aac3fe99e1f11044f20091bf3a940bc8f6a7
Diffstat (limited to 'services/appfunctions/java')
0 files changed, 0 insertions, 0 deletions