Commit Graph

166 Commits

Author SHA1 Message Date
James Wei
f545a3ac9e MTP: media info can not be retrieved via MTP#2
Under the new MtpStorageManager design,
media info like MP3 Track title, album and artist, Genre, etc
can not be retrieved via MTP
by Windows Media Player, Linux Rhythmbox and Some Car Kits

Bug: 112635346
Test: atest MtpTests
Test: atest MediaProviderTests
Test: Manual test: Windows Media Player
Change-Id: I57a947fe6d3a583a0990be5bd2b0678f39d948f2
2020-05-01 07:52:55 +00:00
James Wei
82062b99eb MTP: Fix MTP SD card issue
Modify MTP access path for SD card in accordance with Storage Permission change

Bug: 150188237

Test: atest MtpTests
Test: Manual test: MTP file browsing / copy on SD card
Change-Id: I7da699ca04844514827af18b0318c66d2a3fbc6e
2020-04-22 11:34:42 +08:00
James Wei
19ded228a3 MTP: Add MtpDatabase unit test
Add Thumbnail feature test cases

Bug: 117863715
Test: atest MtpTests
Change-Id: I5a09efef10df20e382a4c623481e048e7b35ff14
2020-04-22 03:20:02 +00:00
James Wei
fa96ad19c7 Merge "MTP: Add MTP Thumbnail feature" 2020-02-05 02:56:03 +00:00
Andrii Kulian
e57f2dc246 Exempt-From-Owner-Approval: Fix usages of WindowManager.getDefaultDisplay() in f/b
Replace the existing usages of now-deprecated API
WindowManager.getDefaultDisplay() with WindowMetrics or
Context.getDisplay() in frameworks/base.

Bug: 128338354
Test: Build, auto test
Change-Id: I02d38a022c5e0e6e9d699f03d35b65d6c8126da9
2020-01-31 01:15:21 +00:00
James Wei
bb3f548234 MTP: Add MTP Thumbnail feature
Add thumbnail support for more supported image & video format

Bug: 117863715
Test: atest MtpTests
Test: manual test on Windows 10 file explorer
Test: manual test on Linux nautilus file browser
Change-Id: Id973db64683dbdb75f1fe97cae8439bab6cdcb57
2020-01-22 09:38:59 +00:00
Artur Satayev
2ebb31c00c Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv \
      git diff HEAD^ HEAD | grep '^[+-][^+-]' | grep -v '.import'

Change-Id: I853372f3c6fef905553bb31be4f1bb48df735f7a
2020-01-08 16:06:00 +00:00
Automerger Merge Worker
90dc909c3a Merge "Revert "Use new UnsupportedAppUsage annotation."" am: edf7ce4f38 am: 019286764f am: f6253ef435
Change-Id: Id33f64eb9c8aa7d68cc52f7359b4f0a3d2675d8a
2019-12-19 12:13:32 +00:00
Austin Wang
a63a2c0130 Revert "Use new UnsupportedAppUsage annotation."
This reverts commit a5264903e2.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=sdk_phone_armv7-sdk&lkgb=6083299&lkbb=6085371&fkbb=6083313, bug b/146533269

Change-Id: Ie5b031d7b277cf0e09b0a9776b26bf74f5f69e70
2019-12-19 06:38:19 +00:00
Automerger Merge Worker
277353090c Merge "Use new UnsupportedAppUsage annotation." am: 1385dca8f6 am: 068a9faf3d am: c7f44bacbe
Change-Id: I30839db2fe99ba4670ec1b39d5e64540fdd15f69
2019-12-18 16:31:41 +00:00
Artur Satayev
a5264903e2 Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv \
      git diff HEAD^ HEAD | grep '^[+-][^+-]' | grep -v '.import'
Change-Id: I087bb1cecbe59f1cf0c2e770c735d7a433722c6f
2019-12-18 12:07:36 +00:00
Jeff Sharkey
04b4ba1e15 Shuffling to prepare for MediaProvider APEX.
An upcoming change will move MediaStore to be within the recently
created MediaProvider APEX.  This means that MediaStore will need to
be fully built against @SystemApi, and so this CL adjusts APIs to
support a clean transition:

