summaryrefslogtreecommitdiff
path: root/media/java/android/mtp/MtpDatabase.java
AgeCommit message (Collapse)Author
2021-06-21MTP: Skip runtime thumbnail generation for Android HostJames Wei
Android Host is not capable to deal with the long processing time for runtime thumbnail generation. Skip runtime thumbnail generation for Android Host but keep no impact to other Host Bug: 188752500 Test: atest MtpTests Test: atest MtpServerTest Test: atest MtpServiceTests Test: manual test on Windows 10 File Explorer Test: manual test on Android Host Files App Change-Id: I24ed3bb29c5a6912398a9e00e7748fd406cf6a64
2021-04-01Merge "MTP: Add thumbnail generation for JPG" am: 5aac2c84ba am: d68b21d215 ↵Treehugger Robot
am: fe8e0b235f Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657579 Change-Id: Ia6f614fe65c560681b2f076046a7e4295a3f3e86
2021-04-01Merge "MTP: Add thumbnail generation for JPG" am: 5aac2c84ba am: d68b21d215Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657579 Change-Id: I9b85e42a66e310666de6d811e2af38d428a86f3d
2021-03-30MTP: Add thumbnail generation for JPGJames Wei
Add thumbnail generation support for JPG image format Instead of retrieving thumbnail from EXIF header Bug: 178726106 Test: atest MtpTests Test: manual test on Windows 10 file explorer Test: manual test on Linux nautilus file browser Change-Id: I29ad89835a8a27204a2e6dbd97b994209a813424
2021-01-20Add unsupported mime types in media capabilitiesManish Singh
Since ApplicationMediaCapabilities now provides the option to add unsupported mime types, we add the unsupported types to the bundle for the case when we want transcoding to happen in MTP. Test: manual BUG=158466651 Change-Id: I1266c0753e43b84ec4f5bd181386f5c6aeb477d3
2021-01-15Support transcode via MTPZim
Add a helper method to open files via MediaProvider ContentResolver. Note that we are optimizing for the current default transcode option - B (which is to transcode) and therefore we include the bundle only when we do not want to transcode. Test: Manual Bug: 158466651 Change-Id: I48436ef143feb889b523a9c0e620c2312157ef89
2021-01-11Fix renaming file and moving file issue in MTPIvan Chiang
After the user renames/moves a file/directory, the database of MediaProvider is not updated. It causes that the file can't be opened via MediaProvider. Use scanFile to instead of MP.update for the file/directory. Handle the .nomedia case for create/copy/move/delete/rename. Scan the parent directory to update the database. Test: atest MtpTests Test: atest --test-mapping packages/providers/MediaProvider Test: manual. 1. Move/rename the file/directory. 2. Open the file in DocumentsUI 3. create/copy/move/delete/rename for .nomedia case Bug: 169300366 Bug: 171538933 Bug: 172029805 Bug: 170798581 Change-Id: Ia37be7a027bfe502e3f7c96babe5a5bbed5f942c Merged-In: Ia37be7a027bfe502e3f7c96babe5a5bbed5f942c (cherry picked from commit 20079f10644e641bbb2c35c250e8a9e0b9f6c1b3)
2020-11-19Fix renaming file and moving file issue in MTPIvan Chiang
After the user renames/moves a file/directory, the database of MediaProvider is not updated. It causes that the file can't be opened via MediaProvider. Use scanFile to instead of MP.update for the file/directory. Handle the .nomedia case for create/copy/move/delete/rename. Scan the parent directory to update the database. Test: atest MtpTests Test: atest --test-mapping packages/providers/MediaProvider Test: manual. 1. Move/rename the file/directory. 2. Open the file in DocumentsUI 3. create/copy/move/delete/rename for .nomedia case Bug: 169300366 Bug: 171538933 Bug: 172029805 Bug: 170798581 Change-Id: Ia37be7a027bfe502e3f7c96babe5a5bbed5f942c
2020-05-01MTP: media info can not be retrieved via MTP#2James Wei
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-04-22MTP: Fix MTP SD card issueJames Wei
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-22MTP: Add MtpDatabase unit testJames Wei
Add Thumbnail feature test cases Bug: 117863715 Test: atest MtpTests Change-Id: I5a09efef10df20e382a4c623481e048e7b35ff14
2020-02-05Merge "MTP: Add MTP Thumbnail feature"James Wei
2020-01-31Exempt-From-Owner-Approval: Fix usages of WindowManager.getDefaultDisplay() ↵Andrii Kulian
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-22MTP: Add MTP Thumbnail featureJames Wei
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
2019-12-18Shuffling to prepare for MediaProvider APEX.Jeff Sharkey
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-16Disable support for object references.Jeff Sharkey
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-07-02Remove libexif usage from libmedia_jni.soMarco Nelissen
Test: manual, connect with MTP and PTP Change-Id: I33128db25b8aae60df7854c61fc2a3873a1bced9
2019-04-17Adjust MTP to reference by specific volume name.Jeff Sharkey
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-03-24Query specific collections for properties.Jeff Sharkey
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-02-20MTP: remove usages of device identifiers with virtual serial numberJames Wei
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
2018-10-22MTP: media info can not be retrieved via MTPJames Wei
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-07-27MTP: Add support of ObjectInfoChanged EventJames
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-16Replace streams with Lists in MtpStorageManagerJerry Zhang
Streams are dispreferred in Android java, so use Lists for all cases instead. Test: Mtp works and MtpStorageManager tests pass Change-Id: I0579013fca690346c6c2561fe3079fd50f215833
2018-05-15Call access(2) on all files/dirs modified by MtpJerry Zhang
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-03-27Merge "Guard against null server" into pi-devJerry Zhang
2018-03-27Guard against null serverJerry Zhang
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-22Revert "Add additional context to MtpDatabase"Jerry Zhang
This reverts commit 5f0139d2e8bc8b5819e2c5ef4440f766a4af8813. Bug: 72877143 Test: Switch users, use MTP Change-Id: Ide372a9311a4f2647715d052fc0e1d9a04808aa0
2018-03-05Check mMediaProvider for nullJerry Zhang
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
2017-12-15Add MtpStorageManager for monitoring filesystem eventsJerry Zhang
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-06Merge "Support scanDirectories with JNI callback function"kyle_tso
am: 5747c2b81c Change-Id: I8996fb568c4024ccf76a5643049de8cee6f811c6
2017-11-22Support scanDirectories with JNI callback functionkyle_tso
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-14Merge commit '98e12851336b7db16e583f9afac63ecc97465980' fromXin Li
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master. Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7 Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
2017-10-19Merge "Add storageId to moveObjects"Jerry Zhang
am: 1f4f6d2a18 Change-Id: Id4f53fc283850d8f93cde7e67581355dc50e595e
2017-10-17Add storageId to moveObjectsJerry Zhang
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-03Merge "Add moveObject method to change object's path and parent." am: ↵Jerry Zhang
33a200e572 am: 0f09ac317d am: f9696617bd Change-Id: Ia6ba6d0cf89879914894d35a0dbf110d905966ac
2017-10-03Merge "Add moveObject method to change object's path and parent."Jerry Zhang
am: 33a200e572 Change-Id: Iabb8c9989ad35140ab1c752fb70741f52e56c04d
2017-10-02Add moveObject method to change object's path and parent.Jerry Zhang
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-08-23Add additional context to MtpDatabaseJerry Zhang
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-19heif: add new file and mime types to MediaScanner -- DO NOT MERGEChong Zhang
bug: 64077740 Change-Id: I6d36c2394a5ae527026c98c83786009e70b20958
2017-04-03Properly guard access to CloseGuard in finalizers.Narayan Kamath
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-01-19Add support for MTP perceived device type property.Jerry Zhang
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
2016-03-01Fix argument type in MtpDatabase#getObjectPropertyValue.Daichi Hirono
In MTP code, we use jint for ID (e.g. object handle) and code (property code). But getObjectPropertyValue takes jlong and it causes missing property values in Java code. Previously we passed the long value to Map<Integer, MtpPropertyGroup>#get(Integer) and the compiler somehow accepted the code. However it actually takes Long at runtime, so the properties are never found. BUG=26437284 Change-Id: I79defd325ea5d20c4dce84d891d984e24abcacc5
2016-01-19Extend MediaScanner and MtpDatabase to support RAW image filesJaesung Chung
Bug: 25871812 Change-Id: Iee92632585dc9020238a9b562defd06d6d2a91dc
2016-01-06Discourage use of "_data" column.Jeff Sharkey
Moving forward, all client file access really needs to be going through explicit APIs like openFileDescriptor(), since that allows the provider to better protect its underlying files. This change also changes several classes to use the AutoClosable pattern, which enables try-with-resources usage. Older release() methods are deprecated in favor of close(). Uniformly apply CloseGuard across several classes, using AtomicBoolean to avoid double-freeing, and fix several resource leaks and bugs related to MediaScanner allocation. Switch MediaScanner and friends to use public API instead of raw AIDL calls. Bug: 22958127 Change-Id: Id722379f72c9e4b80d8b72550d7ce90e5e2bc786
2015-02-28Remove unused imports in frameworks/base.John Spurlock
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-01-23MTP: Fix partial implementation of 5 new audio specific propertiesMike Lockwood
In change Ic5b3fb75309893caae1a4f4b56068a543847f1f7, we added partial support for the MTP properties: MTP_PROPERTY_AUDIO_WAVE_CODE, MTP_PROPERTY_BITRATE_TYPE MTP_PROPERTY_AUDIO_BITRATE MTP_PROPERTY_NUMBER_OF_CHANNELS MTP_PROPERTY_SAMPLE_RATE However we were not returning any values for these properties in the result of the MTP GetObjectPropList command. Strangely, this triggers a nasty bug in Windows 7 that results in data loss. When copying a directory containing several MP3 files from one location on the device to another, Windows will copy only some of the files to the new location, but delete all of the originals. Finishing the implementation of these new object properties for some unknown reason stops this bad behavior in Windows 7. Bug: 19018427 Change-Id: I5fd3b91a89b31827d3100686445cef6795fe0f3f
2014-10-15Also consider secondary storage when verifying pathsMarco Nelissen
Bug: 17673184 Bug: 17982103 Change-Id: Ief14c7776b02983191c46774fa7e4c76380de58d
2014-09-26Validate MTP pathMarco Nelissen
Bug: 17673184 Change-Id: I51a64f065d9b3609557af81e596ebeb8720ab6c5
2014-03-27Make setServer() safe to call multiple timesMarco Nelissen
This makes it safe to call setServer() multiple times with the same server, different servers, or null. b/13622801 Change-Id: Id04440df720f830e67106eb543653ace42430d97
2014-03-13MTP: Add support for some audio specific object propertiesMike Lockwood
This stops Windows 7 from putting up the "Your device might not be able to play or view this file" dialog when copying MP3 files to the device. Bug: 3195286 Change-Id: Ic5b3fb75309893caae1a4f4b56068a543847f1f7