Phase 5: Offline downloads at selectable bitrates
Adds Room + WorkManager-backed offline downloads: a bitrate picker (Low/Normal/High/Original) on track and album detail screens, a Downloads library screen, and Settings additions for Wi-Fi-only downloads and default quality. Bitrate tiers route through Subsonic's `stream` endpoint with `maxBitRate`; Original uses `download`, which always returns the untranscoded source file. Three real bugs found and fixed during on-device verification: - WorkManager was constructing DownloadWorker with its default reflection-based WorkerFactory instead of HiltWorkerFactory (NoSuchMethodException on the @AssistedInject constructor). The default androidx.startup auto-init ran before Hilt's field injection was guaranteed to have happened. Fixed by disabling the manifest's auto-init provider and calling WorkManager.initialize() manually in DeepwaveApplication.onCreate(), after super.onCreate(). - Crash on every download: WorkManager's own SystemForegroundService declares no foregroundServiceType in its manifest, but the worker requests dataSync at runtime via ForegroundInfo, which API 29+ requires to be a subset of what's manifest-declared. Fixed by manifest-merging that service with foregroundServiceType="dataSync". - Offline playback was completely broken: ResolvingDataSource only rewrites the DataSpec's URI (to file:// for a downloaded track) but always hands it to the same wrapped upstream DataSource to open. OkHttpDataSource can only open http(s) URLs, so the rewritten file:// URI failed with "Malformed URL" and playback silently fell through to the network. Wrapping the signed OkHttpDataSource.Factory in DefaultDataSource.Factory routes by scheme instead - this bug was latent since Phase 4, since LocalTrackFiles was always empty until now and the local-file path was never actually exercised. - Re-downloading a track at a different quality could produce a different file extension (Content-Type-driven), orphaning the previous file on disk with no cleanup path. DownloadWorker now clears any existing files for the track id before writing the new one. Verified on-device: downloads at all four tiers produce distinctly different, correctly-ordered file sizes (Low < Normal < High < Original); a fully downloaded track keeps playing with Wi-Fi and mobile data both disabled; killing and relaunching the app mid-download lets WorkManager resume the interrupted download to a correct, byte-exact final file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ad10f891b6
commit
a89e81983e
@@ -17,6 +17,22 @@
|
||||
|
||||
<string name="settings_title">Settings</string>
|
||||
<string name="settings_log_out">Log out</string>
|
||||
<string name="settings_downloads">Downloads</string>
|
||||
<string name="settings_wifi_only_downloads">Download over Wi-Fi only</string>
|
||||
<string name="settings_default_quality">Default download quality</string>
|
||||
|
||||
<string name="download_notification_channel_name">Downloads</string>
|
||||
<string name="download_notification_title">Downloading</string>
|
||||
<string name="download_pick_quality">Download quality</string>
|
||||
<string name="download_album">Download album</string>
|
||||
<string name="download_action">Download</string>
|
||||
<string name="download_downloading">Downloading</string>
|
||||
<string name="download_downloaded">Downloaded</string>
|
||||
<string name="download_failed">Download failed, tap to retry</string>
|
||||
<string name="download_remove">Remove download</string>
|
||||
|
||||
<string name="downloads_title">Downloads</string>
|
||||
<string name="downloads_empty">No downloads yet</string>
|
||||
|
||||
<string name="player_nothing_playing">Nothing playing</string>
|
||||
<string name="player_play">Play</string>
|
||||
|
||||
@@ -8,4 +8,7 @@
|
||||
<full-backup-content>
|
||||
<exclude domain="sharedpref" path="deepwave_master_keyset_prefs.xml"/>
|
||||
<exclude domain="file" path="datastore/deepwave_credentials.preferences_pb"/>
|
||||
<!-- Restoring "downloaded" rows without the actual audio files (app-specific external
|
||||
storage, never backed up) would be misleading state - the DB and files must move together. -->
|
||||
<exclude domain="database" path="deepwave.db"/>
|
||||
</full-backup-content>
|
||||
@@ -7,9 +7,11 @@
|
||||
<cloud-backup>
|
||||
<exclude domain="sharedpref" path="deepwave_master_keyset_prefs.xml"/>
|
||||
<exclude domain="file" path="datastore/deepwave_credentials.preferences_pb"/>
|
||||
<exclude domain="database" path="deepwave.db"/>
|
||||
</cloud-backup>
|
||||
<device-transfer>
|
||||
<exclude domain="sharedpref" path="deepwave_master_keyset_prefs.xml"/>
|
||||
<exclude domain="file" path="datastore/deepwave_credentials.preferences_pb"/>
|
||||
<exclude domain="database" path="deepwave.db"/>
|
||||
</device-transfer>
|
||||
</data-extraction-rules>
|
||||
Reference in New Issue
Block a user