-- Listing of "recent" storage volumes and scan paths for "internal"
storage is now handled by StorageManager directly, so that partners
retain control over what is deemed recent.
-- StorageVolume now returns the MediaStore volume name and the
filesystem directory where its contents are presented to apps.
-- Conversion of legacy thumbnail "kind" values to dimensions now
happens directly inside MediaStore.
-- PendingParams and PendingSession are completely removed.
-- Contributed media APIs are completely removed.
-- Media for demo users is now surfaced as a unique StorageVolume.
-- Migrate most MediaStore APIs to accept ContentResolver, which
supports easy usage of ContentResolver.wrap().

Bug: 144247087, 137890034
Test: atest --test-mapping packages/providers/MediaProvider
Exempt-From-Owner-Approval: in-place refactoring
Change-Id: I445528b2779bb37b9f2558e67a3cfc9f60412092
2019-12-18 01:35:46 +00:00
Jeff Sharkey
8f5cdbb49b Disable support for object references.
MediaProvider has standardized on being an indexed view of files that
we discover on disk, so that we can always recover that indexed
information in case of user data wipe or corruption.  This means
that MediaProvider no longer supports abstract "object references".

This doesn't prevent future MTP implementations from bringing back
object reference support, and the recommended path forward would
be to have MtpDatabase convert object references into playlist files
that are written to disk.  MediaProvider will then gladly scan those
playlist files to be visible to users.

Shift to directly using the existing Files.getContentUri() API for
all MediaProvider interactions.

Bug: 137890034
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I829027bb9fbcf5991c1ddee0aec04ad7e7b240cd
2019-12-16 14:10:56 -07:00
Marco Nelissen
292fdc1c93 Remove libexif usage from libmedia_jni.so
Test: manual, connect with MTP and PTP
Change-Id: I33128db25b8aae60df7854c61fc2a3873a1bced9
(cherry picked from commit f7ec16802c)
(cherry picked from commit efb865ace2)
(cherry picked from commit 5954d210d3)
2019-07-08 05:29:38 +00:00
Marco Nelissen
f7ec16802c Remove libexif usage from libmedia_jni.so
Test: manual, connect with MTP and PTP
Change-Id: I33128db25b8aae60df7854c61fc2a3873a1bced9
2019-07-02 15:48:17 +00:00
Neil Fuller
ca48dd8182 Switch to HexEncoding from ByteStringUtils
Migration in preparation for deletion of ByteStringUtils.

Also contains an import ordering change needed for upload.

Bug: 124232146
Test: build only
Change-Id: I0c71751de9a142a81ce43b4eaea497bf291afcbc
(cherry picked from commit 8fdca745d6)
2019-06-06 14:01:38 +00:00
Jeff Sharkey
731ca71e07 Merge "Adjust MTP to reference by specific volume name." into qt-dev am: 383d316707
am: 951c617d7d

Change-Id: I507f1c1de958ad8b5866eec8334f4a1404c659f2
2019-04-17 15:18:15 -07:00
Jeff Sharkey
42bf6d8a42 Adjust MTP to reference by specific volume name.
The MediaStore.VOLUME_EXTERNAL volume is a merged view of all storage
devices, and clients working on a specific volume need to focus on
the volume they're interested in.

Bug: 129840030
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I91cee6a96d7f9360e6a93a9a3c389b097b6b9967
2019-04-17 11:16:15 -06:00
Neil Fuller
8fdca745d6 Switch to HexEncoding from ByteStringUtils
Migration in preparation for deletion of ByteStringUtils.

Also contains an import ordering change needed for upload.

Bug: 124232146
Test: build only
Change-Id: I0c71751de9a142a81ce43b4eaea497bf291afcbc
2019-04-11 11:31:28 +01:00
Jeff Sharkey
ff200957fd Query specific collections for properties.
We're now enforcing the public API schema, so clients like MTP need
to query specific collections when asking for properties that are
specific to those media types.

