1. 25 Apr, 2016 1 commit
    • Jeff Sharkey's avatar
      Move DownloadManager to use JobScheduler. · 3a5f5eaf
      Jeff Sharkey authored
      JobScheduler is in a much better position to coordinate tasks across
      the platform to optimize battery and RAM usage.  This change removes
      a bunch of manual scheduling logic by representing each download as
      a separate job with relevant scheduling constraints.  Requested
      network types, retry backoff timing, and newly added charging and
      idle constraints are plumbed through as job parameters.
      
      When a job times out, we halt the download and schedule it to resume
      later.  The majority of downloads should have ETag values to enable
      resuming like this.
      
      Remove local wakelocks, since the platform now acquires and blames
      our jobs on the requesting app.
      
      When an active download is pushing updates to the database, check for
      both paused and cancelled state to quickly halt an ongoing download.
      
      Shift DownloadNotifier to update directly based on a Cursor, since we
      no longer have the overhead of fully-parsed DownloadInfo objects.
      
      Unify a handful of worker threads into a single shared thread.
      
      Remove legacy "large download" activity that was thrown in the face
      of the user; the UX best-practice is to go through notification, and
      update that dialog to let the user override and continue if under
      the hard limit.
      
      Bug: 28098882, 26571724
      Change-Id: I33ebe59b3c2ea9c89ec526f70b1950c734abc4a7
      3a5f5eaf
  2. 27 Aug, 2015 1 commit
  3. 14 Jul, 2015 1 commit
    • Jeff Sharkey's avatar
      Relax permissions on package-specific paths. · ed30deae
      Jeff Sharkey authored
      Normally apps must hold the WRITE_EXTERNAL_STORAGE permission in
      order to use DownloadManager.  However, now that the platform has
      relaxed permissions on package-specific directories, we relax the
      DownloadManager check in a similar way.  This also opens up using
      DownloadManager to save files on secondary external storage devices.
      
      Fix bug so that we now check the relevant volume state when thinking
      about resuming a download.
      
      Bug: 22135060
      Change-Id: If439340ea48789ea167f49709b5b69a4f0883150
      ed30deae
  4. 14 Apr, 2015 1 commit
  5. 17 Jun, 2014 1 commit
  6. 11 Apr, 2014 1 commit
  7. 28 Mar, 2014 1 commit
  8. 06 Feb, 2014 3 commits
    • Jeff Sharkey's avatar
      Add idle service to clean orphan downloads. · 1f2c2c56
      Jeff Sharkey authored
      Periodically reconcile database against disk contents.  This handles
      the case where a user/app deletes files directly from disk without
      updating the database, and the rare case where a database delete
      didn't make it to deleting the underlying file.
      
      Also cleans up any downloads belonging to a UID when removed.
      
      Bug: 12924143
      Change-Id: I4899d09df7ef71f2625491ac01ceeafa8a2013ce
      1f2c2c56
    • Jeff Sharkey's avatar
      Many improvements to download storage management. · dffbb9c4
      Jeff Sharkey authored
      Change all data transfer to occur through FileDescriptors instead of
      relying on local files.  This paves the way for downloading directly
      to content:// Uris in the future.
      
      Rewrite storage management logic to preflight download when size is
      known.  If enough space is found, immediately reserve the space with
      fallocate(), advising the kernel block allocator to try giving us a
      contiguous block regions to reduce fragmentation.  When preflighting
      on internal storage or emulated external storage, ask PackageManager
      to clear private app caches to free up space.
      
      Since we fallocate() the entire file, use the database as the source
      of truth for resume locations, which requires that we fsync() before
      each database update.
      
      Store in-progress downloads in separate directories to keep the OS
      from deleting out from under us.  Clean up filename generation logic
      to break ties in this new dual-directory case.
      
      Clearer enforcement of successful download preconditions around
      content lengths and ETags.  Move all database field mutations to
      clearer DownloadInfoDelta object, and write back through single
      code path.
      
      Catch and log uncaught exceptions from DownloadThread.  Tests to
      verify new storage behaviors.  Fixed existing test to reflect correct
      RFC behavior.
      
      Bug: 5287571, 3213677, 12663412
      Change-Id: I6bb905eca7c7d1a6bc88df3db28b65d70f660221
      dffbb9c4
    • Fred Quintana's avatar
      add the WAKE_LOCK perm to the DownloadProvider · a7fa30f3
      Fred Quintana authored
      The DownloadService needs the WAKE_LOCK permission, which
      it normally gets as a side-affect of the MediaProvider
      being in the same shared UID. Since clockwork doesn't
      include the MediaProvider the uses-permission needs to
      be added to DownloadProvider.
      
      Change-Id: Ib3f58695e21e1cf7d841bc55093c26b631092b30
      a7fa30f3
  9. 03 Jan, 2014 1 commit
  10. 09 Oct, 2013 1 commit
  11. 10 Sep, 2013 1 commit
  12. 06 Sep, 2013 1 commit
    • Jeff Sharkey's avatar
      Extend trampoline to show dialogs. · 3c03d1b8
      Jeff Sharkey authored
      Handle incoming manage requests by launching finished downloads,
      or showing various retry dialogs.  Pipe through summary, show
      percentage when in progress, and always show total size and MIME type.
      
      Bug: 10531347, 10599641
      Change-Id: I3be2bc67ea3c0ef795146177200f5be77ad5114e
      3c03d1b8
  13. 29 Aug, 2013 1 commit
  14. 19 Aug, 2013 1 commit
    • Jeff Sharkey's avatar
      Trampoline APK installation to use raw file. · 90aacc86
      Jeff Sharkey authored
      PackageInstaller requires raw file:// Uris, and refuses to accept
      content:// Uris, so create a trampoline that uses the raw file and
      also splices in referrer extras.
      
      Bug: 10391254
      Change-Id: I12a06862069479de5dee140d0065479ce79eb494
      90aacc86
  15. 18 Aug, 2013 1 commit
    • Jeff Sharkey's avatar
      Support custom documents query projections. · af760c0b
      Jeff Sharkey authored
      Uses new MatrixCursor.RowBuilder.offer() to support custom
      projections.  Also query MIME types directly so they're always
      consistent.
      
      Bug: 10329983
      Change-Id: I724b26e008f6ffb85940e009a916b969ead42fcd
      af760c0b
  16. 08 Aug, 2013 1 commit
  17. 11 Apr, 2013 1 commit
  18. 06 Feb, 2013 1 commit
    • Jeff Sharkey's avatar
      Allow granting access to "my_downloads" paths. · afad5797
      Jeff Sharkey authored
      PackageInstaller attempts to grant Uri permissions on my_downloads
      paths passed internally.  This change lets the system successfully
      grant permissions to these paths.
      
      Bug: 7426851
      Change-Id: I9a4eea4397c02175aff4e3881a9a79cea1e6e0e3
      afad5797
  19. 28 Jul, 2012 1 commit
    • Nick Kralevich's avatar
      Explicitly export content providers · 6c26e6e1
      Nick Kralevich authored
      In a future version of Android, the default value for
      <provider android:exported> will change from true to false.
      Explicitly set android:exported="true"
      
      Bug: 3306452
      Change-Id: Id23f16a8527ba97be1d8617ccfc4346734f695d0
      6c26e6e1
  20. 12 Jul, 2011 1 commit
  21. 21 Jun, 2011 1 commit
  22. 17 Jun, 2011 1 commit
    • Jeff Sharkey's avatar
      Teach DownloadManager about network policy. · 96102438
      Jeff Sharkey authored
      Now network access is determined by using getActiveNetworkInfoForUid()
      which uses BLOCKED to indicate that network should be rejected for
      the requesting UID.  While download in progress, watch for any policy
      changes that should trigger pause.
      
      Also check NetworkInfo.isConnected() for correctness.
      
      Change-Id: I1efa79823f15ecc3fa088a6719da1b770c64b255
      96102438
  23. 14 May, 2011 1 commit
    • Jeff Sharkey's avatar
      Add Socket tagging for granular data accounting. · 3fb34dc3
      Jeff Sharkey authored
      Tag active downloads, and account data usage towards UID that made
      the original request.  Also release WakeLock only after we've cleaned
      up the download.
      
      Change-Id: I72d58c6a51beaeb357e59aae4d7c0f5ac9abaa8d
      3fb34dc3
  24. 09 Feb, 2011 1 commit
  25. 16 Nov, 2010 1 commit
  26. 05 Nov, 2010 1 commit
    • Vasu Nori's avatar
      changes to support CL: I1f5dd734e394db0056579a3a0c26862fee27981e · 3ca67748
      Vasu Nori authored
      1. if an application designates a downloaded file to be mediascanner
      scannable or not, store that fact in database.
      2. use the above to determine whether a file shoudl be mediascanned or not
      in DownloadService
      3. implement code to return mimetype for the new Uri "/public_downloads"
      introduced in CL: I1f5dd734e394db0056579a3a0c26862fee27981e
      
      Change-Id: I5c062ad6d1b58306044cee49ff3827e908d27fd9
      3ca67748
  27. 26 Sep, 2010 1 commit
    • Steve Howard's avatar
      UI + string tweaks for downloads UI + size limits UI · b8bb8473
      Steve Howard authored
      * tweaks to UI strings based on feedback
      * new "retry" button for single selection of failed download
      * make SizeLimitActivity translucent+titleless, so it looks like a
        dialog over the current app
      
      Change-Id: I6a990275880d23ab6b4368d39b70f0ad042825ec
      b8bb8473
  28. 21 Sep, 2010 2 commits
    • Steve Howard's avatar
      Expose permission to download without notification. · ece96c74
      Steve Howard authored
      Change-Id: I43d3b9ca4ea7d4786a47363b4f5f7e6f003013bb
      ece96c74
    • Steve Howard's avatar
      Implement dialogs for wifi required + recommended limits. · d3197296
      Steve Howard authored
      This change extends the original work to add a size limit over which
      wifi is required to download a file.
      
      First, this change adds a second size limit, over which wifi is
      recommended but not required.  The user has the option to bypass this
      limit.
      
      Second, this change implements dialogs shown to the user when either
      limit is exceeded.  These dialogs are shown by the background download
      manager service when a download is started and found to be over the
      limit (and wifi is not connected).
      
      I'm including one small fix to the unit tests needed from the previous
      change.
      
      Change-Id: Ia0f0acaa7b0d00e98355925c3446c0472048df10
      d3197296
  29. 18 Sep, 2010 1 commit
    • Steve Howard's avatar
      Temporary fix to support old URIs for Market · b31c2daa
      Steve Howard authored
      Market has its own copies of the download manager URIs.  This change
      bring back support for those so Market will keep working until they
      can properly update their code.
      
      Change-Id: I283ea65931085c0f083a182842d362c113427537
      b31c2daa
  30. 17 Sep, 2010 1 commit
    • Steve Howard's avatar
      Temporary fix to support old URIs for Market · 4bebe75b
      Steve Howard authored
      Market has its own copies of the download manager URIs.  This change
      bring back support for those so Market will keep working until they
      can properly update their code.
      
      Change-Id: I283ea65931085c0f083a182842d362c113427537
      4bebe75b
  31. 15 Sep, 2010 1 commit
    • Steve Howard's avatar
      New URI structure with "my_downloads" and "all_downloads" · 3d55d829
      Steve Howard authored
      This change introduces a second view into the download manager
      database via a set of URIs starting with /all_downloads, renaming the
      original /download URIs to /my_downloads.  In addition to making
      things more clear, this change allows the downloads UI to grant
      permissions on individual downloads to viewer apps.
      
      The old semantics were:
      
      * for ordinary callers, /download included only downloads initiated by
        the calling UID
      * for intraprocess calls or calls by root, /download included all
        downloads
      
      The new semantics are
      
      * /my_downloads always includes only downloads initiated by the
        calling UID, and requires only INTERNET permission.  It could just
        as well require no permission, but that's not possible in the
        framework, since path-permissions can only broaden access, not
        tighten it.  It doesn't matter, because these URIs are useless
        without INTERNET permission -- if a user can't initiate downloads,
        there's no reason to read this.
      * /all_downloads always includes all downloads on the system, and
        requires the new permission ACCESS_ALL_DOWNLOADS.  This permission
        is currently protectionLevel=signature -- this could be relaxed
        later to support third-party download managers.
      
      All download manager code has been changed to use /all_downloads URIs,
      except when passing a URI to another app.  In making this change
      across the download manager code, I've taken some liberties in
      cleaning things up.  Other apps are unchanged and will use
      /my_downloads.
      
      Finally, this incorporates changes to DownloadManager to return a
      content URI for /cache downloads -- the download UI no longer assumes
      it's a file URI, and it grants permissions to the receiver of the VIEW
      intent.  The public API test has also been updated.
      
      I've also fixed some null cursor checking in DownloadManager.
      
      Change-Id: I05a501eb4388249fe80c43724405657c950d7238
      3d55d829
  32. 29 Jul, 2010 1 commit
    • Steve Howard's avatar
      Make all public API downloads visible. · 9da9df3d
      Steve Howard authored
      This change makes all downloads through the public API visible by
      default.  It removes the API that had allowed applications to control
      notifications while the download runs.  This has been replaced with a
      hidden API, since such behavior is needed by SystemUpdater and Market
      (for self-updates).  Additionally, the behavior is now protected by a
      new permission.
      
      I'm making this permission signatureOrSystem, and changing the
      non-purgeable permission to the same (it should've been that, I just
      didn't know).  I'm also adding string descriptions to appease the
      translation folks.
      
      Change-Id: I192e8b19ff9b0e425257cef0db081c3d75996ea5
      9da9df3d
  33. 23 Jul, 2010 2 commits
    • Steve Howard's avatar
      Support for non-purgeable downloads through the public API. · 71aab521
      Steve Howard authored
      This change adds a permission,
      android.permission.DOWNLOAD_CACHE_NON_PURGEABLE.  When an app has this
      permission, any downloads it requests through the public API to the
      download cache will automatically become non-purgeable, i.e. they'll
      never be automatically deleted by the download manager to free up
      space.  This is intended for use only by the system updater.
      
      Change-Id: I35cdd44f7e5d46bc70443d1a9743f61a51395ddb
      71aab521
    • Steve Howard's avatar
      Make DownloadProvider accessible for public API usage. · b06b739b
      Steve Howard authored
      This change removes the requirement that apps have the
      ACCESS_DOWNLOAD_MANAGER permission in order to access
      DownloadProvider.  This enables the public API to work.  Instead,
      DownloadProvider enforces the new permissions model for the public
      API:
      * insert() requires INTERNET permission
      * insert() checks that input fits within the restricted input allowed
        for the public API
      * insert() also strictly checks the file URI provided with
        DESTINATION_FILE_URI (and still requires WRITE_EXTERNAL_STORAGE
        permission if that is supplied)
      
      Note that if an app has the ACCESS_DOWNLOAD_MANAGER permission, legacy
      behavior is retained.
      
      I've added a test to cover this new access, and updated the existing
      permissions tests.
      
      I also fixed a bug in WHERE clause construction in update() and
      delete(), and refactored the code to eliminate duplication.
      
      Change-Id: I53a08df137b35c2788c36350276c9dff24858af1
      b06b739b
  34. 22 Jul, 2010 1 commit
    • Steve Howard's avatar
      Make COLUMN_URI readable and tighten UID restrictions. · 0d8d8910
      Steve Howard authored
      I need to make COLUMN_URI readable by apps, since the public API
      exposes that field.  In order to avoid any possible security issues, I
      got rid of the feature that potentially allowed apps to view downloads
      from other UIDs.  No one was using that feature and the public API
      exposes no such feature (yet).
      
      While at it, I cleaned up some related code in update() and delete().
      
      Change-Id: I5384115d2a865255d009fbe37449488fd2269389
      0d8d8910
  35. 05 Feb, 2010 1 commit
  36. 06 Jan, 2010 1 commit