When rebooting a device, applicaitons lose temporary URI permissions so
we don't need to keep document ID that are not granted persistent URI
permissions.
1. Check Settings.Global.BOOT_COUNT to find out if it's first time to
launch MtpDocumentsProvider since booting.
2. If so, invokes clean up method of MtpDatabase.
BUG=26212981
Change-Id: Ic9a8ca7e7a9cac1ed91fdfb01e9dce14ce819243
The CL introduces MAPPING_KEY column to the database and lets Mapper use
the column to map IDs of devices.
It also removes the concept of mapping mode from Mapper for
simplyfing. Now Mapper just tries to multiple mapping keys (MTP
identifier, display name, and mapping key) to find candidate of ID
mapping.
BUG=26212981
Change-Id: I19f6c7dac146047e9978de4eb33d5076406037ad
(cherry picked from commit 637a2010f4)
According to DocumentsContract mime type field is required.
MtpDocumentsProvider should returns mime type for unknown types of MTP
files as well.
BUG=27148801
Change-Id: I7e4b832f6c00f438cf90190c074f204fdedceef5
disconnected.
To restore Document IDs when the device is reconnected, we need to keep
the metadata in database so that we can use it as hint to remap document
ID with new MTP IDs.
BUG=26212981
Change-Id: Idcc93c41c09d082a709281022c56188dabc80515
(cherry picked from commit 53f5af3f2b)
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 acdbc6e740)
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 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 b63e8c6ccc.
Change-Id: I4e734422ce10ef93ee7c4ef3b8b72a81beaa769b
methods.
The integrated methods will be used to add device documents as well as
root/child documents.
BUG=26175081
Change-Id: Ibf474cfbc41df402a2958e9efcdd0061f07f5ced
Currently all document roots represent MTP storage, but we will not have
this assumption after starting show MTP devices (not storage) as
document roots.
To distinguish these two types of roots, the CL adds document type
column to the document table in MtpDatabase.
BUG=26120019
Change-Id: I6ee930008aea0b43c1c42b21a198b07eccbd443d
When the provider is created, it reopens MTP devices that are recorded
in the database. It enables the provider to resume MTP session after the
provider process is killed by the system.
BUG=25704854
Change-Id: I58ae80fdb2e02cb0f045c63c4ade8943e2baae06