184 Commits

Author SHA1 Message Date
Daichi Hirono
9984ebd6d3 Use column name instead of index in MtpDatabaseTest for readability.
BUG=26194040

Change-Id: I58a6e59f4784fcc81988093bb113e721e36e46d0
2015-12-15 16:02:27 +09:00
Daichi Hirono
7d0b3cdd70 Merge "Stop reopening MTP devices." 2015-12-15 02:12:31 +00:00
Daichi Hirono
be38848969 Stop reopening MTP devices.
BUG=26175809

Change-Id: I45a51c0623b349f12e7d3cf787a89b089f230bc1
2015-12-15 11:10:37 +09:00
Daichi Hirono
42a5e0e3a4 Merge "Integerate mapping methods for root/child documents into the same methods." 2015-12-15 02:08:50 +00:00
Daichi Hirono
7a375c407f 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
2015-12-15 11:06:20 +09:00
Daichi Hirono
4b54e036ef Add document type to MtpDatabase.
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
2015-12-11 17:13:53 +09:00
Daichi Hirono
dc89e079ce Merge "Grant USB device permission by using system permission." 2015-12-09 04:04:47 +00:00
Daichi Hirono
b863990a01 Enable MtpDocumentsProvider by default.
BUG=20274999

Change-Id: I35941df66fea4ab703f8f1de3c69b6f4dd2be9a0
2015-12-09 11:18:32 +09:00
Daichi Hirono
4751880a4d Grant USB device permission by using system permission.
Previously it skips the device permission check by referring package
name. The CL removes the special case and use general MANAGE_USB
system-only permission to skip USB device permission dialog.

BUG=26048722

Change-Id: I3702393a50696209499d1e5f6549dab9fb2cefe4
2015-12-09 11:15:25 +09:00
Daichi Hirono
a57d9ed090 Turn MtpDocumentsService foreground when devices are opend.
BUG=26047393

Change-Id: I70f69c5ddec500ed61d1a76fb9e2e296813b2a4e
2015-12-08 17:27:04 +09:00
Daichi Hirono
99b58052f8 Polish MtpManagerTest.
Change-Id: Ibadd209ee1cb752f0e55694d0f1f631c558f1370
2015-12-04 12:32:41 +09:00
Daichi Hirono
56e086f5da Merge "Extract test utility class." 2015-12-02 03:53:46 +00:00
Daichi Hirono
ed2f850330 Merge "Add storage icon for MTP roots." 2015-12-02 03:53:08 +00:00
Daichi Hirono
b255f58904 Extract test utility class.
Change-Id: I8505ab13ceccf32e7a9b6817f84a66766098b09e
2015-12-02 12:38:49 +09:00
Daichi Hirono
39795da4c9 Add storage icon for MTP roots.
BUG=22545807

Change-Id: I714b26d52e00b0f9a5c95dea1508be0d617482e3
2015-12-02 11:08:40 +09:00
Daichi Hirono
1b8f619480 Merge "Handle Android M as a MTP device in MtpManagerTest." 2015-12-01 07:42:12 +00:00
Daichi Hirono
f26af124e3 Handle Android M as a MTP device in MtpManagerTest.
MtpManagerTest uses real MTP device to test functionallity, but
previously it did not handle Android M's USB client behavior.

BUG=25939006

Change-Id: I53fa8c08c41c3adacf85f24694afdea5ec0781ca
2015-12-01 15:58:29 +09:00
Daichi Hirono
e0282dd7d4 Reopen MTP devices when the provider is created.
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
2015-11-30 10:06:56 +09:00
Daichi Hirono
259ce80132 Extract mapping operations to partial class of MtpDatabase.
Change-Id: I5fda6d5754206528ad5953bcc179a0ffe0b4982d
2015-11-26 15:55:15 +09:00
Daichi Hirono
9e8a4fa78f Change ID format of MtpDocumentsProvider.
BUG=25704562

Change-Id: I5d9fc167512eee06964650e07206e226173611b2
2015-11-26 11:09:46 +09:00
Daichi Hirono
49f920fbde Add new methods to MtpDatabase.
* deleteDocument
 * getParentId
 * queryDocument
 * putNewDocument

BUG=25756881

Change-Id: Ie223b37e04586b3e2b0448d09e14562fedbb652a
2015-11-19 16:00:10 +09:00
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