63 Commits

Author SHA1 Message Date
Daichi Hirono
e1d57710fb Don't close database when all devices have been detached.
ContentProvider is a singleton of the process. So it may live longer
than Service. We could not close database when the service is destroyed.

BUG=25730042

Change-Id: I591250c1a1e7c5705eb2585c71cac2598c0c0fb9
2015-11-19 14:16:42 +09:00
Daichi Hirono
47eb192b27 Start using MtpDatabase in DocumentLoader.
BUG=25704514

Change-Id: I4d9247c148679ee7e40a1a03443e4c0299b1e44d
2015-11-17 15:46:40 +09:00
Daichi Hirono
4604b74603 Prepare for adding MtpDocumentsProvider tests to APCT.
BUG=25093356

Change-Id: I0c194e6bf3abeb632171e9be49471b9d94a0cb4c
2015-11-17 08:30:41 +09:00
Daichi Hirono
dc47344660 Start to use MtpDatabase in RootScanner.
Change-Id: Id99cb61ad8680529b5ee502ca5bb2b3cdd143235
2015-11-16 17:49:20 +09:00
Daichi Hirono
18d70d5b7c Split MtpDatabase class into three classes.
BUG=25162822

Change-Id: Id64b6d9fa11a3214bb855ea8e1344af45fb415ff
2015-11-13 16:42:50 +09:00
Daichi Hirono
cfcb0c007d Adds new method to update existing documents in MtpDatabase.
BUG=25162822

Change-Id: I7aa63fc272aa7b57d6a9672565f842774e898a00
2015-11-13 14:50:48 +09:00
Daichi Hirono
0378da48c4 Add root information to MtpDatabase.
The CLs adds new table to MtpDatabase that contains additional
information to provide DocumentContract.Roots.COLUMN_*. Client code can
obtain these information by using the newly added queryRoots method.

BUG=25162822
Change-Id: Ib6596d38cbb4a42b689c75fffbd73585c0fb524c
2015-11-10 10:32:42 +09:00
Daichi Hirono
a8a3722e7a Extends MtpDatabase so that it can handle child documents.
The CL extracts common routines for root documents and child documents,
adds new methods for child documents, and let the common routines from
the new methods.

BUG=25162822

Change-Id: Ie6f0092e584ae12c89d43593701debeb76f6f3cb
2015-11-04 12:58:20 +09:00
Daichi Hirono
6de8a0e51f Implement ID mapping for root documents.
MTP identifiers like object handle is unstable over MTP sessions.  The
CL introduce two methods to MtpDatabase that enables the provider to
remap exisitng document ID with new MTP identifiers when the provider
reopen the MTP session.

 * MtpDatabase#clearMtpIdentifier invalidates old MTP identifiers
 * MtpDatabase#resolveRootDocuments remaps invalidated documents with
   new MTP identifier.

BUG=25162822

Change-Id: Iadb668ae5932da81aba2b2731d0d185da5656f16
2015-11-02 11:30:47 +09:00
Daichi Hirono
59686f6c35 Update JavaDoc in MtpDatabase.
BUG=25162822

Change-Id: Icfd9391daa01846f5ec12d5ea7448ebc7444a05c
2015-10-28 16:43:32 +09:00
Daichi Hirono
85a808bf96 Let MtpDatabase add device name to storage root.
We have added device name to storage root by ag/790395.
But the change was not added to MtpDatabase class.

BUG=25162822

Change-Id: I019a9cf770a91c43b4e2f4e81e74b40175fd4872
2015-10-27 17:27:16 +09:00
Daichi Hirono
88d2f781f0 Remove fullpath from MtpDatabase.
If the remote MTP device is backed by typical file system, the file name
is unique among files in a directory. However, MTP protocol itself does
not guarantee the uniqueness of name so we cannot use fullpath as ID.

Instead of fullpath, we use artifical ID generated by MtpDatabase
itself. So we don't need to store fullpath in the database.

BUG=25162822

Change-Id: I06598ce631a3221ed72e11734dbdaefef4c6349c
2015-10-27 17:14:50 +09:00
Daichi Hirono
b999b0cb0f Move TestResources class to the outside of MtpDocumentProviderTest.
TestResources class will be used in MtpDatabaseTest.

BUG=25162822

Change-Id: I4f51b517532bbc111e95e7ebd96787a2e6f0f87a
2015-10-27 17:08:20 +09:00
Daichi Hirono
9678f60633 Add MtpDatabase class.
The class stores document information and will be used to remap object
handle with document ID when the process resumes.

