Skip to content

feat: let other apps read the progress of downloads - #130

Open
Anderinfera wants to merge 1 commit into
InfinityLoop1308:devfrom
Anderinfera:feat/download-progress-provider
Open

Anderinfera wants to merge 1 commit into
InfinityLoop1308:devfrom
Anderinfera:feat/download-progress-provider

Conversation

@Anderinfera

Copy link
Copy Markdown

Other apps (a gallery, a file manager) only see a growing file while PipePipe downloads. They can't tell whether the download is still running, paused, failed or finished, or how big it will be.

This adds a read-only content provider, content://<applicationId>.downloadprogress/missions. It has one row per download with the columns id, name, relativePath, uri, bytes, total and state (QUEUED, RUNNING, PAUSED, POSTPROCESSING, ERROR or FINISHED). bytes and total are -1 unless the download is running. Finished downloads stay listed for one minute.

  • Reading needs the new <applicationId>.permission.READ_DOWNLOAD_PROGRESS permission. It is a dangerous permission, so the user grants it to each app. Debug builds get their own permission name, so they can be installed next to a release build.
  • Readers are notified as soon as a download changes state, and at most every 500 ms about progress while a download runs.
  • Reading never starts, changes or deletes a download. Insert, update and delete are refused.
  • While a download runs, the download service rebuilds a small in-memory list every 500 ms and notifies readers only when it changed. Nothing else runs when no download is active.

Validation:

  • ./gradlew assembleDebug builds against PipePipeExtractor e9818f8e.

A read-only content provider lists each download with its name, location,
state, downloaded bytes and total size. A gallery or a file manager can show
the real state of a download instead of guessing it from the size of the
file.

Reading needs the new READ_DOWNLOAD_PROGRESS permission, which the user
grants to each app. Readers are notified at once when a download changes
state and at most every 500 ms about its progress. Reading never starts or
changes a download.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant