MtpDocumentsProvider remembers the mapping between SAF's ID and MTP's
ID. Sometimes we need to do heuristic to restore the mapping when MTP
device is reconnected.
Previously we do the mapping files that shares the same name more
strictly. For example,
1. Found file name "test.txt". Assign document ID "1".
2. MTP device is disconnected and the MTP ID of "1" is lost.
3. Found two files that have same name "test.txt" in the same directory.
Previously we don't reuse existing document ID "1" for neither of two
"test.txt" because it's not 1-to-1 mapping and we cannot determine which
one should be mapped with existing document ID. It means we need the
complete list of files in a directory to remap IDs. It takes long time
to fetch all file names in a directory when a directory has 100+
files. It's rare that a MTP device has the two files sharing the same
name in the same directory. Also the strict rule makes the mapping code
more complex.
The CL relax the rule of mapping, and it allows to reuse existing
document ID even if it is not 1-to-1 mapping. For the previous example,
it assigns "1" for either of "test.txt".
BUG=27053734
Change-Id: I19406fafc21f13ab94ba99411ce5e7f55ce7f658
(cherry picked from commit acdbc6e740ffbd465488b6eb0cf9388d43ae860a)
MTP spec defines format code as a file type of object, but we don't have
format code for some file types like PDF. This CL adds fallback that
tries to obtain mime type from file name in such case.
BUG=27004957
Change-Id: Id61352bf4726f4e044e57edadcefbf179fe3f882
When device has multiple storages, storage are shown as directory under
the device root. In this case, we would not like to add device name to
storage.
Note that we still use "device name + storage name" for root name if the
device has a single storage because we skip storage directory in this
case and shows storage's contents directly under the device.
BUG=26625708
Change-Id: Ie13b044e71ae9b5131c4a01ee9d605023d05f168
Previously MtpDocumentsProvider opens a device just after device is
connected to Android. But MtpDocumentsProvider should open MTP device on
demand so that other applications can open device if user starts to use
the application before using MtpDocumentsProvider.
BUG=26625708
Change-Id: I6083b8c7cef49ee6e9fb0d15ca4adc129734f3eb
The tree structure of MTP model looks like /device/storage/objects. But
almost all MTP device has only single storage, so it's redundant to show
a single storage as a child of device in UI.
MtpDocumentsProvider has a special logic to skip single storage, and
shows storage's object as a children of device in such case. Previously
the logic was applied when MtpDocumentsProvider returned a root
list. The provider returns a storage as a Documents.Root, instead of
device if the device has only one storage.
However the number of root cannot be obtain for closed device. Thus the
previous logic did not work for closed devices that have a single
storage. The CL moves the logic from queryRoot to
queryChildDocuments. Now MtpDocumentsProvider always returns a device as
root, then it returns storage's objects as the device's children, where
we has already opened the device.
BUG=26481574
Change-Id: I25af0fc220410e321a378d67f226798ec4bba19c
The CL adds launch notification that are shown after MTP/PTP device is
connected to Android device. By tapping the notification, Users can
launch an applicaiton that can handle USB_DEVICE_ATTACHED intent of MTP
device.
BUG=26611224
Change-Id: I6fd179ccd436531dfff6ff9a50dc2b754c20f190
Before MtpDocumentsProvider opens a device, it cannot fetch the storage
size. Currently it says 0 bytes available. But actually it is unknown.
BUG=26866812
Change-Id: I3f24773da8e76fe1092c11f1335aac9703f1b3f9
Previously AppFuse getObjectBytes returns byte array and the array's
length needs to equals to the exact number of bytes the method read.
The CL change the function signature so that it can return the number of
read bytes. And reuse a buffer array instead of slicing the array with
valid length.
BUG=None
Change-Id: I78b714554cac9ae71b895cb8929bc98969f5a8ca
* Allow buffer size that is greater than requested read size in JNI,
because we reuse fixed-size buffer among multiple requests.
* Fix condition to check if the file size is greater than 4GB or
not. We need to use 0xffffffffl instead of 0xffffffff because
0xffffffff is int and its value is -1.
BUG=None
Change-Id: I155916e139353b15dc1ab535234faf50d942996d
* Replace tentative resources with real ones.
* Show the notification for each device as per request from UX.
BUG=26625702
Change-Id: Ibcfe7075e4827d5aee216ce5c0007f6dd4572efe
Previously IllegalStateException is thrown in app fuse main loop, if the
loop thread starts just after closing device FD.
BUG=None
Change-Id: Ia5232857d29f9f324446aa38acf3c062f359d406
* Use try-with-resource block to ensure close auto-closeable stream.
* Define local variables just above the place where they are used.
BUG=None
Change-Id: I9d6c952ebac096c51567a4a787b2bc9fff6502de
* Return attributes for all files as well as root.
* Fix buffer size for reading and add a check for reading size.
BUG=25756419
Change-Id: I572f718bc01d96616ec94f85d800b8b57eedd2ea
The CL was previously reviewed at ag/842930.
> We can obtain detailed information of MtpEvent from devices. e.g. object
> handle of changed object. The CL adds the detailed information as
> properties of MtpEvent class.
>
> BUG=26480986
Change-Id: I93afad9caf118d74cd0923d70242133c4fb2a648
* Integrate two while loops waiting for valid device.
* Try to open a device just after getting an device ownership so that
other applicaitons do not steal device ownership before TestUtil
opens a device.
Change-Id: Ia273cfb2a47fe630efd8c54b22d6ef5823a402b8
Because not all MTP devices support getPartialObject, we need to check
supported operation of MTP devices. The CL adds operationsSupported
field to MtpDeviceInfo class.
BUG=26147375
Change-Id: Iaad968fb4497a5ad11bf6489097abea99c3cbac7
Previously MtpDocumentsProvider used to remove device info in the
database when the device is closed. It loses a chance that RootScanner
handles the removal of roots. As a result, notifications for root cursor
does not issued.
The CL stops removing device info at MtpDocumentsProvider, and let
RootScanner remove it.
BUG=26321346
Change-Id: I6aec0cf843a1e5c93e7f67a718cabd26841d9799
The test for readEvent cancelling was flakiness because it can
successfully receives an event before the test tries to cancel it.
Change-Id: Ie7625dff53e07b8bc9888da03e78155e683a6d46
The CL lets MountService to observe device FD, and request unmount to
vold when the device FD was closed, or remote application providing
appfuse is crashed.
BUG=25756420
Change-Id: I7990694d32affa7f89e3f40badb25098d74d744d
Previously the while loop condition refers to Thread.interrupted()
wrongly. The Thread.interrupted() flag is cleared when the
InterupptedException is thrown.
BUG=26297698
Change-Id: I113d5c88389d54a4a6e29af2cf9515b1693b59dc
The CL updates MtpDocumentsProvider#queryRoots so that it fetches
devices from Database as well as storages when we don't have storages
under the device, or when we have multiple storages under the device.
BUG=26120019
Change-Id: Id2b140f00a1d49fa4da7e17d2564dbbaa1795e1e
I suspected that the commit was conflicted with ag/833494, but actually it wasn't. Let me reland this CL again.
This reverts commit b63e8c6ccc1425d56f8b9c801f4bddf906d694e5.
Change-Id: I4e734422ce10ef93ee7c4ef3b8b72a81beaa769b