BUG=25162822
Change-Id: Ic1a2f60ae0ee90b6c2b77a89a578cef1e0e917f2
2015-10-26 10:41:03 +09:00
Daichi Hirono
d391813b70 Merge "Support major format code in MtpDocumentsProvider." 2015-10-22 02:23:39 +00:00
Daichi Hirono
3359d45545 Support major format code in MtpDocumentsProvider.
Start to use common MeidaFile helper class that can convert major format
code into mime type.

BUG=25096009

Change-Id: I8379cc6f11945c8e2215d36492367e73377fdc26
2015-10-21 12:31:29 +09:00
Daichi Hirono
17c8d8bcda Add device model name to MtpDocumentsProvider's roots.
BUG=24813180

Change-Id: I548c553978357dd9619cf66622ec9c0f61886f33
2015-10-13 14:46:59 -07:00
Daichi Hirono
0b494663a4 Add readEvent method to MtpDevice.
BUG=23368533

Change-Id: Ibefff559fa7dd0bee17e2812bd7cdd129108d804
2015-09-25 14:54:17 +09:00
Tomasz Mikolajewski
4c1d3dde05 Create PipeManager and DocumentLoader per device.
Also, reduce MtpManager's synchronization to per device synchronization.

Bug: 23733078
Change-Id: Ieedc7d871f2a4d260ca4287c6fa05d67f54fb4c5
2015-09-15 09:42:20 +09:00
Tomasz Mikolajewski
9d89dc40f1 Replace hardcoded numeric literals with those in MtpConstants.
Change-Id: Idbac906fefd6da060a88a256187f124359f2205c
2015-09-02 16:42:36 +09:00
Tomasz Mikolajewski
81d7474310 Refresh directory changes on Mtp when a child is deleted or created.
Change-Id: I0325c60ac142368c2e61fcf9efa751f678f3f3a3
2015-09-01 14:52:50 +09:00
Tomasz Mikolajewski
df544176b1 Fix uploading multiple files via MtpDocumentsProvider.
Uploading was breaking as SendObject request was not being sent directly
after SendObjectInfo which is assumed by the MTP stack in Android.

Change-Id: I36b94f56682e79dec38add9be5f70f55d07e22e7
2015-09-01 09:25:30 +09:00
Tomasz Mikolajewski
ab65d363bb Remove redundand code from TestMtpManager.
Change-Id: I487dbab4366375c80d82d26ed9757e5ba17a2c56
2015-09-01 09:25:30 +09:00
Tomasz Mikolajewski
bb430fa930 Remove MtpDocument.
Change-Id: Ie4b0e55f6ff2c7b323cf767a5ed3d3c61c12734d
2015-09-01 09:25:30 +09:00
Tomasz Mikolajewski
3d13bdfd36 Merge "Fix remaining renames in MtpDocumentsProvider tests." 2015-08-31 04:34:44 +00:00
Daichi Hirono
2e95181a7a Merge "Add simple unit test for MtpManager which uses real MTP device." 2015-08-31 04:31:17 +00:00
Tomasz Mikolajewski
3edb420137 Fix remaining renames in MtpDocumentsProvider tests.
Change-Id: I7093654c35faa750c12f75da57ddfa2828c474b0
2015-08-31 13:25:59 +09:00
Daichi Hirono
5bc41d1854 Add simple unit test for MtpManager which uses real MTP device.
BUG=23536467

Change-Id: I46f207b09d3d0706ccf8cb02d8dedcf6eb354a89
2015-08-31 13:20:23 +09:00
Daichi Hirono
c68b9df81e Merge "Fix member naming style in PipeManagerTest." 2015-08-31 03:36:23 +00:00
Daichi Hirono
84dfb05407 Fix member naming style in PipeManagerTest.
BUG=None

Change-Id: I962a37667f110ee17e62e24517db6a85aa227b9f
2015-08-31 12:32:39 +09:00
Daichi Hirono
03a0965933 Merge "Add activity to show the result of tests." 2015-08-31 03:31:08 +00:00
Daichi Hirono
c3e93a8f5b Add activity to show the result of tests.
When testing a real MTP device, we cannot obtain test results by using the USB
port because the USB port is occupied by the MTP devcie. The CL adds an activity
to test package that shows test results.

BUG=23536467

