summaryrefslogtreecommitdiffstats
path: root/src/com
Commit message (Collapse)AuthorAgeFilesLines
* Make DownloadProvider accessible for public API usage.Steve Howard2010-07-222-47/+125
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* Public API support for broadcasts and connectivity control.Steve Howard2010-07-216-23/+158
| | | | | | | | | | | | | | | | * 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
* Major refactoring of DownloadThread.run().Steve Howard2010-07-204-609/+733
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix bug with deciding when to restart a download.Steve Howard2010-07-202-21/+23
| | | | | | | | | | | | | | In previous refactoring I had combined the code for starting a download (from DownloadService.insertDownload()) and restarting a download (from DownloadService.updateDownload()). I'd missed the fact that the former checks DownloadInfo.isReadyToStart() while the latter checks DownloadInfo.isReadyToRestart(). This cause a race condition where multiple startService() calls during a download would cause the service to try to spawn a second thread for the same running download. I've fixed the bug and added a test case to exercise this. Change-Id: Ia968331a030137daac7c8b5792a01e3e19065b38
* Support for max download size that may go over mobileSteve Howard2010-07-196-119/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces support for a maximum download size that may go over a mobile connection. Downloads above this limit will wait for a wifi connection. To accomplish this, I moved a lot of the logic for checking connectivity info into DownloadInfo itself. I then moved the code to call these checks from DownloadService, where it would call the checks before spawning a DownloadThread, into DownloadThread itself. This makes it simpler to check connectivity after we get Content-Length info. It also eliminates the risk of a race condition where connectivity changes between the check and the actual request execution. I realize this change reduces efficiency, because we now call into ConnectivityManager/TelephonyManager twice per DownloadThread, rather than once per DownloadService "tick". I feel that it's OK since its a small amount of computation running relatively infrequently. If we feel that it's a serious concern, and that the efficiency issues outweigh the race problem, I can go easily back to the old approach. I've left out the code to actually fetch the limit. I think this will come from system settings, but I want to double-check, so I'll put it in a separate change. Other changes: * simplify SystemFacade's interface to get connectivity info - rather than returning all connected types, just return the active type, since that should be all we care about * adding @LargeTest to PublicApiFunctionalTest Change-Id: Id1faa2c45bf2dade9fe779440721a1d42cbdfcd1
* Introduce a seam to ConnectivityManager and TelephonyManagerSteve Howard2010-07-157-64/+99
| | | | | | | | | 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
* Merge "Support for custom HTTP headers on download requests" into gingerbreadSteve Howard2010-07-154-175/+273
|\
| * Support for custom HTTP headers on download requestsSteve Howard2010-07-154-175/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Cleanup whitespace in DownloadNotificationSteve Howard2010-07-151-24/+24
|/ | | | Change-Id: I598ece9690649573d44d3089e473612e25f2974b
* Support for file URI destinations + last modified timestampSteve Howard2010-07-142-55/+114
| | | | | | | | | | | | | 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
* Improve error message when SQL parser gets illegal characterSteve Howard2010-07-131-1/+1
| | | | Change-Id: Ife165361ebd75d558b311710e62abdfbdc355f1b
* Stub out the system clock in the download manager, add testsSteve Howard2010-07-014-15/+38
| | | | | | | | | | | | | | Introduce SystemFacade, an interface that allows us to stub out the system clock for testing the download manager. This allows us to test retrying a failed download without having the test wait 60 seconds. This interface can include other dependencies in the future as well. I've also used this to add tests for 503 (retry-after) and 301 (redirect), and I've added a test for download to the cache partition. Other changes: * made MockWebServer capable of checking + rethrowing exceptions from child threads * refactoring + cleanup of DownloadManagerFunctionalTest
* merge from open-source masterThe Android Open Source Project2010-05-101-1/+13
|\ | | | | | | Change-Id: If84d4054324db6d10fd0cdbd2169c039c6675726
| * code left opened files behindusul2010-05-101-1/+13
| | | | | | | | | | | | | | verified with lsof DownloadProvider after downloading a file shows: ${proc} 338 10034 33w REG 179,0 167634 5 /sdcard/download/fw4-1.pdf Change-Id: I8e2412fe9a6348f5ece6f5ca3a9ebf99a4474bce
| * Show correct date for downloads in the statusbarPer Edelberg2010-02-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The date was not set properly in notifications when the text for expanded view was created. This fix sets the displayed time to the download time for each individual file. The DownloadProvider recreates the notifications several times but don't set the time before the expanded message is created. The expanded message will therefore display the time the notification was created and not the time a file was downloaded. The displayed time will in most case be the time when the last file was downloaded. This fix sets the displayed time to the downloaded time for each individual file.
| * eclair snapshotJean-Baptiste Queru2009-11-129-472/+564
| |
* | Update to reflect android-common no longer in framework.Dianne Hackborn2010-02-241-1/+1
| |
* | Supply a Context to AndroidHttpClient.newInstance(), to enableDan Egnor2010-02-101-1/+1
| | | | | | | | persistent SSL session caching.
* | Create a new permission that allows apps to see downloads from otherLeon Scroggins2010-02-052-29/+41
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | b/2383073 Use new fine-grained download status codes.Attila Bodis2010-01-261-29/+36
| | | | | | | | | | Takes advantage of two new download status codes (STATUS_DEVICE_NOT_FOUND_ERROR and STATUS_INSUFFICIENT_SPACE_ERROR) when reporting failed download attempts.
* | Revert "Download files even if there is no activity to launch them."Leon Scroggins2010-01-223-11/+68
| | | | | | | | | | | | | | This reverts commit 0f1aae327a9e4c68044d767e9bafbac747b6d985. I misunderstood the bug. We do not want to be able to download files for which there is currently no Activity to launch them.
* | Update the title of the download based on the filename.Leon Scroggins2010-01-211-6/+20
| | | | | | | | | | | | | | | | Now that the downloads page is not necessarily opened when a download starts, we need to provide a name even if the downloads page isn't shown. So when we create a notification, provide the title. Depends on a change to frameworks/base
* | Download files even if there is no activity to launch them.Leon Scroggins2010-01-213-68/+11
| | | | | | | | Fixes http://b/issue?id=2367247
* | Use the private legacy APIJean-Baptiste Queru2010-01-147-317/+333
| | | | | | | | | | | | | | | | | | | | 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
* | Changed class paths for classes moved in unbundling effortPaul Westbrook2009-12-141-1/+2
| |
* | Fix Download application notification timestamp not correct issueLixin Yue2009-11-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Should set the value of Notification.when before calling setLatestEventInfo(). On downloading an image without exif information, the received file's timestamp is correct for main database field but incorrect for temporary display field. Root cause is that if Notification.when not set before calling setLatestEventInfo(), the timestamp value in milliseconds unit will be directly set to a field as second unit. Thus database will record the time as 1000 times forward as 2067, etc. However from UI the file's time will be just shown like "10/10/67", misleading people to think time is set backwards before system time 0(1969).
* | Disable unnecessary loggingJean-Baptiste Queru2009-09-241-3/+3
| | | | | | | | BUG=2134410
* | Re-use the same random value to compute a download's restart time.Jean-Baptiste Queru2009-09-241-1/+4
| | | | | | | | | | | | | | | | | | The restart time is used multiple times during the same pass, and it needs to be consistent across calls. Otherwise, it's possible for a download to not be restarted immediately and to not be scheduled for a future restart. BUG=2055624
* | Remove unnecessary loggingJean-Baptiste Queru2009-09-243-58/+3
| | | | | | | | | | | | | | Also tweak some slightly inaccurate logging, and add a note about a potential bug. BUG=2055624
* | Log the service being launchedJean-Baptiste Queru2009-09-221-0/+14
| | | | | | | | BUG=2055624
* | Add a bit more logging to track down network state issues.Jean-Baptiste Queru2009-09-223-11/+51
| | | | | | | | BUG=2055624
* | Add logging to track connectivity as seen from the Download Manager.Jean-Baptiste Queru2009-09-213-0/+41
| | | | | | | | | | | | | | This is enabled by a separate build-time constant, so that it can be turned on for everyone without having to use a system property. BUG=2055624
* | am d3403254: Enable full logging (for easier debugging)Jean-Baptiste Queru2009-07-141-1/+1
|\| | | | | | | | | | | | | Merge commit 'd3403254c3a290b6a68804c36c6876cb3787ec15' * commit 'd3403254c3a290b6a68804c36c6876cb3787ec15': Enable full logging (for easier debugging)
| * Enable full logging (for easier debugging)Jean-Baptiste Queru2009-07-141-1/+1
| | | | | | | | See http://b/1973844
* | Merge commit 'f0fa1cdc' into manualmergeJean-Baptiste Queru2009-07-062-2/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-022-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Automated import from //branches/donutburger/...@140733,140733Feng Qian2009-03-241-1/+1
| |
* | Merge commit 'korg/cupcake'The Android Open Source Project2009-03-271-6/+23
|\ \ | | | | | | | | | | | | Conflicts: src/com/android/providers/downloads/DownloadThread.java
| * | auto import from //branches/cupcake_rel/...@141571The Android Open Source Project2009-03-191-1/+1
| |/
| * auto import from //branches/cupcake_rel/...@140373The Android Open Source Project2009-03-181-7/+24
| |
* | Merge commit 'remotes/korg/cupcake' into mergeJean-Baptiste Queru2009-03-171-2/+2
|\| | | | | | | | | | | | | Conflicts: docs/index.html src/com/android/providers/downloads/DownloadProvider.java src/com/android/providers/downloads/DownloadService.java
| * auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-039-0/+3969
| |
| * auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-039-3969/+0
| |
| * auto import from //branches/cupcake/...@132276The Android Open Source Project2009-02-192-5/+4
| |
| * 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
| |
* | Optimize call to queryIntentActivities()Jean-Baptiste Queru2009-02-271-4/+2
| | | | | | | | | | | | | | | | Replace a call to queryIntentActivities() with a calls to resolveActivity(). This is done since the only purpose of the call is to check if the returned list is empty or non-empty. It's inefficient to move an entire list across the process boundary, only to discard it.
* | 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).