summaryrefslogtreecommitdiff
path: root/legacy
AgeCommit message (Collapse)Author
2025-02-12Keep separate files for Legacy MediaProvider Himanshu Arora
Move files to legacy package which are necessary to build legacy MediaProvider. This change isolates legacy functionality so that modifications to the upstream files won't impact the legacy MediaProvider build. Additionally, remove the playlist and dao package since these are not required Flag: EXEMPT, code refactor Test: m MediaProviderLegacy Bug: 395901424 Change-Id: I652a7e397e1de65a10cb742b6f18552b6b3e79dd
2024-08-30Merge "Make java_sdk_library dependencies explicit" into main am: f369ddf3a9 Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/3247658 Change-Id: I7384958652e4d040889017e82d86d0604751a683 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-08-30Make java_sdk_library dependencies explicit Jihoon Kang
modules should specify the submodule of java_sdk_library that the module actually depends on Test: CI Bug: 358613520 Change-Id: Ie3ad72f004a5de8fd917de17864b8ea6cf1561fe
2024-05-17Update logging tag name of LegacyMediaProvider Dipankar Bhardwaj
Change-Id: I9cba95b4ee9843abe567f4af78dceff9b7947390 Test: n/a Bug: 341190735
2023-05-31Remove LegacyDatabaseHelper code from MP source code Dipankar Bhardwaj
LegacyDatabaseHelper code affects code coverage numbers for MP module. Test: n/a Bug: 284258052 Change-Id: Ie28208ee10936da11eec8ac2db2fe0e50e08f04d
2023-04-20Remove ProfileInstallReceiver Sahana Rao
LegacyMediaProvider doesn't need this receiver. Test that tests LegacyMediaProvider doesn't have any receivers is failing because of this receiver. Removing it from the manifest explicitly. Bug: 278130163 Test: atest android.provider.cts.media.MediaStoreTest#testLegacy Change-Id: If5c96a6afdc9f5ea73eab07767739593b1fae130
2022-10-21Remove LegacyMediaProvider dependency on DatabaseHelper Dipankar Bhardwaj
As part of Stable URIs, we need to get an instance of MediaProvider to interact with FuseDaemon to perform leveldb operations. Since we were using the same DatabaseHelper class for MP and Legacy MP, we cannot MP as local content provider in the same class. Test: n/a Bug: 253026009 Change-Id: I71cbbcc7c838eed5b333e0a485890b431c2b3f5b
2022-05-18Fix next row id backup for work profile and adoptable storage Dipankar Bhardwaj
With work profile, Media Provider process did not have the required permission(media_rw) to set xattr on /data/media/<user-id>. In this CL, we are making a change to set xattr on /data/media/0 for all user profiles by adding user id suffix to xattr keys. In case of user id reuse, it should work fine as next row id would not have been used previously. Also for devices with adoptable storage support, opting for adoptable storage will not delete /data/media/0 directory. Test: Manually on multiple user profiles and on adoptable storage Bug: 216743720 Change-Id: I710e95742b41e19822ed7f80a5930b860611b19d
2022-01-27Fix licenses and license texts. Bob Badour
Entire project is 1p. Test: m nothing Change-Id: I89bfb50edff9c91cf680e883ec850c794cd510b4
2021-10-20Hide the column in query result by @ExportedSince value Ivan Chiang
- Add the @ExportedSince Build.VERSION_CODES.S on is_recording - If the column is added @ExportedSince by X version, if the os version is less than X, the query result won't include the column. Test: atest MediaProviderTest Test: atest DatabaseHelperTest Bug: 202040814 Change-Id: Ib019feb0ef715ac1b828ae5c39140bcfb80cf51e
2021-09-07Remove custom BackgroundThread and HandlerExecutor William Escande
Use stand-alone modules-utils library. Files import has changed accordingly. local filegroup has been updated to java_library. Bug: 198418216 Tag: #refactor Test: atest MediaProviderTests MediaProviderClientTests Ignore-AOSP-First: Merge conflict resolution Change-Id: Ie77277cd990216ba6cf6b83885574223e0fca590
2021-08-30Merge "Remove startup provider from legacy MediaProvider manifest" am: ↵ Treehugger Robot
b043718839 am: 26a8485635 am: aaadd8fcca am: 5a77bd88ac am: 15e936c816 Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/1813477 Change-Id: I77b7557ed9ba9fa8b1df6807cd39a3e96f4a8ebd
2021-08-30Merge "Remove startup provider from legacy MediaProvider manifest" am: ↵ Treehugger Robot
b043718839 Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/1813477 Change-Id: Iba1f6c23d1fa931079a98250fbe0f4ae48bee5b8
2021-08-30Remove startup provider from legacy MediaProvider manifest Alan Viverette
Change-Id: I7a59c9ce791943f13885b553640e56335131085e Fixes: 197891819 Test: android.provider.cts.media.MediaStoreTest
2021-06-16No-op refactor to support more than 2 dbs in DatabaseHelper Zim
Currently, the DatabaseHelper assumes MediaProvider can only have 2 dbs, so if a db is NOT internal, it is external. For the photo picker, we will introduce a separate db, picker.db which breaks this assumption. In preparation to introduce the picker.db, we refactor the code with explicit methods to check if db is internal or external. In future cl, we'll add an explicit check for picker db. Test: presubmit Bug: 190713331 Change-Id: Iab0fbe9a9047fc63a043685312a1e1fd394f9b48
2021-02-21Merge "[LSC] Add LOCAL_LICENSE_KINDS to packages/providers/MediaProvider" ↵ Bob Badour
am: 95cf803022 am: c8d5dbb7d3 am: 229793cb0f Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/1588510 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ide7b90d69f7d0fd266ca22003898d8d2d7de2aef
2021-02-12[LSC] Add LOCAL_LICENSE_KINDS to packages/providers/MediaProvider Bob Badour
Added SPDX-license-identifier-Apache-2.0 to: Android.bp apex/Android.bp apex/framework/Android.bp apex/testing/Android.bp errorprone/Android.bp jni/Android.bp legacy/Android.bp tests/Android.bp tests/client/Android.bp tools/dialogs/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Ibbbf07ceca50a345680a911a3860321ab71c83c3
2021-02-10Add AudioColumn is_recording and support recording type Ivan Chiang
Bug: 161526501 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: I844f463d7f98185a507d24c4d7970d7d1de2ec72
2020-09-19Support Playlist#Members uri in LegacMediaProvider Sahana Rao
Previously, LegacyMediaProvider mapped all uris to "files" table. To migrate playlist->audio map, we need to query "audio_playlists_map" table. To be able to query "audio_playlists_table", LegacyMediaProvider should map Playlist#Members uri to "audio_playlists_map" table. This is a minimal change in LegacyMediaProvider to map Playlist#Members uri to "audio_playlists_map" table. Any other uri still maps to "files" table. Bug: 165904660 Test: LegacyProviderMigrationTest#testLegacy_PlaylistMap Change-Id: Ib6210c214bab32dfca2a2254e7ca4cf9ff31a6db (cherry picked from commit b9f6864f54dade89afc7afad3a78da567f1c4f14) (cherry picked from commit 9a5c84884f6268ba463864924965419a1772fe12)
2020-09-09Support Playlist#Members uri in LegacMediaProvider Sahana Rao
Previously, LegacyMediaProvider mapped all uris to "files" table. To migrate playlist->audio map, we need to query "audio_playlists_map" table. To be able to query "audio_playlists_table", LegacyMediaProvider should map Playlist#Members uri to "audio_playlists_map" table. This is a minimal change in LegacyMediaProvider to map Playlist#Members uri to "audio_playlists_map" table. Any other uri still maps to "files" table. Bug: 165904660 Test: LegacyProviderMigrationTest#testLegacy_PlaylistMap Change-Id: Ib6210c214bab32dfca2a2254e7ca4cf9ff31a6db
2020-07-01Add version code to legacy MediaProvider manifest. Corina
This ensures the version code is higher than for the previous release. This is also only for the legacy version. Bug: 160230380 Test: version number is now the same as non-legacy Change-Id: If63138b1e8dbe862beca3c0273a9f832d1b9d9e9
2020-04-16Improvements for migration of large databases. Jeff Sharkey
When migrating thousands of media items from a legacy provider, we can't actually fit everything inside a single SQLite transaction, since it'll fail with SQLITE_NOMEM. To handle this, we need to shift the migrateFromLegacy() logic to manage its own transactions, instead of running inside the single transaction driven by the onUpgrade() flow. We do this by shifting to onOpen() which has no automatic transaction. We also add a "silent" option to the legacy provider to skip creating thousands of media files during the newly added test; without this we'd timeout. Bug: 153842860 Test: atest MediaProviderClientTests:com.android.providers.media.client.LegacyProviderMigrationTest Change-Id: Ieed9036ed7d308d8b60ce2025e8d43b418dd67a0
2020-04-02Progress towards database schema locking. Jeff Sharkey
We recently tried fixing some obscure SQLite deadlocking in a51c3d1c, but the cure was worse than the disease, since any threads just about to perform a database operation before we close() the database would encounter an "Cannot perform this operation because the connection pool has been closed" exception. Since we don't have control over the deep inner workings of SQLite which result in the deadlock, the best we can do is to create a ReadWriteLock where the "readers" are all normal database mutations or queries, and the "writers" are schema modifications. We're going to land this in two phases; the first phase here shifts all database interactions to be driven by runWithTransaction() or runWithoutTransaction(), which we'll use to acquire the upcoming schema ReadWriteLock. Any SQLiteDatabase instances obtained through getReadableDatabase() or getWritableDatabase() would be unprotected by this schema lock, so we adjust those methods to explicitly throw, to ensure that all future changes interact with the database safely. Bug: 152005629, 152802030 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ia79fb94e71352744006a7e1182dfeb112889bdf3
2020-03-31Restore deleted database row on create and rename Sahana Rao
On create & rename, if the new path was previously deleted, saved deleted row ID is restored. Added custom database functions to generate row ID for insert and update operations. Deleted row ID is restored only if insert and update are initiated by FUSE thread. Test: atest packages/providers/MediaProvider Bug: 151076202 Change-Id: Ib6cc0b84f6f79988226cbd960395321facabafb6
2020-03-25Align databases with migration lifecycle. Jeff Sharkey
We've seen evidence of the remote caller attempting multiple migrations, so adjust the logic to ensure that we always have a valid database while an active migration is taking place. Also protect the Mainline code from a legacy provided that is having trouble with lifecycle events. Bug: 151960212 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: I3920bb652352ca3a08d2004fb5e3e135cbc0ce82
2020-03-07Updates based on API council feedback. Jeff Sharkey
-- Promote generally-useful PFD API to public. -- Add @WorkerThread annotations. -- Add docs to explain how AUTHORITY_LEGACY works, and add explicit START/FINISH_LEGACY_MIGRATION_CALL verbs to communicate progress. -- Expand docs for createWriteRequest() to explain broader access that it grants. Expand all request methods to indicate the action is fully completed before the result is delivered. -- Expand docs for new generation fields to explain that version also needs to be inspected. -- Explicitly call out why getKindSize() is deprecated, and guide towards better alternative. Bug: 148867182, 148403418, 148011561, 147760276 Test: none Change-Id: Ibfae5a0b490d4b4b3f1725b72e246833f79c50e2
2020-02-17Merge "Add media-provider compat config to the APEX." Anna Trostanetski
2020-02-10Adds forceQueryable to manifest Patrick Baumann
This change adds the forceQueryble attribute to the manifests of both the module and legacy media providers so that consumers of the media provider don't need to modify their manifests. Test: atest ExternalStorageHostTest Bug: 142386643 Change-Id: Ib6fce200e23b6bcaea001553fdef726c7e965711
2020-02-07Add media-provider compat config to the APEX. atrost
Also adding a dependancy on the annotations lib to allow defining changes. Test: m Test: flash device, inspect unpacked APEX and the config is present. Bug: 142650523 Change-Id: I221d8fc945cf8eb2f1d360ef4be8b2db1fb18187
2020-01-20Consistent content change notifications. Jeff Sharkey
In upcoming changes we're preparing to start sending change notifications that include the actual operation type, such as insert, update, or delete. We could try gathering this up in MediaProvider, but that's already proven tedious and hard to ensure that we always gather the correct set of IDs that have changed. That would be even more difficult since update() or delete() calls don't always have easy access to the MEDIA_TYPE of the items being changed. The most robust solution would be to always get direct notifications from SQLite as media items are changed. Thankfully we can use the recently added SQLiteDatabase.setCustomScalarFunction() along with triggers to get precise information on exactly when and how items change in the database. This new approach fixes several subtle and long-standing bugs where update() and delete() thumbnail invalidation and change notifications may have been incorrect when called without a transaction held, or not updating MediaDocumentsProvider state. It also lets us bypass postProcessMetadataForFuseRename() entirely, since any database changes performed from FUSE will now automatically result in the right side-effects. Bug: 144464323, 147778086 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: I261f410b47e08e407bc584581df1ed073566b1f8
2020-01-13Introduce "generation" to track mutations. Jeff Sharkey
Add generation numbers to the metadata for each media item. This is useful for apps that are attempting to quickly identify exactly which media items have changed since a previous point in time. Generation numbers are monotonically increasing over time, and can be safely arithmetically compared. Detecting media changes using generation numbers is more robust than using DATE_MODIFIED, since those values may change in unexpected ways when apps use File.setLastModified() or when the system clock is set incorrectly. This is implemented by ensuring that all mutations to go through our local SQLiteQueryBuilder, which then forces those mutations to always happen inside an active transaction. Then each time we create a transaction, we increment the generation counter, and force-copy the current generation into any mutation operations. This design also means that all mutations that should affect the generation counter must go through DatabaseHelper to ensure that the logic above is applied; there's mechanical refactoring across MediaProvider to accomplish this. Fix bug in getWritableDatabase() that could return a readable database. Fix bug in LegacyMediaProvider to create missing directories. Adjust logging script to enable log cleaner SQL from SQLQueryBuilder instead of noisy raw logs. Bug: 140248585 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: I15f05c79ed5ff445e20679dedafb1b800755458b
2020-01-07Introduce persistent logs to aid debugging. Jeff Sharkey
As requested by partners, this changes begins emitting important events into a persistent log files on disk to aid in later debugging investigations. This also logs non-standard ".nomedia" files that we encounter on disk. Also fixes bug where dump() would end up trying to obtain the database from the main thread, which would could trigger ANRs. Bug: 143723019, 142072796, 141506637, 137970002, 145014907 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: I5b681d9007fc344e87e53f4a9a37270f65a6b016
2019-12-22Build MediaProviderLegacy with "system_current". Jeff Sharkey
As a recent bug just reminded us, we can't have MediaProviderLegacy depending on hidden APIs delivered through the APEX, since they're unstable and can change at any time. This requires a slight pivot of our original design strategy, where the only shared code between the legacy and modern providers is the DatabaseHelper logic. This requires some side-stepping to ensure that DatabaseHelper and its dependencies safely build against "system_current". We also adjust DatabaseHelper to only log metrics when running as the real production database, to avoid noise from the legacy provider and unit tests. These changes also helped uncover that our unit tests were technically running against MediaProviderLegacy, which no longer holds the bulk of the code that needs to be tested. It's tricky to get an accurate instrumentation target because our tests live in AOSP, but a device may have either the AOSP or Mainline version of the module. Thus we pull everything directly into MediaProviderTests to ensure that we can run tests against it. Bug: 146670970 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ib257793f5d8a12eb83e18b0eed6284e25d7c011c