androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.6k stars 377 forks source link

Is DownloadManager respecting the WorkManager network? #1188

Open yschimke opened 6 months ago

yschimke commented 6 months ago

A general question, not blocking just trying to understand the guarantees.

I'm looking at how to ensure we use the right network for downloads.

The WorkManagerScheduler code https://github.com/androidx/media/blob/d13a0f4ec62ca092b79746a5725b62a3244cc5b4/libraries/exoplayer_workmanager/src/main/java/androidx/media3/exoplayer/workmanager/WorkManagerScheduler.java#L39 sets network requirements.

But WorkerParameters has [getNetwork](https://developer.android.com/reference/androidx/work/WorkerParameters#getNetwork()), which identifies the network matching those requirements.

It doesn't seem like this gets to CronetDataSource or other DataSource in order to ensure the right network is used.

If Wifi is requested and available for downloads, but there is an existing pooled connection (say over BT on Wear), where is this handled?

Side question: Can these constraints be applied for streaming to avoid LTE traffic? Is there a good pattern?

yschimke commented 6 months ago

For HttpClient or Cronet - should it be calling bindToNetwork on the engine or the UrlRequest?

https://cs.android.com/android/platform/superproject/main/+/main:external/cronet/android/java/src/android/net/http/UrlRequest.java;l=151