Also refactor MediaScanner calls to go through MediaProvider, so
they can be handled by ModernMediaScanner.  We no longer directly
try inserting items, and instead rely completely on the scanner.

Bug: 127625964, 122263824
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Ic86982766606a619afafe725f9c60013a5671840
2019-03-24 14:21:01 -06:00
James Wei
9c968fdb4f MTP: remove usages of device identifiers with virtual serial number
Improving protection of user privacy
Use randomly generated virtual serial number that persists until factory reset

Bug: 117585389
Test: Open multiple MTP device
	Check MTP device property
	uninstall / re-install MTP driver
	WMP sync with multiple MTP device
	Enable MTP mode with multi-user
	Malformed MTP ID file

Change-Id: I7ed4ce81d9ca1e1c6605c59c73bcd2d26419a5d3
2019-02-20 15:12:42 +08:00
James Wei
f7f608ccc3 MTP: media info can not be retrieved via MTP
Under the new MtpStorageManager design of Android P,
media info like MP3 Track title, album and artist, Genre, etc
can not be retrieved via MTP
by Windows Media Player, Linux Rhythmbox and BMW Car Kit

Bug: 112635346
Test: Windows Media Player
Test: Linux Rhythmbox

Change-Id: Ibbdaff52a24fa36c6090e799323b767dd5692207
(cherry picked from commit 7784da12b9b3394beb791b16befcd33075668270)
2018-10-22 02:16:28 +00:00
Raj Mojumder
b570968483 Modify MTP OWNERS file.
Set noparent and correct one entry.

Test: no

Change-Id: Iea566148c9cddd4d2529f164c2ff2ff78f4dc596
2018-08-27 14:11:46 -07:00
Raj Mojumder
22e0a4ab0f Add frameworks/base/media/java/android/mtp/OWNERS
Differentiated OWNERS for MTP functionality

Test: no
Change-Id: I477143dc58c65fcc366bb8167f820f91ee009f99
2018-08-27 10:53:29 -07:00
TreeHugger Robot
29bcb287b6 Merge "MTP: Add support of ObjectInfoChanged Event" 2018-08-23 01:38:39 +00:00
Mathew Inwood
d99b96e0f8 Add @UnsupportedAppUsage annotations
For packages:
  android.mtp

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Id97d70dc1003cd7c6ed585d647bf0df0fd7a946a
2018-08-09 17:22:11 +01:00
James
e4f680e058 MTP: Add support of ObjectInfoChanged Event
Under MTP mode, new file created at device side shown size zero at PC side
due to file information is not updated to PC in time with ObjectAdded event

Bug: 77883345
Test: 1. Take screenshot of device under MTP mode with Win10 / Linux
    2. file copy, delete, rename between PC and device
    3. file copy, delete, rename on device with adb shell command
Test: adb shell am instrument -w android.mtp/
	android.support.test.runner.AndroidJUnitRunner

Change-Id: If428064fb0104b53b8afd5b050a4fab4a09312f0
2018-07-27 11:54:43 +08:00
Jerry Zhang
9a018747be Replace streams with Lists in MtpStorageManager
Streams are dispreferred in Android java, so
use Lists for all cases instead.

Test: Mtp works and MtpStorageManager tests pass
Change-Id: I0579013fca690346c6c2561fe3079fd50f215833
2018-07-16 18:21:47 -07:00
Jerry Zhang
01f41f96fe Merge "Call access(2) on all files/dirs modified by Mtp" into pi-dev 2018-05-15 21:35:43 +00:00
Jerry Zhang
d470a1eca6 Call access(2) on all files/dirs modified by Mtp
External sdcards are accessed through /mnt/media_rw,
so access() each touched file for sdcardfs to update
its metadata.

Java handles single object renames directly so that
is the only place where it is needed.

Bug: 77849654
Test: use mtp with emulated sdcard
Change-Id: Ie460398010f1fe74d8084808a6333b121674362c
2018-05-15 12:29:13 -07:00
Jerry Zhang
71938e18ca Access removable volumes through /mnt/media_rw
Due to permissions changes, we now need to access
the underlying filesystem of removable devices in
order to get write access.

