summaryrefslogtreecommitdiff
path: root/media/java/android/mtp/MtpDatabase.java
Commit message (Collapse)AuthorAgeFilesLines
* Fix MtpDatabase multithreading NullPointerExceptionkatao2022-11-021-5/+7
| | | | | | | | | | | | | | When MtpDatabase receives BATTERY_CHANGED broadcasting, it calls the sendDevicePropertyChanged of mServer. But in some cases, MtpService will call setServer to set mServer to null. There will be an NullPointerException when these two cases occur at the same time. This bug was reported to Google Issue Tracker. Link:https://issuetracker.google.com/issues/111158105 Test: Set the MTP mode and pull out the USB interface when the battery changes. Change-Id: I961c0f3d805b7df32285f578890f2d9efe8340ff
* Limit transcoding size workaround to windowsKevin Rocard2021-11-261-3/+7
| | | | | | | | | | | Test: Connect android to windows through usbc. Enable mtp, then enable the transcoding option. Copy H265 video from the camera folder to windows' desktop. Transcoded H264 video plays correctly in WMPcorrectly. Bug: 184117074 Bug: 190422448 Change-Id: I17264f0ee3e742315569d4c50817b1da7f3f2eb4
* MTP: Skip runtime thumbnail generation for Android HostJames Wei2021-06-211-2/+35
| | | | | | | | | | | | | | | 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
* Merge "MTP: Add thumbnail generation for JPG" am: 5aac2c84ba am: d68b21d215 ↵Treehugger Robot2021-04-011-3/+15
|\ | | | | | | | | | | | | | | am: fe8e0b235f Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657579 Change-Id: Ia6f614fe65c560681b2f076046a7e4295a3f3e86
| * Merge "MTP: Add thumbnail generation for JPG" am: 5aac2c84ba am: d68b21d215Treehugger Robot2021-04-011-3/+15
| |\ | | | | | | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657579 Change-Id: I9b85e42a66e310666de6d811e2af38d428a86f3d
| | * MTP: Add thumbnail generation for JPGJames Wei2021-03-301-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | Fix renaming file and moving file issue in MTPIvan Chiang2021-01-111-96/+24
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Add unsupported mime types in media capabilitiesManish Singh2021-01-201-4/+6
| | | | | | | | | | | | | | | | | | | | | | 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
* | Support transcode via MTPZim2021-01-151-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix renaming file and moving file issue in MTPIvan Chiang2020-11-191-96/+24
|/ | | | | | | | | | | | | | | | | | | | | 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
* MTP: media info can not be retrieved via MTP#2James Wei2020-05-011-0/+1
| | | | | | | | | | | | | 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
* MTP: Fix MTP SD card issueJames Wei2020-04-221-1/+2
| | | | | | | | | | 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
* MTP: Add MtpDatabase unit testJames Wei2020-04-221-3/+7
| | | | | | | | Add Thumbnail feature test cases Bug: 117863715 Test: atest MtpTests Change-Id: I5a09efef10df20e382a4c623481e048e7b35ff14
* Merge "MTP: Add MTP Thumbnail feature"James Wei2020-02-051-0/+47
|\
| * MTP: Add MTP Thumbnail featureJames Wei2020-01-221-0/+47
| | | | | | | | | | | | | | | | | | | | 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
* | Exempt-From-Owner-Approval: Fix usages of WindowManager.getDefaultDisplay() ↵Andrii Kulian2020-01-311-0/+1
|/ | | | | | | | | | | | 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
* Shuffling to prepare for MediaProvider APEX.Jeff Sharkey2019-12-181-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Disable support for object references.Jeff Sharkey2019-12-161-64/+5
| | | | | | | | | | | | | | | | | | | | 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
* Remove libexif usage from libmedia_jni.soMarco Nelissen2019-07-021-0/+50
| | | | | Test: manual, connect with MTP and PTP Change-Id: I33128db25b8aae60df7854c61fc2a3873a1bced9
* Adjust MTP to reference by specific volume name.Jeff Sharkey2019-04-171-29/+28
| | | | | | | | | | 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
* Query specific collections for properties.Jeff Sharkey2019-03-241-124/+59
| | | | | | | | | | | | | | | 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
* MTP: remove usages of device identifiers with virtual serial numberJames Wei2019-02-201-1/+6
| | | | | | | | | | | | | | | 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
* MTP: media info can not be retrieved via MTPJames Wei2018-10-221-1/+6
| | | | | | | | | | | | | | 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)
* MTP: Add support of ObjectInfoChanged EventJames2018-07-271-0/+6
| | | | | | | | | | | | | | 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
* Replace streams with Lists in MtpStorageManagerJerry Zhang2018-07-161-18/+25
| | | | | | | | Streams are dispreferred in Android java, so use Lists for all cases instead. Test: Mtp works and MtpStorageManager tests pass Change-Id: I0579013fca690346c6c2561fe3079fd50f215833
* Call access(2) on all files/dirs modified by MtpJerry Zhang2018-05-151-0/+10
| | | | | | | | | | | | | 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
* Merge "Guard against null server" into pi-devJerry Zhang2018-03-271-2/+6
|\
| * Guard against null serverJerry Zhang2018-03-271-2/+6
| | | | | | | | | | | | | | | | | | | | | | 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
* | Revert "Add additional context to MtpDatabase"Jerry Zhang2018-03-221-2/+2
|/ | | | | | | | This reverts commit 5f0139d2e8bc8b5819e2c5ef4440f766a4af8813. Bug: 72877143 Test: Switch users, use MTP Change-Id: Ide372a9311a4f2647715d052fc0e1d9a04808aa0
* Check mMediaProvider for nullJerry Zhang2018-03-051-1/+3
| | | | | | | | | | 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
* Add MtpStorageManager for monitoring filesystem eventsJerry Zhang2017-12-151-769/+570
| | | | | | | | | | | | | | | | | | | | 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
* Merge "Support scanDirectories with JNI callback function"kyle_tso2017-12-061-0/+6
|\ | | | | | | | | | | am: 5747c2b81c Change-Id: I8996fb568c4024ccf76a5643049de8cee6f811c6
| * Support scanDirectories with JNI callback functionkyle_tso2017-11-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit '98e12851336b7db16e583f9afac63ecc97465980' fromXin Li2017-11-141-3/+7
|\ \ | |/ |/| | | | | | | | | oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master. Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7 Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
| * Merge "Add moveObject method to change object's path and parent." am: ↵Jerry Zhang2017-10-031-0/+27
| |\ | | | | | | | | | | | | | | | | | | | | | 33a200e572 am: 0f09ac317d am: f9696617bd Change-Id: Ia6ba6d0cf89879914894d35a0dbf110d905966ac
| * | Add additional context to MtpDatabaseJerry Zhang2017-08-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | heif: add new file and mime types to MediaScanner -- DO NOT MERGEChong Zhang2017-08-191-0/+2
| | | | | | | | | | | | | | | bug: 64077740 Change-Id: I6d36c2394a5ae527026c98c83786009e70b20958
* | | Merge "Add storageId to moveObjects"Jerry Zhang2017-10-191-8/+18
|\ \ \ | |_|/ |/| | | | | | | | | | | am: 1f4f6d2a18 Change-Id: Id4f53fc283850d8f93cde7e67581355dc50e595e
| * | Add storageId to moveObjectsJerry Zhang2017-10-171-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | When moving between different storages, the storageId must be changed as well. Bug: 67028892 Test: Move between storages with virtual sdcard. Change-Id: Ie82aa8d53686bfffb7c26b46a49524a00f2f0214
* | | Merge "Add moveObject method to change object's path and parent."Jerry Zhang2017-10-031-0/+27
|\| | | |/ |/| | | | | | | am: 33a200e572 Change-Id: Iabb8c9989ad35140ab1c752fb70741f52e56c04d
| * Add moveObject method to change object's path and parent.Jerry Zhang2017-10-021-0/+27
| | | | | | | | | | | | | | | | This is needed to implement the MTP MOVE_OBJECT operation. Bug: 66679910 Test: Move objects and folders, verify mediastore is consistent Change-Id: I2f4f0c43134fb3ff82745166c051712cc1736b7f
* | Properly guard access to CloseGuard in finalizers.Narayan Kamath2017-04-031-1/+4
|/ | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for MTP perceived device type property.Jerry Zhang2017-01-191-0/+9
| | | | | | | | | | 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
* Fix argument type in MtpDatabase#getObjectPropertyValue.Daichi Hirono2016-03-011-16/+15
| | | | | | | | | | | | 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
* Extend MediaScanner and MtpDatabase to support RAW image filesJaesung Chung2016-01-191-0/+2
| | | | | Bug: 25871812 Change-Id: Iee92632585dc9020238a9b562defd06d6d2a91dc
* Discourage use of "_data" column.Jeff Sharkey2016-01-061-42/+49
| | | | | | | | | | | | | | | | | | 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
* Remove unused imports in frameworks/base.John Spurlock2015-02-281-1/+0
| | | | Change-Id: I031443de83f93eb57a98863001826671b18f3b17
* MTP: Fix partial implementation of 5 new audio specific propertiesMike Lockwood2015-01-231-39/+29
| | | | | | | | | | | | | | | | | | | | | | 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
* Also consider secondary storage when verifying pathsMarco Nelissen2014-10-151-2/+4
| | | | | | Bug: 17673184 Bug: 17982103 Change-Id: Ief14c7776b02983191c46774fa7e4c76380de58d
* Validate MTP pathMarco Nelissen2014-09-261-0/+20
| | | | | Bug: 17673184 Change-Id: I51a64f065d9b3609557af81e596ebeb8720ab6c5