History log of /frameworks/av/media/mtp/MtpFfsHandle.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
297912b6c9046ac3a00acc2dfd9389c6feb557ad 11-May-2018 Jerry Zhang <zhangjerry@google.com> Remove limitation on read/write size

Previously ios called through read write
were limited to 16kb because read packets
are very small. However, write packets can
be greater than that amount in cases where
a folder contains over 4k items. Thus,
remove the limitation.

Add corresponding ReadLarge and WriteLarge
tests as well.

Bug: 79214960
Test: mtp_ffs_handle_test passes, Mtp works
with large folders

Change-Id: I8a980612c3eb941552ff4dd11ac631d1dc5d3347
/frameworks/av/media/mtp/MtpFfsHandle.cpp
63dac45aa868b9048c028967e9865c90a9ba544d 07-Dec-2017 Jerry Zhang <zhangjerry@google.com> Remove configure() from Mtp

Instead of configuring the server each
time the connection happens, UsbService
will now pass in the control fd with the
descriptors already written. Also, PTP
endpoints have been moved to their own
directory at /dev/usb-ffs/ptp rather than
using the same ones as mtp.

Bug: 72877174
Test: Verify PTP and MTP config changes work
Change-Id: I9a0336afd610aa397c9947568c308afb89b27c08
/frameworks/av/media/mtp/MtpFfsHandle.cpp
fbc8b0683630a0f14dda04f71da7df9a5f13821f 23-Oct-2017 Jerry Zhang <zhangjerry@google.com> Always set sys.usb.ffs.mtp.ready during configure

Sometimes, due to a race, the configure
will fail even though descriptors are actually
written because MtpServer did not die properly.
MtpServer lifetime is fixed properly in master
with multiplexed io, but to work around the
issue here, we set the property at all times.

Also reduce the timeout to leave room for
UsbDeviceManager.

Bug: 67844294
Test: Plug/replug device on sled with usb debugging off x50
Test: Verify that the race is hit, but projection still starts
Test: Verify that all other usb configurations still work
Change-Id: I39dd4d3db95e087f065d58ba80ca980559920c99
/frameworks/av/media/mtp/MtpFfsHandle.cpp
69b74506f9d658fd9ed18676eb75b86fdb7d7d73 03-Oct-2017 Jerry Zhang <zhangjerry@google.com> Move mtp descriptors into separate source, add tests

Functionfs descriptors are moved into MtpDescriptors.cpp.
Added assertions and tests to ensure that descriptors aren't
unintentionally changed, and bug numbers in comments for
future context.

Test: updated MtpFfsHandle_test passes
Bug: 67367056
Change-Id: I90eb5e48a687f366b8919621718e976e83b5b064
/frameworks/av/media/mtp/MtpFfsHandle.cpp
51bf9853c28e6d193e6521a698866d675d854431 31-Aug-2017 Jerry Zhang <zhangjerry@google.com> Add MTP and PTP OS descriptors.

This adds OS descriptor functionality for
devices that don't use configfs for OS descriptors.

Test: usb sniffer, verify descriptors sent
Bug: 64790536
Change-Id: Iec417606f86fe4d7492273d09d685ab2ec3d03c8
(cherry picked from commit 95ea161b05040412d95b5add98dc882e3be4075c)
/frameworks/av/media/mtp/MtpFfsHandle.cpp
df69dd33b4d8a2f9926b5eaccbf53ee7f67475c2 04-May-2017 Jerry Zhang <zhangjerry@google.com> Switch MtpFfsHandle to aio, add control functions.

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
008f4df3ca1bdb0e0df80fff68467a95ddbc6c40 10-Aug-2017 Jerry Zhang <zhangjerry@google.com> Stop capturing mtp_event by reference in lambda

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 7360303d3e93cd6a5fd8c5c4340a335416bd0f28)
/frameworks/av/media/mtp/MtpFfsHandle.cpp
94ef0eaba32244d8732394291873f2abd4c63da3 26-Jul-2017 Jerry Zhang <zhangjerry@google.com> mtp: Send events async.

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 d80492b819b3934475596ec4afda979bad3bd126)
/frameworks/av/media/mtp/MtpFfsHandle.cpp
5410756e75fb7567540f13d3813f42f4ac3838a0 15-May-2017 Jerry Zhang <zhangjerry@google.com> Fix file transfer corner cases.

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
c9cbf9870c28d5c65e7363db5291a4b89e1a8e8d 15-Apr-2017 Jerry Zhang <zhangjerry@google.com> Fix zero length packet handling

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
7063c936e50326883e672837036381f77080c2f3 05-Apr-2017 Jerry Zhang <zhangjerry@google.com> Wait for threads to finish before returning.

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
0475d911fcc1e6e1b4f49626f59a0a07038590fa 03-Apr-2017 Jerry Zhang <zhangjerry@google.com> Add timeout to lock in MtpServer configure

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
2a14168f59bf5ad6e0cddb28c23f3e7fef75ac89 13-Feb-2017 Jerry Zhang <zhangjerry@google.com> Raise MTP max burst values.