Add internalPath to StorageVolume, and have VolumeInfo
set the field on creation.

Bug: 77849654
Test: Can write to emulated sdcard through MTP
Change-Id: I63302ecf2dd2600a1c9f3f6ab106c3695654cbaa
2018-05-14 11:39:12 -07:00
Jerry Zhang
bb54f62d1a Merge "Guard against null server" into pi-dev 2018-03-27 17:54:21 +00:00
Jerry Zhang
2ecbc7acdb Guard against null server
If MtpService stops before MtpServer
shuts down, the server will be null,
so don't attempt to use it in that
case.

Bug: 76433619
Test: no errors
Change-Id: I6744cb78908e6a0663a4b60107d5c9c18dda62bb
2018-03-27 00:01:33 +00:00
Jerry Zhang
63a69fd4f8 Revert "Add additional context to MtpDatabase"
This reverts commit 5f0139d2e8.

Bug: 72877143
Test: Switch users, use MTP
Change-Id: Ide372a9311a4f2647715d052fc0e1d9a04808aa0
2018-03-22 11:35:19 -07:00
Jerry Zhang
6d319b8aaa Write descriptors for Mtp in UsbService
The current model for setting up a functionfs
function is:

UsbDeviceManager#setCurrentFunctions() ->
intent is sent to MtpReceiver to write the descriptors ->
init/hal waits for descriptors to write, then pulls up gadget ->
Gadget is configured, a USB_STATE intent starts MtpServer

The main downside of this is a lack of reliability because
the Mtp process could be killed at any point. Normally, a
gadget is unbound if its control endpoint is closed. no_disconnect
works around this, but is still a little janky. In addition, the
extra intent delays the startup of the gadget.

With the new model, UsbDeviceManager writes the descriptors
on initialization. Since it is a system service, it won't be killed.

UsbDeviceManager#setCurrentFunctions() ->
init/hal pulls up gadget ->
Gadget is configured, a USB_STATE intent starts MtpServer
MtpServer calls UsbManager#getControlFd to get a dup of the control
endpoint.

Also modify permissions so system server can access mtp files.

Bug: 72877174
Test: Change usb configurations to ptp/mtp
Change-Id: Id17d2b5930f4e1f37ec1b4f00add9d594174ad49
2018-03-22 11:35:19 -07:00
Jerry Zhang
484ea675dd Check mMediaProvider for null
Getting the content provider could
return null in some cases where the user
is locked, so check for that when closing.

Bug: 73656609
Test: no crash
Change-Id: I607cd2da5348520616a1c171d0d8a1afacabe592
2018-03-05 22:25:58 +00:00
Jerry Zhang
f9c5c2574d Add MtpStorageManager for monitoring filesystem events
MtpStorageManager keeps track of file information and
send notifications for new files. MtpDatabase now uses
this instead of MediaProvider for getting object information,
although some operations are still reflected into MP.

Since MtpStorageManager handles storage ids, remove
that field from StorageVolume and VolumeInfo.

Clean up a lot of the jni code for MtpDatabase.

Bug: 63143623
Test: Test every MtpOperation in a variety of situations on Linux and
Windows. Also use the shell to manipulate files. Verify that the cache
is consistent throughout, and the operations behave as expected. Verify
files created by the shell appear.
Test: adb shell am instrument -w android.mtp /android.support.test.runner.AndroidJUnitRunner
Change-Id: Id4ea810047b0c323399cd833047733e5daafb30a
2017-12-15 00:59:41 +00:00
kyle_tso
34be883ebd Merge "Support scanDirectories with JNI callback function"
am: 5747c2b81c

Change-Id: I8996fb568c4024ccf76a5643049de8cee6f811c6
2017-12-06 03:22:30 +00:00
kyle_tso
b4aa69fd11 Support scanDirectories with JNI callback function
MtpServer needs this function to update the database for directory
copy operation.

Test: Call this function from MtpServer and database is updated in
directory copy scenario.

