Implement SharedArtworkContentProvider to centralize and secure alb…#1683
Merged
Conversation
…um art distribution across the system and external controllers.
### Core Architecture & Artwork Sharing
- **SharedArtworkContentProvider**: Introduced a new `ContentProvider` to handle artwork requests via a dedicated authority (`${applicationId}.artwork`). It provides read-only access to cached album art files, improving compatibility with system media style and external metadata consumers.
- **URI Resolution**: Implemented robust URI building and parsing logic within the provider to handle song-specific artwork requests, including support for cache-busting tokens (`?t=`).
- **Manifest Integration**: Registered the new provider with `exported="true"` to allow cross-process artwork access.
### Artwork Utilities & Optimization
- **LocalArtworkUri Enhancements**:
- Added support for detecting and parsing "volatile" artwork URIs (legacy cache files and new shared content URIs).
- Implemented `extractCacheBustToken` to preserve timestamp metadata during URI transformations.
- Refactored `resolveSongArtworkUri` to handle transitions from volatile or legacy URIs to stable internal URI formats.
- **MediaItem Mapping**: Updated `MediaItemBuilder` to use `SharedArtworkContentProvider` URIs when exposing artwork to external controllers, ensuring consistent image loading in notifications and Wear OS.
### Reliability & Testing
- **Unit Tests**:
- Added `SharedArtworkContentProviderTest` to verify authority building, URI construction, and song ID parsing.
- Expanded `LocalArtworkUriTest` to cover legacy cache filename parsing, shared URI resolution, and cache-bust token extraction.
- **Security**: Restricted `SharedArtworkContentProvider` to read-only mode and validated file paths to ensure only legitimate cached artwork is served.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…um art distribution across the system and external controllers.
Core Architecture & Artwork Sharing
ContentProviderto handle artwork requests via a dedicated authority (${applicationId}.artwork). It provides read-only access to cached album art files, improving compatibility with system media style and external metadata consumers.?t=).exported="true"to allow cross-process artwork access.Artwork Utilities & Optimization
extractCacheBustTokento preserve timestamp metadata during URI transformations.resolveSongArtworkUrito handle transitions from volatile or legacy URIs to stable internal URI formats.MediaItemBuilderto useSharedArtworkContentProviderURIs when exposing artwork to external controllers, ensuring consistent image loading in notifications and Wear OS.Reliability & Testing
SharedArtworkContentProviderTestto verify authority building, URI construction, and song ID parsing.LocalArtworkUriTestto cover legacy cache filename parsing, shared URI resolution, and cache-bust token extraction.SharedArtworkContentProviderto read-only mode and validated file paths to ensure only legitimate cached artwork is served.