History log of /frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
76be46f4d9314fd7daca0985a0a7e02126d85975 08-Apr-2016 Daichi Hirono <hirono@google.com> Fix crash when deleting multiple files.

When deleting files, MtpDocumentsProvider clears LoadingTask in
DocumentsLoader to update directory contents list. Previously it can
clear ongoing task, and it skips calling Mapper#stopAddingDocuments.
Since Mapper#startAddingDocuments and Mapper#stopAddingDocuments must be
called 1 to 1, it causes precondition check failure at the next call of
Mapper#startAddingDocuments.

Change-Id: I23e2b117da826297e45404be4db4cc29f96e5510
Fix: 28076320
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
64111e08d905525c7f4fe27e69953eb71bd62511 24-Mar-2016 Daichi Hirono <hirono@google.com> Get object size that is more than 4GB.

MtpObjectInfo contains object size as 32-bit integer and the provider
needs to invoke MtpDevice#getObjectSizeLong hidden API to get 64-bit
object size.

The CL switches to use MtpDevice#getObjectSizeLong hidden API if
MtpObjectInfo#getCompressedSize() returns 0xffffffffL, which means the
object size is more than 4GB.

BUG=27805369

Change-Id: I87ea02c09aa784246cf016def309d1f39ed20e90
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
61ba923ca0cb5c928a16729d0aa67b6bf4b2f027 25-Feb-2016 Daichi Hirono <hirono@google.com> Set document flag by referring MTP supported operations.

BUG=26147375

Change-Id: I6c4244f1f1153c1bbbf21ea9d608dc1a92ca70cd
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
0f32537e40ee2662d4f0b7b625ee280ca9c02066 21-Feb-2016 Daichi Hirono <hirono@google.com> Stops performing operations that does not supported by MTP device.

MTP devices can return supported operation list. The CL sets root flag
by referring it.

BUG=26147375

Change-Id: I02397821e208cf5a8fcf7457aa279d2818ce24c7
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
1bc289c92c94855b208204974016cfd0dfd83fad 25-Feb-2016 Daichi Hirono <hirono@google.com> Merge "Resolve unmapped document when the device is connected." into nyc-dev
5c690557cce825024f5dc9e5e686f256155691a3 21-Feb-2016 Daichi Hirono <hirono@google.com> Delete disconnected row when the corresponding remote file is deleted in a
MTP device.

The CL has MtpDatabase remove file metadata for the case.

1. Files app opens a MTP device. MtpDocumentsProvider stores the
metadata of files in MtpDatabase.
2. A user disconnects the MTP device. MtpDatabase marks the files
metadata as disconnected.
3. A user operates the MTP device and deletes a file in the MTP device.
4. A user connects the MTP device to Android again, and opens the MTP
device again in Files app.
5. MtpDocumentsProvider updates the metadata of files, it should delete
metadata of a file that was deleted at step 3.

BUG=27280143

Change-Id: I79b8df2457cd5b36d1706a9c6e3827c8e7d16208
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
4e94b8deaa646f176bad9b80d5924ce64142743e 21-Feb-2016 Daichi Hirono <hirono@google.com> Resolve unmapped document when the device is connected.

Once MTP device is disconnected from Android, the files on MTP device
are marked as 'DISCONNECTED' in metadata database. These metadata will
be back when MtpDocumentsProvider finds the reconnected MTP device and
fetches the files again.

Previously the 'DISCONNECTED' files are not automatically
refetched. User needs to see files in Documents UI again to reuse
document ID of 'DISCONNECTED' files. The CL changes DocumentLoader so
that it automatically refetches disconnected documents.

BUG=26212981

Change-Id: I5cb2cc9c11af72632e481c59a505794f43ed62ea
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
ebd24051599280443435606cab220de33b9356ad 06-Feb-2016 Daichi Hirono <hirono@google.com> Use device key to map device documents.

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 637a2010f4a0c0484b13c4cb87aa2858bdf079b2)
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
8e87364a67ada7ce92730182719f7820886c13bd 07-Feb-2016 Daichi Hirono <hirono@google.com> Keep metadata of documents as disconnected status after the device is
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 53f5af3f2ba1328d301a0f8a4ae3f574ccc5da65)
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
619afdaae1ec7dcbd71bb1f698a0901a1fa290fe 07-Feb-2016 Daichi Hirono <hirono@google.com> Check parent existance when adding/removing documents.

BUG=26212981
Change-Id: I8109e2324c027ec2182c6f521d57f3fe078a8660
(cherry picked from commit df803ec6ebd47ddc7f97ea8ef13aa359ecc7fb95)
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
9fca541ab8acb06bb390319251526fa9807b846f 07-Feb-2016 Daichi Hirono <hirono@google.com> Relax mapping rule to make the mapping logic simple.

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)
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
f83ccbd7edd32e728785fb7aad44f11886e79645 04-Feb-2016 Daichi Hirono <hirono@google.com> Drop device name from storage document name.

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
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
81d48536aef702d301cdc3a339008de767b51f99 16-Dec-2015 Daichi Hirono <hirono@google.com> Show MTP device as root when it has multiple/zero storages.

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
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
20754c5a112e418c11cc88176283db2c4bf2efd6 15-Dec-2015 Daichi Hirono <hirono@google.com> Store device document even if the device is not opened.

BUG=26197156

Change-Id: I2a80bb3e85310cf63253173b1110a155ee1391ba
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
b3fe72bfb288a509a953e5586264ca1c4460d2df 15-Dec-2015 Daichi Hirono <hirono@google.com> Revert "Revert "Add device document to MtpDatabase.""

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
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
b63e8c6ccc1425d56f8b9c801f4bddf906d694e5 15-Dec-2015 Daichi Hirono <hirono@google.com> Revert "Add device document to MtpDatabase."

This reverts commit c0ae45be046b1aed005589791e1ee483c399ab1c.

Change-Id: I03337324e768c509bdcf94c89f7abe7ca00c8a18
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
c0ae45be046b1aed005589791e1ee483c399ab1c 14-Dec-2015 Daichi Hirono <hirono@google.com> Add device document to MtpDatabase.

BUG=26175081

Change-Id: Ida91c50f7e33d7b300a32ee318b6f3837edf6606
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
7a375c407f2759f21fb4ca7215034f056b4ade1c 14-Dec-2015 Daichi Hirono <hirono@google.com> Integerate mapping methods for root/child documents into the same
methods.

The integrated methods will be used to add device documents as well as
root/child documents.

BUG=26175081

Change-Id: Ibf474cfbc41df402a2958e9efcdd0061f07f5ced
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
259ce80132d55774fe599c60b53a9d9dfc1efa65 20-Nov-2015 Daichi Hirono <hirono@google.com> Extract mapping operations to partial class of MtpDatabase.

Change-Id: I5fda6d5754206528ad5953bcc179a0ffe0b4982d
/frameworks/base/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java