summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadProvider.java
Commit message (Collapse)AuthorAgeFilesLines
...
* | resolved conflicts for merge of 2f3c8c7e to masterSteve Howard2010-08-181-2/+10
|\| | | | | | | Change-Id: Idcaa37fc828bfae41a150f2cce7b55fa152987be
| * Fix and test handling of null/empty download fields.Steve Howard2010-08-181-2/+10
| | | | | | | | | | | | | | Minor change to make title/description default to blank stings, and add test case covering all null/empty download fields. Change-Id: Id44344bc2e464f46589faed49c8f383a45a8d329
* | am e80c3555: am e61798da: Extend PublicApiAccessTest to exercise ↵Steve Howard2010-08-161-0/+8
|\| | | | | | | | | | | | | | | | | DownloadManager. Merge commit 'e80c35557bd72489323303af9d93c2c33c88cce9' * commit 'e80c35557bd72489323303af9d93c2c33c88cce9': Extend PublicApiAccessTest to exercise DownloadManager.
| * Extend PublicApiAccessTest to exercise DownloadManager.Steve Howard2010-08-161-0/+8
| | | | | | | | | | | | | | | | | | This change adds a new test case to PublicApiAccessTest to enqueue a request through DownloadManager, ensuring that the values constructed by DownloadManager fit within the allowed bounds. It also fixes a bug with allowing http header values exposed by the new test. Change-Id: I94fec57d7a41298ac42ddaab338516e6a60c4e75
* | am 1d332ceb: am da5a4183: Merge "Make all public API downloads visible." ↵Steve Howard2010-08-061-2/+9
|\| | | | | | | | | | | | | | | | | into gingerbread Merge commit '1d332ceb5756ef2e09ae97f1735aa9b529063874' * commit '1d332ceb5756ef2e09ae97f1735aa9b529063874': Make all public API downloads visible.
| * Make all public API downloads visible.Steve Howard2010-07-281-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | am 0a450da1: am 71aab521: Support for non-purgeable downloads through the ↵Steve Howard2010-07-261-5/+16
|\| | | | | | | | | | | | | | | | | public API. Merge commit '0a450da1d9e95f27f479aa45b442960baac49bb1' * commit '0a450da1d9e95f27f479aa45b442960baac49bb1': Support for non-purgeable downloads through the public API.
| * Support for non-purgeable downloads through the public API.Steve Howard2010-07-231-5/+16
| | | | | | | | | | | | | | | | | | | | | | 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
* | am 8667ebd1: am b06b739b: Make DownloadProvider accessible for public API usage.Steve Howard2010-07-261-40/+124
|\| | | | | | | | | | | | | Merge commit '8667ebd109ea212a7645ad6c214d4d765bb70b75' * commit '8667ebd109ea212a7645ad6c214d4d765bb70b75': Make DownloadProvider accessible for public API usage.
| * Make DownloadProvider accessible for public API usage.Steve Howard2010-07-221-40/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | am c2448d48: am 0d8d8910: Make COLUMN_URI readable and tighten UID restrictions.Steve Howard2010-07-221-34/+15
|\| | | | | | | | | | | | | Merge commit 'c2448d488ff4e476762d0a07bb0757ca99c05445' * commit 'c2448d488ff4e476762d0a07bb0757ca99c05445': Make COLUMN_URI readable and tighten UID restrictions.
| * Make COLUMN_URI readable and tighten UID restrictions.Steve Howard2010-07-211-34/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | am 0bd0e0c9: am 0a77c62a: Public API support for broadcasts and connectivity ↵Steve Howard2010-07-211-6/+38
|\| | | | | | | | | | | | | | | | | control. Merge commit '0bd0e0c9e4eec9d63b4e0f213e80fc9eee85fdf6' * commit '0bd0e0c9e4eec9d63b4e0f213e80fc9eee85fdf6': Public API support for broadcasts and connectivity control.
| * Public API support for broadcasts and connectivity control.Steve Howard2010-07-211-6/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Three new DB fields, one indicating whether a download was initiated by the public API or not, two to hold connectivity control info. DB migration to add these fields and code in DownloadProvider.insert() to handle them. * Change broadcast intent code to match public API spec, for public API downloads only. (Legacy code can go away once existing clients are converted over to the new API.) * Introduce SystemFacade methods for sending broadcasts and checking package ownership; this facilitates new tests of broadcast code. * Change DownloadInfo.canUseNetwork() to obey new connectivity controls available in public API, but again, retain legacy behavior for downloads initiated directly through DownloadProvider * New test cases to cover the new behavior Also made a couple changes to reduce some test flakiness I was observing: * in tearDown(), wait for any running UpdateThread to complete * in PublicApiFunctionalTest.setUp(), if the test directory already exists, remove it rather than aborting DB changes for broadcast + roaming support Change-Id: I60f39fc133f678f3510880ea6eb9f639358914b4
* | am 918f819a: resolved conflicts for merge of b5629da7 to gingerbread-plus-aospSteve Howard2010-07-211-0/+1
|\| | | | | | | | | | | | | Merge commit '918f819abfb1da3661c1c604440666655e0c8909' * commit '918f819abfb1da3661c1c604440666655e0c8909': Major refactoring of DownloadThread.run().
| * Major refactoring of DownloadThread.run().Steve Howard2010-07-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: I need to fix the handling of 302s, so that after a disconnect, subsequent retries will use the original URI, not the redirected one. Rather than store extra information in the DB, I'd like to just keep the redirected URI in memory and make the redirected request within the same DownloadThread. This involves working with the large-scale structure of DownloadThread.run(). Since run() was a ~700 line method, I didn't feel comfortable making such changes. So this change refactors run() into a ~80 line method which calls into a collection of ~20 other short methods. The state previously kept in local variables has been pulled into a couple of state-only inner classes. The error-handling control flow, formerly handled by "break http_request_loop" statements, is now handled by throwing a "StopRequest" exception. The remaining structure of run() has been simplified -- the outermost for loop, for example, could never actually repeat and has been removed for now. Some other bits of code have been cleaned up a bit, but the functionality has not been modified. There are many good next steps to this refactoring. Besides various other cleanup bits, a major improvement would be to consolidate the State/InnerState classes, move some functionality to this new class (there are many functions of the form "void foo(State)" which would be good candidates), and promote it to a top-level class. But I want to take things one step at a time, and I think what I've got here is a major improvement and should be enough to allow me to safely implement the changes to redirection handling. In the process of doing this refactoring I added many test cases to PublicApiFunctionalTest to exercise some of the pieces of code I was moving around. I also moved some test cases from DownloadManagerFunctionalTest. Over time I'd like to move everything over to use the PublicApiFunctionalTest approach, and then I may break that into some smaller suites. Other minor changes: * use longs instead of ints to track file sizes, as these may be getting quite large in the future * provide a default DB value of -1 for COLUMN_TOTAL_BYTES, as this simplifies some logic in DownloadThread * small extensions to MockResponse to faciliate new test cases Change-Id: If7862349296ad79ff6cdc97e554ad14c01ce1f49
* | am c45c8eb1: am 1aa26989: Merge "Introduce a seam to ConnectivityManager and ↵Steve Howard2010-07-191-1/+1
|\| | | | | | | | | | | | | | | | | TelephonyManager" into gingerbread Merge commit 'c45c8eb1f9e8d93a02a7af2621a8fbcea1b2f6a7' * commit 'c45c8eb1f9e8d93a02a7af2621a8fbcea1b2f6a7': Introduce a seam to ConnectivityManager and TelephonyManager
| * Introduce a seam to ConnectivityManager and TelephonyManagerSteve Howard2010-07-151-1/+1
| | | | | | | | | | | | | | | | | | This change abstracts access to ConnectivityManager and TelephonyManager behind methods on SystemFacade, moving the code from Helpers into RealSystemFacade and adding fake implementations to FakeSystemFacade. This facilitates new connectivity tests. Change-Id: Id6c6b861e1d4ca45b3c1572bfb8ae0aa26af756b
* | Fix build - remove reference to ReadOnlyCursorWrapperSteve Howard2010-07-151-3/+2
| | | | | | | | Change-Id: I099c98e310039886990502d63566f3e217738b45
* | am d1bec343: am 88ea0b39: Merge "Support for custom HTTP headers on download ↵Steve Howard2010-07-151-95/+180
|\| | | | | | | | | | | | | | | | | requests" into gingerbread Merge commit 'd1bec343dcbbc555837790119449ff7eea7c5312' * commit 'd1bec343dcbbc555837790119449ff7eea7c5312': Support for custom HTTP headers on download requests
| * Support for custom HTTP headers on download requestsSteve Howard2010-07-151-95/+180
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provider changes: * new many-to-one DB table holding headers for each download. since there was no real migration logic in DownloadProvider, I implemented some. * DownloadProvider.insert() reads request headers out of the ContentValues and puts them into the new table * DownloadProvider.query() supports a new URI form, download/#/headers, to fetch the headers associated with a download * DownloadProvider.delete() removes request headers from this table Service changes: * made DownloadInfo store request headers upon initialization. While I was at it, I refactored the initialization logic into DownloadInfo to get rid of the massive 24-parameter constructor. The right next step would be to move the update logic into DownloadInfo and merge it with the initialization logic; however, I realized that headers don't need to be updatable, and in the future, we won't need the update logic at all, so i didn't bother touching the update code. * made DownloadThread read headers from the DownloadInfo and include them in the request; merged the custom Cookie and Referer logic into this logic Also added a couple new test cases for this stuff. Change-Id: I421ce1f0a694e815f2e099795182393650fcb3ff
* | am 2c80c375: am 6d9b9828: Support for file URI destinations + last modified ↵Steve Howard2010-07-141-3/+20
|\| | | | | | | | | | | | | | | | | timestamp Merge commit '2c80c37546b89dfd31875f6f6e977e9610cdb22b' * commit '2c80c37546b89dfd31875f6f6e977e9610cdb22b': Support for file URI destinations + last modified timestamp
| * Support for file URI destinations + last modified timestampSteve Howard2010-07-141-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | File URI destinations: * permission checking in DownloadProvider * implementation in Helpers.generateSaveFile(). it's a fairly small amount of logic added here, but I did some significant method extraction to simplify this change and clean up the code in general. * added test case Last modified timestamp: * made DownloadProvider use a SystemFacade for getting system time, so I could properly test timestamps * updated test cases to cover last modified time + handle new ordering
* | Stop using private APIs that are going away.Jeff Hamilton2010-05-131-34/+0
|/ | | | Change-Id: Ic675d13e70e8e18af44d71b590f4782559966396
* Create a new permission that allows apps to see downloads from otherLeon Scroggins2010-02-051-7/+34
| | | | | | | | | | | | applications to the SD card. Necessary for http://b/issue?id=2384554 Also create names for files by default, so they do not display as <Untitled>. Remove calls to createTitleFromFilename, which are no longer necessary. Requires a change to frameworks/base.
* Grant access to downloaded packages to default container.Suchi Amalapurapu2010-01-271-3/+33
| | | | | The package name is hardcoded for now but will eventually move to a separate gid guarded by a permission.
* Use the private legacy APIJean-Baptiste Queru2010-01-141-87/+90
| | | | | | | | | | The public API is getting deeply reworked for forward compatibility, but since the Download Manager and the Browser need to continue using the old API, a separate copy is being kept on the side. Bug: 2245521 Change-Id: I85eff6ba9efc68600aa80e8dffa6720b0f2ed155
* Merge commit 'f0fa1cdc' into manualmergeJean-Baptiste Queru2009-07-061-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix crash in discardPurgeableFiles with proper selection syntax. The basic crash is that this codepath was doing a query to the download provider without properly quoting its selection arguments (which is mandated by the download provider). A secondary crash is that the DESTINATION column wasn't readable. This fixes bug 1941125. Tested by force-calling discardPurgeableFiles for each download to /cache, locally adding a few debugging statements to be sure that the codepath was getting executed, and doing a market download. Conflicts: src/com/android/providers/downloads/DownloadProvider.java src/com/android/providers/downloads/Helpers.java
| * Fix crash in discardPurgeableFiles with proper selection syntax.Jean-Baptiste Queru2009-07-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic crash is that this codepath was doing a query to the download provider without properly quoting its selection arguments (which is mandated by the download provider). A secondary crash is that the DESTINATION column wasn't readable. This fixes bug 1941125. Tested by force-calling discardPurgeableFiles for each download to /cache, locally adding a few debugging statements to be sure that the codepath was getting executed, and doing a market download.
| * auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+731
| |
| * auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-731/+0
| |
| * auto import from //branches/cupcake/...@130745The Android Open Source Project2009-02-101-8/+14
| |
* | Make the DownloadProvider work in the simulatorJean-Baptiste Queru2009-02-271-1/+2
| |
* | Refine interaction between destination and default visibility.Jean-Baptiste Queru2009-02-061-8/+14
| | | | | | | | | | | | The previous code was hard to read, and relied on the fact that one of the constants was 0 (which is also the default value when reading back uninitialized columns).
* | Use the new download manager APIs introduced in change 7400Jean-Baptiste Queru2009-01-211-70/+70
| |
* | Match the official code style guide.Jean-Baptiste Queru2009-01-201-3/+2
|/ | | | | | This fixes a number of style violations that weren't caught by automated tools and brings those files closer to compliance with the official style guide for this language.
* Code drop from //branches/cupcake/...@124589The Android Open Source Project2008-12-171-85/+278
|
* Initial ContributionThe Android Open Source Project2008-10-211-0/+532