fix: Respect the data warning when caching the entire playing episode - #5567
Conversation
CacheWorker.startCachingEntireEpisode hardcoded NetworkType.CONNECTED, so full-episode background caching ran over metered connections even with Warn before using data enabled. Pass the constraint from ExoPlayerDataSourceFactory using the same rule as buildPrefetchRequest (UNMETERED when warnOnMeteredNetwork is on). PCDROID-442
|
Claude finished @joashrajin's task in 1m 18s —— View job Code ReviewI reviewed the diff against Verdict: LGTM. The fix is correct, well-scoped, and faithfully mirrors the established Correctness ✅
Suggestions (non-blocking)
TestingAgreed that a device-level check of the metered/deferred path and the 416-reset re-cache (both flagged as manual TODOs in the description) is the right validation here given the WorkManager plumbing nature of the change. Nice, targeted fix — the reasoning in the description about auto-advance re-enqueuing an unconstrained job is convincing and matches what the code does. |
|
Claude finished @joashrajin's task in 1m 19s —— View job Code Review
The change is correct, minimal, and well-reasoned. It closes a real gap: Verification
Minor suggestions (non-blocking)
On testingAgree with the PR note that there's no existing harness for Verdict: Looks good to merge. The two suggestions are optional polish; the fix itself is sound and behavior-preserving on WiFi. Note the two manual verification TODOs in the description (metered-data deferral + 416 re-cache path) are still worth completing before release since there's no automated coverage. |
Dedupes the warnOnMeteredNetwork -> NetworkType mapping between buildPrefetchRequest and the entire-episode cache path, per PR review suggestion, and adds a direct unit test for the helper.
832a7eb to
5138504
Compare
…-ignoring-wifi-only-setting-when-manipulating-up # Conflicts: # CHANGELOG.md
|
Claude finished @joashrajin's task in 54s —— View job Code Review — updated diff
This synchronize pushed the follow-up that both prior reviews asked for: the What changed since the last review
Correctness ✅
Non-blocking notes (unchanged from before)
Nice, clean follow-up — the extraction landed exactly where it should and the test locks the policy in. |
…-ignoring-wifi-only-setting-when-manipulating-up # Conflicts: # CHANGELOG.md
|
Claude finished @sztomek's task in 47s —— View job Code Review — latest sync (
|
Description
When a non-downloaded episode starts playing (and
cacheEntirePlayingEpisodeis enabled — its Firebase Remote Config default istrue),ExoPlayerDataSourceFactoryenqueuesCacheWorker.startCachingEntireEpisode, which downloads the entire episode in the background withNetworkType.CONNECTEDhardcoded. On a metered connection this transfers the full episode (hundreds of MB for long shows) over mobile data regardless of the user's Warn before using data setting — and the 416-error recovery path (SimplePlayer.onPlayerError→resetEpisodeCaching) wipes the cache and downloads the whole episode again, multiplying usage. The playback path itself does not write to the cache (setCacheWriteDataSinkFactory(null)), so this is an additional transfer on top of what the user actually streams.buildPrefetchRequestalready handles this correctly by pickingUNMETEREDwhenwarnOnMeteredNetworkis on;CacheWorkernever got the same treatment.Changes:
CacheWorker.startCachingEntireEpisodenow takes anetworkConstraint: NetworkTypeparameter (mirroringPrefetchWorker.prefetchNextEpisode) instead of hardcodingNetworkType.CONNECTED.ExoPlayerDataSourceFactory.startCachingEntireEpisodeIfNeededpassesUNMETEREDwhensettings.warnOnMeteredNetwork.valueis true, elseCONNECTED— the same rule asbuildPrefetchRequest. TheresetEpisodeCachingpath inherits the fix via the shared helper.Net behavior: on WiFi nothing changes; on metered networks the full-episode cache job waits for an unmetered network instead of silently consuming mobile data. Streaming playback is unaffected (the stream is a separate data path).
Addresses PCDROID-442 — likely explains the reports where affected users (ZD 11401496, 11307725, 11383273) never manually manipulate Up Next: any episode change during playback (including auto-advance) creates a new media source and enqueues a full-episode
CacheWorkerjob with the unconstrained network type. Not using aFixeskeyword because theDownloadEpisodeWorker(UserTriggered(waitForWifi = false)) angle in the original report may be a separate contributor and needs its own verification.Testing Instructions
Preconditions: Settings → Storage & data use → Warn before using data = ON, episode caching enabled (Settings → Advanced → cache entire playing episode), a podcast with non-downloaded episodes.
adb shell dumpsys jobscheduler | grep -A5 pocket_casts_cache_worker(or WorkManager inspection) shows the job constrained toUNMETEREDand deferredScreenshots or Screencast
Checklist
./gradlew spotlessApplyto automatically apply formatting/linting) (ranspotlessCheck— passed)CacheWorker/ExoPlayerDataSourceFactoryhave no existing test harness and the change is WorkManager constraint plumbing; covered by the manual steps above — same situation as fix: Halt playback for the data warning and respect it on stream retry #5533)modules/services/localization/src/main/res/values/strings.xml— n/a, no new stringsI have tested any UI changes...
n/a — no UI changes