52 Commits

Author SHA1 Message Date
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
Daichi Hirono
11bd3cbd2d Random fix for Identity class.
* Change separator for ID from ':' to '_' so that the ID can be used as a file
   name in FAT.
 * Implements equals and hashCode methods.

BUG=20274999

Change-Id: Ibb83151f7d6bdb0c993622dddeb89723aecfa264
2015-08-04 15:07:28 +09:00
Daichi Hirono
e5323b7493 Implement MtpDocumentsProvider#queryDocument.
BUG=20274999

Change-Id: Id5c81f744ea1e28d0a0d352b52db1c33fd5edcc2
2015-07-31 11:19:28 +09:00
Daichi Hirono
6ee4a1c124 Rename MtpManagerMock with TestMtpManager.
BUG=20274999

Change-Id: I0db6609ed7cde211d0e174a5cd88ca7551ea64ae
2015-07-31 10:30:05 +09:00
Daichi Hirono
beac2184ab Extract common initialization of MtpDocumentsProviderTest into setUp method.
BUG=20274999
Change-Id: Ib8e6907b17d89842bac85e9850bfad301bf51fe6
2015-07-29 19:31:34 +09:00
Daichi Hirono
09109567e9 Add test for queryRoots.
BUG=20274999

Change-Id: Iea9ca7514d29bb9dcb9c1ef83ff5554f5dc41901
2015-07-29 19:27:22 +09:00
Daichi Hirono
50d17aa871 Implement queryRoot method of MtpDocumentsProvider.
BUG=20274999

Change-Id: I27aa8bffe47eab6ea1f4195023dbacb6e2f76548
2015-07-29 14:38:11 +09:00
Daichi Hirono
d30c9d1302 Remove local flag for proguard.
Now default configuration of proguard can handle internal VisibleForTesting
annotation. We don't need to have local configuration.

BUG=20274999

Change-Id: Ib21e07336e48dda71d0d2644ddd86422414f7524
2015-07-28 14:30:07 +09:00
Daichi Hirono
df3f2e6fdd Add ReceiverActivity to MtpDocumentsProvider.
To show the application chooser for the UsbManager.ACTION_USB_DEVICE_ATTACHED
intent, the intent should be received by activity. The activity has NoDisplay
theme and immediately terminate after routing intent to MtpDocumentsService.

BUG=20274999

Change-Id: I2080ea433b1657dd68640681664adbf92d1d30e9
2015-07-28 13:06:17 +09:00
Daichi Hirono
2efe4cac49 Add MtpDocumentsService.
BUG=20274999

Change-Id: I1d60ebcf100767136ac7f78e619021776c6be02f
2015-07-28 12:49:11 +09:00
Daichi Hirono
21c20ad32c Implement openDevice/closeDevice method of MtpManager.
BUG=20274999

Change-Id: Ic7f269ca76bd33ef14023b3791b37e0bec1212a8
2015-07-24 10:50:47 +09:00
Daichi Hirono
d5152429e1 Add openDevice and closeDevice methods to MtpDocumentsProvider.
These methods will be called in the following CL from the service that handles
USB attach and detach intent.

BUG=20274999

Change-Id: I7b3c658afc5750d6a2713c07f40c59b26dcd1460
2015-07-24 10:50:08 +09:00