Vasu Nori [Sun, 16 Jan 2011 18:52:14 +0000 (10:52 -0800)]
(GB MR) bug:3351783 don't store redirectcount in db
redirectcount shouldn't be stored in the db.
say, you are downloading a large app and there are redirects
involved inthe download.
if network connectivity changes during download, then download
is paused and resumed once connectivy is back on.
when the download is resumed, it should start with redirectcount of 0
instead of redirectcount from the previous download session.
Kenny Root [Wed, 1 Dec 2010 19:38:41 +0000 (11:38 -0800)]
Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS
Old platform behavior of DownloadProvider would allow anyone with
special access to access all the downloads. New behavior is to return
/my_downloads/ on an .insert() call. For things that aren't using the
new API where DownloadInfo.getAllDownloadsUri() is accessible, make any
application with ACCESS_ALL_DOWNLOADS permission bypass the calling UID
check for /my_downloads/
Kenny Root [Wed, 1 Dec 2010 19:38:41 +0000 (11:38 -0800)]
Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS
Old platform behavior of DownloadProvider would allow anyone with
special access to access all the downloads. New behavior is to return
/my_downloads/ on an .insert() call. For things that aren't using the
new API where DownloadInfo.getAllDownloadsUri() is accessible, make any
application with ACCESS_ALL_DOWNLOADS permission bypass the calling UID
check for /my_downloads/
Vasu Nori [Fri, 3 Dec 2010 19:35:04 +0000 (11:35 -0800)]
(GB/GBMR) (do not merge) delete file from disk when deleting from db
bug:3175143
sometimes mediaprovider doesn't delete the file from disk when
it is deleted from its db. for example, audio files, pdf files.
DownloadManager/DownloadApp should delete the file when it is
deleted from downloads db.
DO NOT MERGE
this is esentially porting HC fix from DownloadService.java to GB
Vasu Nori [Thu, 2 Dec 2010 02:23:09 +0000 (18:23 -0800)]
(GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC
Real fix is in Change-Id: Ifea1544737023008eff44aef9acd976902a0c143
In the database, sometimes _data column in downloads is set to null
and sometimes to empty string. this is inconsistent
and causes bugs such as bug:3144642.
This bug is caused by line# 793 in DownloadThread.
state.mFileName is null sometimes and empty string sometimes - because
the correspodning field is set inconsistentlt in downloads.db
_data column.
in GB MR, apply a bandaid because real fix could be too risky for
GB.
Kenny Root [Wed, 1 Dec 2010 19:38:41 +0000 (11:38 -0800)]
Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS
Old platform behavior of DownloadProvider would allow anyone with
special access to access all the downloads. New behavior is to return
/my_downloads/ on an .insert() call. For things that aren't using the
new API where DownloadInfo.getAllDownloadsUri() is accessible, make any
application with ACCESS_ALL_DOWNLOADS permission bypass the calling UID
check for /my_downloads/
Vasu Nori [Fri, 15 Oct 2010 05:57:46 +0000 (22:57 -0700)]
bug:3099994 NPE in DownloadManager when deleting non-media file
DownloadService always scans files and assumes MediaProvider
returns a valid Uri. But MediaProvider returns null for
return param 'uri'
if the file is not audio/video/image etc media type file
(for example, pdf)
Vasu Nori [Wed, 13 Oct 2010 06:27:49 +0000 (23:27 -0700)]
bug:3069735 in Download UI app, handle deletes correctly
gingerbread.
High-level details
1. When a file is downloaded by DownloadManager, metadata about the file
is stored in 2 databases: DownloadProvider and MediaProvider.
2. So, when it is to be deleted, its metadata needs to be cleaned up from
both the databases.
3. But the 2 databases use differnt content-uri's as "primary keys" and
DownloadProvider loses the "primary-key" of the row in MediaProvider
database.
4. Easiest thing would have been to have DownloadProvider give filepath
to MediaProvider and let MediaProvider linearly scan its database
to locate the row and delete it.
5. The other - faster but more coding for now - option is to have
DownloadProvider store the "primary-key" of the MediaProvider's
row. implemented in this CL.
Low-level details
1. add 2 new columns to downloads table in downloads.db:
mediaprovider_uri = downloaded file's content_uri in mediaprovider db
this column is null for downloads that finished before this column is
added to the database.
deleted = flag is set to true if a file is to be deleted
2. download UI app shows only those files whose 'deleted' flag is not set.
3. when the user deletes downloads from download UI app,
3.1. if mediaprovider_uri is NOT null, then the row is deleted from
downloads table AND from the mediaprovider database.
3.2 if mediaprovider_uri is NULL, then its row in downloads database
is marked 'tp be deleted' by setting 'deleted' column to '1'.
4. When DownloadService (in DownloadProvider) processes all rows from
downloads table, if it sees any rows wth 'deleted' = 1, then
it uses MediaScanner Service to re-scan the file,
get the mediaprovider_uri from MediaProvider
and update the row in downloads table with this mediaprovider_uri value
and then delete the row by doing the following
1. delete it from MediaProvider database using mediaprovider_uri
2. delete it from DownloadProvider database
Problem with this solution:
There is a small window where it is deleted by the user on the Download app
(and the row disappears from the display) but it is still present in
Gallery app.
Thats due to the following asynchronous operations
1. DownladService which processes rows-to-be-deleted is not always up
2. DownloadService uses asynchronous call to have the file re-scanned
by MediaScanner to get mediaprovider_uri
Steve Howard [Fri, 8 Oct 2010 01:16:15 +0000 (18:16 -0700)]
Make DownloadProvider use parameterized queries.
This avoids filling up the query cache unnecessary, but required some
structural changes to ease the passing around of a selection along
with its arguments.
Steve Howard [Fri, 1 Oct 2010 01:18:51 +0000 (18:18 -0700)]
Seriously improve error reporting in DownloadThread.
My old error reporting strategy for DownloadThread was to log the
stack trace for the exception, so we'd know exactly what conditions
caused the StopRequest. hackbod suggested that we shouldn't log
tracebacks as they clutter the log. Instead, we should just always
include a little string tag explaining why the request is being
stopped -- this is more concise and more useful to developers.
There are three main changes here to acheive this goal:
* make StopRequest require a short, log-friendly error message upon
construction, and add such a message to all construction sites
* make a similar change to GenerateSaveFileError, so that the variety
of errors that originate with Helpers.generateSaveFile() get
similarly fine-grained and concise error reporting
* make network usable checking code return a distinct error code for
each distinct negative condition, and add a utility to return a
log-friendly error message for each such code.
Finally, I cleaned up some of the ways errors/exceptions are handled
in the process.
Steve Howard [Thu, 30 Sep 2010 22:12:58 +0000 (15:12 -0700)]
Make downloads UI singleTop.
Browser downloads, when clicked, will launch the downloads UI. When
clicked from the downloads UI (as opposed to a notification), we don't
want to launch a second copy of the downloads UI activity.
Steve Howard [Thu, 30 Sep 2010 18:39:40 +0000 (11:39 -0700)]
Handle null local URI when deleting a download.
I'd written this to assume a non-null local URI, but I forgot the
legacy downloads can still have null local URI, so this handling needs
to remain until the legacy API is dead and gone.
Steve Howard [Wed, 29 Sep 2010 23:48:01 +0000 (16:48 -0700)]
Improve how the download manager reports paused statuses.
This change makes the download manager report more detail when a
download is paused. Rather than always reporting status
RUNNING_PAUSED, there are now four different statuses:
* paused by the app
* waiting to retry after a network error
* waiting for network connectivity
* queued for wifi due to size limits
This allows a few improvements:
* code deciding when to run a download can be improved and cleaned up
(I've taken some extra steps in cleaning up this particular code)
* notification code no longer has to rely on the in-memory-only
"mPausedReason" member of DownloadInfo; instead, it knows from the
status that the download is queued for wifi, and can display the
appropriate string. This moves the string fetching out into the
UI-specific logic and is a sign that this is really the right way
to do things.
And finally, the real motivation for this change: I've changed the
meaning of "Queued" in the downloads UI so it now means "Queued for
WiFi'. This is what was originally intended, I'd misunderstood. What
was formerly known as "Queued", a download that hadn't started, is now
displayed as "In progress" (it's always a transient state so it's
basically meaningless anyway). Otherwise it remains the same (in
particular, downloads paused for other reasons are still reported as
"In progress").
I've also increased some of the logging in DownloadThread a bit, as
this change initally introduced some bugs that were impossible to
track down without that logging. There have been other bug reports
that were impossible to diagnose and these few extra log statements
should really help, without cluttering logs too much. I've taken care
to avoid potentially introducing any PII into the logs.
* 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
Steve Howard [Thu, 23 Sep 2010 02:51:59 +0000 (19:51 -0700)]
DB migration to eliminate some null fields in old downloads
The DownloadProvider now ensures that current bytes, total bytes,
title and description are never null in the DB. Some new code relies
on this assumption for simplicity. That means we need to ensure this
invariant is true for pre-existing downloads as well.
Steve Howard [Fri, 17 Sep 2010 23:45:58 +0000 (16:45 -0700)]
Implement dialogs for wifi required + recommended limits.
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.
Steve Howard [Fri, 17 Sep 2010 00:03:39 +0000 (17:03 -0700)]
Display time for today's downloads, delete files on external
* in downloads UI, for downloads that occurred today, display the time
of day rather than the date
* when deleting a download on external from the downloads UI,
explicitly delete the underlying file as well (the service only
deletes cache files when deleting a download from the database, it
intentionally leaves external files around)
Steve Howard [Thu, 16 Sep 2010 19:04:17 +0000 (12:04 -0700)]
Improve file error reporting + new detailed error messages in UI
* support new error code for "destination file already exists"
* improve error handling for various file error cases to return a more
specific error code when appropriate
* make UI support more detailed error messages for some cases
* use Uri.getPath() instead of Uri.getSchemeSpecificPart() for file
URIs