summaryrefslogtreecommitdiff
path: root/api/api.go
diff options
context:
space:
mode:
author tomm <tomm@squareup.com> 2024-11-07 02:42:38 +0000
committer Tom Mulcahy <tomm@squareup.com> 2024-12-02 20:54:42 +0000
commit78033b77795fd5d0d56d56a973543c3993af3e76 (patch)
tree98955410ccbdcfa1f9407dfa4f80ceafbadcb595 /api/api.go
parent2e1a903f24a285faa888840a8fcf498bfdb6b6aa (diff)
usb: Use Get/SetByteArrayRegion in controlTransfer
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 controlTransfer, we call usb_device_control_transfer between GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical. usb_device_control_transfer is a blocking call so this can lead to GC hangs. Instead, we allocate a new buffer and then call GetByteArrayRegion/SetByteArrayRegion before/after usb_device_control_transfer, depending on the direction of the endpoint. This change is analogous to https://android-review.googlesource.com/c/platform/frameworks/base/+/3056082 which fixed the same problem in bulkTransfer. Test: I ran the USB Accessory Test - https://source.android.com/docs/compatibility/cts/verifier#testing-accessory-8 - both directions (this change on the DUT and this change on the companion device) Change-Id: I3f670121fc1c65f046376aa819d638edb446658a
Diffstat (limited to 'api/api.go')
0 files changed, 0 insertions, 0 deletions