google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.01k forks source link

Add Download Manager release and recreate support to DownloadService #10395

Open rossbeazley opened 2 years ago

rossbeazley commented 2 years ago

[REQUIRED] Use case description

Within the life of one application process we would like to release DownloadManager in order to significantly reconfigure the Download Managers databases etc to support user logout / login. It looks like by design the expectation is to only support one instance of Download Manager per application process https://github.com/google/ExoPlayer/blob/r2.18.0/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadService.java#L173-L177

Proposed solution

Permit the release of DownloadManager by the DownloadService, add a Command to the DownloadService for release eg

  public static Intent buildReleaseDownloadManager(
      Context context, Class<? extends DownloadService> clazz, boolean foreground) {
    return getIntent(context, clazz, ACTION_RELEASE_DOWNLOAD_MANAGER, foreground);
  }

Upon processing this command, clear the reference from the DownloadManagerHelpers and release the DownloadManager (it helps)

Alternatives considered

Alter DownloadManagerHelper to clear itself down if this block evaluates to false

We will in the short term use our own service copied from your code with this feature added.

marcbaechinger commented 2 years ago

Thanks Ross for the feature request!

I'm not sure when we have a chance to look into this. If you want to do a pull request in the meantime. please do! :) If possible this PR should be done in the new repo against the main branch: https://github.com/androidx/media/tree/main

rossbeazley commented 2 years ago

ah yes, sorry, do you want me to move the issue to that repo instead?

marcbaechinger commented 2 years ago

Nah, fine to have the issue here. If you do a pull request, handling it is much easier for us when you use the other repo as we internally use the new module/package structure.