diff options
author | Steve Howard <showard@google.com> | 2010-09-15 12:29:50 -0700 |
---|---|---|
committer | Steve Howard <showard@google.com> | 2010-09-20 11:34:54 -0700 |
commit | 3398db8f3b195959faa2a7cf09918f364432ac28 (patch) | |
tree | b274d3f30d22bb3d56100cb18e3ade5a83c91b71 /src/com/android/providers/downloads/DownloadNotification.java | |
parent | 4bebe75b3e2361d7fb0aa966598c41c45ad9317f (diff) | |
download | android_packages_providers_DownloadProvider-3398db8f3b195959faa2a7cf09918f364432ac28.tar.gz android_packages_providers_DownloadProvider-3398db8f3b195959faa2a7cf09918f364432ac28.tar.bz2 android_packages_providers_DownloadProvider-3398db8f3b195959faa2a7cf09918f364432ac28.zip |
Fix notification bugs, cleanup DownloadService + DownloadReceiver
This change started out just fixing a few regressions related to
notifications:
* Browser downloads weren't picking up a title from the determined
filename. This was due to my change to default the title field to
"" instead of null.
* Notification click/hide events weren't being handled properly. This
was due to previous change to the URI structure of DownloadProvider.
DownloadReceiver needed to be changed to perform queries through
/all_downloads URIs, like all other parts of the download manager
code. I did some general refactoring of the DownloadReceiver code
while I was there.
* The code in DownloadNotification wasn't picking up some updates to
downloads properly. This was due to my change to make
DownloadNotification use the DownloadInfo objects rather than
querying the database directly, so that it could make use of info
provided by the DownloadThread that didn't go into the DB. Fixing
this didn't turn out to be all that complicated, but along the way
to figuring this out I made some substantial refactoring in
DownloadService which made it much cleaner anyway and eliminated a
lot of duplication. That's something that had to happen eventually,
so I'm leaving it all in.
Change-Id: I847ccf80e3d928c84e36bc24791b33204104e1b2
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotification.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadNotification.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java index 38def594..90c8693b 100644 --- a/src/com/android/providers/downloads/DownloadNotification.java +++ b/src/com/android/providers/downloads/DownloadNotification.java @@ -26,8 +26,8 @@ import android.provider.Downloads; import android.view.View; import android.widget.RemoteViews; +import java.util.Collection; import java.util.HashMap; -import java.util.List; /** * This class handles the updating of the Notification Manager for the @@ -104,12 +104,12 @@ class DownloadNotification { /* * Update the notification ui. */ - public void updateNotification(List<DownloadInfo> downloads) { + public void updateNotification(Collection<DownloadInfo> downloads) { updateActiveNotification(downloads); updateCompletedNotification(downloads); } - private void updateActiveNotification(List<DownloadInfo> downloads) { + private void updateActiveNotification(Collection<DownloadInfo> downloads) { // Collate the notifications mNotifications.clear(); for (DownloadInfo download : downloads) { @@ -135,7 +135,6 @@ class DownloadNotification { item.mId = (int) id; item.mPackageName = packageName; item.mDescription = download.mDescription; - String className = download.mClass; item.addItem(title, progress, max); mNotifications.put(packageName, item); } @@ -195,7 +194,8 @@ class DownloadNotification { Intent intent = new Intent(Constants.ACTION_LIST); intent.setClassName("com.android.providers.downloads", DownloadReceiver.class.getName()); - intent.setData(ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, item.mId)); + intent.setData( + ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, item.mId)); intent.putExtra("multiple", item.mTitleCount > 1); n.contentIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); @@ -209,7 +209,7 @@ class DownloadNotification { return download.mStatus == Downloads.STATUS_RUNNING_PAUSED && download.mPausedReason != null; } - private void updateCompletedNotification(List<DownloadInfo> downloads) { + private void updateCompletedNotification(Collection<DownloadInfo> downloads) { for (DownloadInfo download : downloads) { if (!isCompleteAndVisible(download)) { continue; @@ -224,7 +224,8 @@ class DownloadNotification { title = mContext.getResources().getString( R.string.download_unknown_title); } - Uri contentUri = ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, id); + Uri contentUri = + ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id); String caption; Intent intent; if (Downloads.Impl.isStatusError(download.mStatus)) { |