Change-Id: I9b316f4dbf7f35922292c33ab02f9efebc867aa8
Signed-off-by: kyle_tso <kyle_tso@htc.com>
2017-11-22 20:30:42 +08:00
Xin Li
220871a697 Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
2017-11-14 12:31:11 -08:00
Jerry Zhang
18abf57e99 Merge "Add storageId to moveObjects"
am: 1f4f6d2a18

Change-Id: Id4f53fc283850d8f93cde7e67581355dc50e595e
2017-10-19 18:11:49 +00:00
Jerry Zhang
def7b19300 Add storageId to moveObjects
When moving between different storages, the storageId
must be changed as well.

Bug: 67028892
Test: Move between storages with virtual sdcard.
Change-Id: Ie82aa8d53686bfffb7c26b46a49524a00f2f0214
2017-10-17 15:27:03 -07:00
Jerry Zhang
3a13ab1fd3 Merge "Add moveObject method to change object's path and parent." am: 33a200e572 am: 0f09ac317d
am: f9696617bd

Change-Id: Ia6ba6d0cf89879914894d35a0dbf110d905966ac
2017-10-03 00:33:02 +00:00
Jerry Zhang
0f09ac317d Merge "Add moveObject method to change object's path and parent."
am: 33a200e572

Change-Id: Iabb8c9989ad35140ab1c752fb70741f52e56c04d
2017-10-03 00:04:03 +00:00
Jerry Zhang
952558d4e5 Add moveObject method to change object's path and parent.
This is needed to implement the MTP MOVE_OBJECT operation.

Bug: 66679910
Test: Move objects and folders, verify mediastore is consistent
Change-Id: I2f4f0c43134fb3ff82745166c051712cc1736b7f
2017-10-02 11:48:38 -07:00
Jerry Zhang
5f0139d2e8 Add additional context to MtpDatabase
MtpService has been changed to a singleton service
running in user 0, so the original context will
be that of user 0. Accesses to MediaProvider and
MediaScanner should use the new passed in user context
in order to access user data, while the broadcast
receiver for battery data will use the original context.

Bug: 64822515
Test: Use Mtp and switch users.
Change-Id: Ic181258337944db7dc6f6097c967cb104df938d3
2017-08-23 11:10:51 -07:00
Chong Zhang
6e18ccee2a heif: add new file and mime types to MediaScanner -- DO NOT MERGE
bug: 64077740
Change-Id: I6d36c2394a5ae527026c98c83786009e70b20958
2017-08-19 00:05:06 +00:00
Narayan Kamath
492e9e851c Properly guard access to CloseGuard in finalizers.
CloseGuard instances are allocated in constructors and usually
assigned to final fields. This implies they're non-null in finalizers
except in the case where the constructor throws. We add a null check
to make sure we can continue cleaning up other state in the finalizer
(if applicable).

Also, this change decouples closeguard warnings in constructors
from other state based logic. This because the logic there is usually
duplicated with the call to close().

NOTE: This change is not a "complete" fix. Many of these finalizers
are broken in the case where <init> throws. The only objective of
this change is to make such errors more obvious.

Note that some of these classes don't have CTS tests.

Test: make, CtsMediaTestCases.
Bug: 35609098

Change-Id: I24d9e0215f80e44914dba8ab99b6312fd6ed1fc0
2017-04-03 18:12:04 +01:00
Jerry Zhang
e30d5723e4 Merge "Add support for MTP perceived device type property." am: b6ed343e85 am: 7644b885c7
am: 136f37b88f

Change-Id: I446cd52e5fd8cda48e9af46ee3faee5578cae286
2017-03-20 21:54:28 +00:00
Jerry Zhang
13bb2f4dda Add support for MTP perceived device type property.
Property value is based on the particular device.
This allows some hosts (windows) to apply a device
specific icon in file explorer.

Test: Connect device to windows, verify new icon
Bug: 25360563
Change-Id: I9d3468ca8c01a6f0d42ad543aef11ed265b6c825
2017-01-19 11:26:35 -08:00