Change-Id: I0e53c2de122cb3afd52f22bedd93ece53aaeb525
2015-08-31 12:29:04 +09:00
Tomasz Mikolajewski
b80a3cfd05 Add support for uploading files via MTP.
Change-Id: Id1811ab70cb28be471e0a99999e9ad5380deac49
2015-08-28 10:50:23 +09:00
Tomasz Mikolajewski
c0834cd049 Fix tests in MtpDocumentsProvider.
Change-Id: I19c0c39b7865990db5021eaa44d3be70751c5eb3
2015-08-26 12:31:45 +09:00
Tomasz Mikolajewski
7f2aba0fb9 Merge "Wire uploading to MtpDocumentsProvider." 2015-08-21 01:08:12 +00:00
Tomasz Mikolajewski
87763e6a91 Wire uploading to MtpDocumentsProvider.
This patch does not yet allow to upload files, but uploading (creating)
directories already works.

Bug: 22545670
Change-Id: If4d5a53aa26f791475bb1a783e0ac9540d6760c1
2015-08-20 11:34:44 +09:00
Daichi Hirono
831c5a1e43 Merge "Extract task list operations from MTP DocumentLoader to the internal task list class." 2015-08-20 01:10:18 +00:00
Daichi Hirono
d40b030ad5 Extract task list operations from MTP DocumentLoader to the internal task list class.
BUG=23067619

Change-Id: I8dc6f50f2e8927fe38b992e4135009f36acf3079
2015-08-19 13:53:06 +09:00
Steve McKay
743d554a07 Merge "Add comment to argument in MtpDocumentsProvider#openDocumentThumbnail." 2015-08-18 17:13:46 +00:00
Daichi Hirono
b1870e922e Handle null value returned by MtpDevice#getRoots.
BUG=23169303

Change-Id: I9602dda01f3b8919a471c1f4c88acdd19f391684
2015-08-17 18:17:33 +09:00
Daichi Hirono
8b9024f0c2 Add RootScanner to MtpDocumentsProvider to handle new/removed MTP storages.
BUG=23169303
Change-Id: I5a73da7f869fed2fcf69e6ab7b039d1a60b883e2
2015-08-14 17:14:52 +09:00
Daichi Hirono
630be43c1c Merge "Let MTPDocumentsProvider load documents in background thread." 2015-08-13 06:50:12 +00:00
Daichi Hirono
6baa16e910 Let MTPDocumentsProvider load documents in background thread.
The CL introduce DocumentLoader class that has a responsibility for loading
documents on background thread. When the provider is requested documents and the
result is not cached, it returns the cursor containing the first 10 items with
extra loading flag. Then it loads the rest of documents into cache on background
thread and notifies update regularly.

BUG=23067619

Change-Id: I7ac9d919bc3ffee1960ae3e8e7272a792a982ea8
2015-08-13 15:47:19 +09:00
Daichi Hirono
2ff024f497 Start to use importFile to file descriptor.
BUG=22908937

Change-Id: Ia4f01099816e7841e364d46c125542d006cd47a6
2015-08-12 17:37:04 +09:00
Daichi Hirono
573c1fbc5f Add comment to argument in MtpDocumentsProvider#openDocumentThumbnail.
BUG=20274999

Change-Id: Ibfda61812c0c26f923f939836f483f26b964be0e
2015-08-11 19:31:30 +09:00
Daichi Hirono
124d060bc9 Implement MtpDocumentsProvider#queryChildDocuemnts.
BUG=20274999

Change-Id: Ib18e0f36aa97add1c4b603fe11e9adedfef157ec
2015-08-11 18:08:07 +09:00
Daichi Hirono
3faa43a4a6 Implement MtpDocumentsProvider#openDocumentThumbnail.
BUG=20274999
Change-Id: I4ee43d94d92735e07786dfe557eaca69e8bff6c3
2015-08-06 16:03:06 +09:00
Tomasz Mikolajewski
52652ac7a5 Make reading files streamed in MtpDocumentsProvider.
Change-Id: If5ca4fc71cf27a2eccb46865421235790623985a
2015-08-06 13:15:19 +09:00
Daichi Hirono
5fecc6cf03 Implement MtpDocumentsProvider#deleteDocument.
BUG=20274999

Change-Id: I6d07280ddbb0809d3c1334aec5fcbc0c67c4c2aa
2015-08-05 15:59:24 +09:00
Daichi Hirono
8ba419119d Implement MtpDocuments#openDocument.
BUG=20274999

Change-Id: Iebcee84cb47ac521412b15f91903922953cbd3a8
2015-08-05 15:21:57 +09:00