MtpFfsHandle now uses kaio to handle usb data.
This achieves better performance without using
the endpoint alloc ioctl.
This also allows ep0 events to be handled without
race conditions. Events will also include control
requests, which will allow both host and device
initiated cancellation.
Bug: 37916658
Bug: 36802721
Test: Transfer various size files, run MtpFfsHandleTest
Test: Cancel transfer on Windows
Test: Allow device to cancel transfer on Windows
Change-Id: Ib3ce996f00782ce7f68f29b2510dbc17f09fdf14
This takes a reference to the event,
which then can become invalid. Instead
pass by copy like normal.
Bug: 64529223
Test: No crash
Change-Id: I2ac7bd0002e6d0ce1c547c24334dfd2926ed7090
(cherry picked from commit 7360303d3e)
AFT will not read the events endpoint at all
causing every sendEvent() to block. Since
event ordering doesn't really matter, send
events in their own detached thread instead.
Bug: 36802721
Test: Connect AFT, create a folder from device, check not frozen
Change-Id: I4b8aee93c19fa9c73e6b2f34d9794a491b2433e1
(cherry picked from commit d80492b819)
Fix zero packet read/write in corner cases
with initial read/writes. This affects transfers
of 16372 bytes to the device and transfers of
1012 bytes (or packet size - 12) from the device.
Test: Transfer various length files
Bug: 37175601
Change-Id: Ic1281e8757d1a33d78c66d2c57319b5ee38d6a46
Fix the following warning:
frameworks/av/media/mtp/MtpServer.cpp:1098:5: warning: Assigned value is
garbage or undefined [clang-analyzer-core.uninitialized.Assign]
BUG:None
TEST:Warnings fixed.
Change-Id: If4e54ebd9b865e2e6cdc7666da0c9987a918df7c
Ensure that a zero length packet is properly sent
/ received when handling data that is a multiple of the
endpoint size.
This fixes an issue where files whose size is a multiple
of the endpoint size would hang during transfer.
Bug: 37175601
Test: check successful file transfer.
Change-Id: Iaf3cea18422234d65b59f5961ef9fb3f3ee2049a
Prevents the thread struct from being deallocated
before the thread has finished.
Bug: 35152606
Test: Transfer files in both directions, verify behavior when
interrupted
Change-Id: Ic247072234977709711366636e6a39031fbc125a
In situations where MtpServer is in a bad state, this will prevent
the configure call from blocking indefinitely, which will prevent
a few visible problems and allow the state to recover on the next
config change.
Bug: 34873000
Test: Connect to AA test sled
Change-Id: I5daf9cfcec69c967bde6bf3f6fd90e1c434e18bb
Since we only support one open session, this
command is the same as CLOSE_SESSION.
Test: mtp-reset
Change-Id: I2e95687a685af239c92473feb7c98419fcd55a1e
This fixes warning: The left operand of '%' is a garbage value.
Bug: None.
Test: The warning is gone.
Change-Id: I191e5bfd9d5f5136afcc2b5d8277c44b7d223998
This fixes the warning warning: Passed-by-value struct argument contains
uninitialized data (e.g., field: 'command') [clang-analyzer-core.CallAndMessage]
Bug: None
Test: The warning is gone.
Change-Id: I3e06ff484bdec995c5125433acb5c3f14dc29dd9
This fixes a warning: Access to field 'mPlaybackFormats' results
in a dereference of a null pointer (loaded from field 'mDeviceInfo')
[clang-analyzer-core.NullDereference]
Bug: None
Test: Static analyzer no longer complains, bullhead still boots with no
apparent issues.
Change-Id: I71ce486c667441d9b90ef63c2df8d23d70254639
Unlike the read() and write() calls, the ioctl() call
does not wait for endpoints to be enabled, which is
problematic if ioctls() are the first calls on the
usb connection, since they may be called before the
endpoints are set up. We'll have to retry if this
causes them to fail.
Bug: 34822471
Test: Change configs to mtp and ptp
Change-Id: I89610b9614c33f0b22535cc68cd0c9b502cb55c9
Linux apps use GetPartialObject to access
MTP files directly. Fix file offset handling
as well as lengths shorter than packet size.
Bug: 34822471
Test: Attach photos in Gmail, open directly from device
Change-Id: I9986cd8c70ed261f07e8f96a72e53b87341dd93f
Workloads that send a large number of small files could
repeatedly allocate and free the buffer, causing fragmentation
and eventually running out of allocable memory. Instead
have the allocation be once per MTP session, and retry
with smaller buffers if it fails initially.
Bug: 34741015
Bug: 34822471
Test: Transfer files via MTP
Change-Id: I775376076d3a0c26765b211100830ea0c08450ef
This way they don't immediately destruct. Also
up the logging for an allocation failure and use
posix_madvise to possibly improve memory performance.
Test: Transfer files and verify that allocs are scoped properly
Bug: 30976142
Change-Id: If8d2c03cefcc98a83bbb57618c35337529437f73