Slightly increases transfer speeds on USB 3.0 connections.

Test: Transfer files
Change-Id: I25fb0a37fa92063356c4a2a0e0ba7f011b6b0527
/frameworks/av/media/mtp/MtpFfsHandle.cpp
746f8acd98c474be1c8b32df570667fda219bb10 22-Feb-2017 Yunlian Jiang <yunlian@google.com> fix uninitialized warning.

This fixes warning: The left operand of '%' is a garbage value.

Bug: None.
Test: The warning is gone.
Change-Id: I191e5bfd9d5f5136afcc2b5d8277c44b7d223998
/frameworks/av/media/mtp/MtpFfsHandle.cpp
94b13227f4c77bb303d7d004d889f6bf6a65f64c 09-Feb-2017 Jerry Zhang <zhangjerry@google.com> Increase EP_ALLOC ioctl number.

This prevents conflict with future upstream ioctls.

Test: Perform a file transfer.
Change-Id: If7313a048f528dfa57ef2fe52932ed664ad6f234
/frameworks/av/media/mtp/MtpFfsHandle.cpp
b4f54266042f0553b41409a3d1f0542b684c2129 03-Feb-2017 Jerry Zhang <zhangjerry@google.com> Retry allocations in case of ENODEV

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
4418030f45cca8cad25051f49b142988fb635037 04-Feb-2017 Jerry Zhang <zhangjerry@google.com> Fix GetPartialObject on FFS

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
cc9d0fdd302cf997607055e0a8b5559509cba766 27-Jan-2017 Jerry Zhang <zhangjerry@google.com> Make Mtp FFS allocations per session rather than per file

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
e9d94421825dd90f0036d0dbde59b1f00f85f23b 18-Jan-2017 Jerry Zhang <zhangjerry@google.com> Keep ScopedEndpointBufferAlloc in variables

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
/frameworks/av/media/mtp/MtpFfsHandle.cpp
6a7905217bc840eae38125bb9ebced994b21442b 12-Jan-2017 Jerry Zhang <zhangjerry@google.com> Re-add MTP interface string

The string is used in some hosts like Mac to
check for MTP devices.

Test: Connect device
Bug: 30976142
Change-Id: Iac616997dc8afd0bdf03de0d13dee7baa6483904
/frameworks/av/media/mtp/MtpFfsHandle.cpp
5a804b923e2faa4bf9f02b238b94abceb3b6d0fa 16-Dec-2016 Jerry Zhang <zhangjerry@google.com> Use FUNCTIONFS_ENDPOINT_ALLOC_BUFFER ioctl to improve performance.

The ioctl preallocates kernel buffers for the read/write syscalls,
reducing memory fragmentation and allowing for larger buffers,
as well as removing the kmalloc overhead.

Test: Manual
Change-Id: I9f5fef1b1625c1a2cda374541d8042f7e0ba78f5
/frameworks/av/media/mtp/MtpFfsHandle.cpp
487be61fb0a38873aec1d12da92437fba5e728f2 24-Oct-2016 Jerry Zhang <zhangjerry@google.com> Refactored Mtp driver interface into multiple classes.

Added new interface for FunctionFS. This allows most of
the driver code to exist in userspace. The driver will
automatically use FunctionFS if it is enabled for that
device, otherwise it will default to the kernel driver.

The intention is to eventually deprecate the kernel driver.

Bug: 30976142
Change-Id: I36b8d16ca254fddd995b3ea1bd3d37b0ff4a28f7
Test: New automated tests for MtpFfsHandle, AsyncIO.
Manual testing on each device.
/frameworks/av/media/mtp/MtpFfsHandle.cpp