MediaProvider has standardized on being an indexed view of files that
we discover on disk, so that we can always recover that indexed
information in case of user data wipe or corruption. This means
that MediaProvider no longer supports abstract "object references".
This doesn't prevent future MTP implementations from bringing back
object reference support, and the recommended path forward would
be to have MtpDatabase convert object references into playlist files
that are written to disk. MediaProvider will then gladly scan those
playlist files to be visible to users.
Shift to directly using the existing Files.getContentUri() API for
all MediaProvider interactions.
Bug: 137890034
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: Ib9513867c5074d1553b70fc7f188bfd594dcb52d
Since the only f_mtp.h header is deprecated in newer Android kernels,
copy this file out of bionic and to the only place it's used.
Test: Builds.
Change-Id: I06bab28f46b7d60bdb83a279b8ebec306b2e6661
When copy/paste folders from PC (e.g. windows),
there's an extra white space at the end of the folder names.
It cause the mkdir call failed with *Invalid argument* on device.
bug: 139645636
Change-Id: I4f0c017fd086b87180ba014722cdcf4d988e8bc5
In preparation for fuzz testing the MtpServer, we need to be able to
mock the IMtpHandle interface to avoid reading directly from the USB
interface.
Test: SANITIZE_TARGET='hwaddress fuzzer' mmm -j .
Test: atest mtp_ffs_handle_test
Change-Id: I79d023cbda75d6760bed22b659fa31328e9d81c5
change offset variable type from off_t to loff_t, then it won't overflow
when the offset value is larger than 2GB.
change the pwrite and pread function to be pwrite64 and pread64 so the
offset parameter won't overflow.
Change-Id: I45947479a59a4240fd708787384bcadee09d8947
Signed-off-by: faqiang.zhu <faqiang.zhu@nxp.com>
poll timeout not setting well in MTP ffs handler.
This will cause MTP ffs handler not going into sleep mode.
Bug: 121171744
Test: MTP 500 Mbyte file copy throughput from / to Host (no drop)
Change-Id: I9b8a7257670b8e536bf2ea81118d297211254984
Bug: http://b/116873221
Mark beginCopyObject() and endCopyObject() as pure virtual. If not,
Clang assumes that the TU which defines this function will contain the
vtable for the class as well. Since there's no out-of-line definition
of this funciton, no TU ends up with the vtable.
This causes a problem with coverage builds, which are built with -O0,
where calls don't get inlined, thereby requiring a definition of the
vtable. For non -O0 builds, the vtable is not required since the
virtual calls get inlined/optimized-out.
Test: Build with and without -O0.
Change-Id: I5e8dcf583a75af51af1e9dd31a6635aa2f9d4413
MtpDevice::sendObject is using int to define object size,
if the object size is bigger than 2GB, the size will be type-cast to
a negative number. And it will cause a endless loop in MtpDataPacket::write
until DUT auto reboot.
And JNI api android_mtp_MtpDevice_send_object requires that object
size must be uint32_t , so MtpDevice::sendObject works well after its
size parameter is changed from int to uint32_t.
Also change the return type of below API from int to int64_5
int64_t MtpDataPacket::write(struct usb_request *request, UrbPacketDivisionMode divisionMode,
int fd, size_t size)
so that it can return the right size in the case of writing 2~4G file.
Test: manual - connect Android device to Android Automotive
Test: manual - select MTP/File Transfer in android device
Test: manual - copy a file which is bigger than 2GB from automotive to the android device.
bug: 115451170
Change-Id: I65b89f195ef0527a802bccefc90721e536683b87
Signed-off-by: robinz1x <robinx.zhang@intel.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
When timeout is set as '0' for USB bulk transfer,
kernel waits indefinitely in case of faulty
responder devices. This results in device reboot
if hung_task panic is enabled in kernel.
So, add a finite timeout for USB bulk transfer.
Bug: 113991602
Test: manual run and test with bad responder device
Change-Id: I29631dfa3624afa4b4f9912a985351993cbc1698
Signed-off-by: sgopal1 <saranya.gopal@intel.com>
Remove extraneous logs which might include PII
Also add / modify some debug log
Bug: 111604284
Test: Copy file and check log
Change-Id: I7da65824be3d4d0b66f48d199ed181de96ded924
While received canceling event, error code is set but not
returned with correct state
Bug: 65644242
Test: manually copy file with / without cancel under Win10
Test: atest MtpFfsHandleTest
Change-Id: I601599c77bdd7c8615ed63970c8b22b8c5fcc315
Under MTP mode, new file created at device side shown size zero at PC side
due to file information is not updated to PC in time with ObjectAdded event
Bug: 77883345
Test: 1. Take screenshot of device under MTP mode with Win10 / Linux
2. file copy, delete, rename between PC and device
3. file copy, delete, rename on device with adb shell command
Test: adb shell am instrument -w android.mtp/
android.support.test.runner.AndroidJUnitRunner
Change-Id: If428064fb0104b53b8afd5b050a4fab4a09312f0
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
External sdcards are accessed through /mnt/media_rw,
so access() each touched file for sdcardfs to update
its metadata. This is done for all created/deleted/renamed
folders and files.
Bug: 77849654
Test: use mtp with emulated sdcard
Change-Id: Ic8cef9dc90e9cbc9783ff45a87c481833f910665
Linux uses UTF8 but java and MTP both
use UTF16. In a few places, this results
in the top byte of a UTF16 string being
truncated on conversion to UTF8.
Also, the hardcoded UTF to byte serialization
in MtpStringBuffer is incorrect.
Replace it with conversions from std, and
replace usages of MtpString with MtpStringBuffer.
Remove any remaining usages of libutils
and replace them with corresponding std
libraries.
Bug: 70546563
Test: Mtp works, tests pass
Test: file/folder names containing emoji can be transferred to/from
windows
Change-Id: Idbcb73f1beac17ce8a90843fa254e759dd1a6369
Creating a thread for each operation was
slightly wasteful. This also makes traces
easier to read.
Test: Transfer files, view traces
Bug: 76154677
Change-Id: I6028f113b9e5a84f01fb020a209a4dccadfdece4
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
MoveObject and DeleteObject require
begin() and end() methods in order to
maintain database consistency. delete() now
has to return errors.
Allow sendObject after sendObjectInfo since
the spec allows this.
Test: See tests for main MtpStorageManager change
Bug: 63143623
Change-Id: Ied105e884cafd36e861521dcc59740e23b330f5f
When copying directories, files and sub-directories should be
recursively copied. And we have to update the database by scanning
the entire directory.
Test: Copy directories with sub-directories and files inside to
another location. All directories and files are successfully
copied.
Change-Id: Iea9603b51bd0a944c87dedd962804d18d11984c4
Signed-off-by: kyle_tso <kyle_tso@htc.com>
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
For folders to recursively update their paths,
MediaProvider expects the folder to already exist
when database moveObject is called.
Bug: 66925416
Test: Move a folder containing files and use content query --uri content://media/external/file to verify paths are correct.
Change-Id: I45668159d2d3f99db088d8d4dcd065a79b732c44
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
Copy and move will use mkdir() if target
is a folder, and copyFile() if target is a file.
Move will recursively copy contents if moving
between different storages. Move will also
change the storageId.
Bug: 67028892
Test: Copy and move folders on win 10
Change-Id: If114ef74b9d8668cf66d45953d9ea8b17bc11ae8