From 6b9789795ced7bf05e2c592c8445722df500e279 Mon Sep 17 00:00:00 2001 From: Per Edelberg Date: Wed, 10 Feb 2010 08:30:48 +0100 Subject: Show correct date for downloads in the statusbar 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. --- src/com/android/providers/downloads/DownloadNotification.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java index 9f54190e..f7c10073 100644 --- a/src/com/android/providers/downloads/DownloadNotification.java +++ b/src/com/android/providers/downloads/DownloadNotification.java @@ -276,6 +276,7 @@ class DownloadNotification { intent.setClassName("com.android.providers.downloads", DownloadReceiver.class.getName()); intent.setData(contentUri); + n.when = c.getLong(lastModColumnId); n.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(mContext, 0, intent, 0)); @@ -285,8 +286,6 @@ class DownloadNotification { intent.setData(contentUri); n.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); - n.when = c.getLong(lastModColumnId); - mNotificationMgr.notify(c.getInt(idColumn), n); } c.close(); -- cgit v1.2.3 From 72f14a6f122f020e560e6572b2581c43b3ea90e3 Mon Sep 17 00:00:00 2001 From: usul Date: Sun, 28 Mar 2010 16:26:05 +0100 Subject: code left opened files behind 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 --- src/com/android/providers/downloads/DownloadThread.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java index d899314b..1ad1d4f9 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -694,8 +694,10 @@ http_request_loop: FileUtils.setPermissions(filename, 0644, -1, -1); // Sync to storage after completion + FileOutputStream downloadedFileStream = null; try { - new FileOutputStream(filename, true).getFD().sync(); + downloadedFileStream = new FileOutputStream(filename, true); + downloadedFileStream.getFD().sync(); } catch (FileNotFoundException ex) { Log.w(Constants.TAG, "file " + filename + " not found: " + ex); } catch (SyncFailedException ex) { @@ -704,6 +706,16 @@ http_request_loop: Log.w(Constants.TAG, "IOException trying to sync " + filename + ": " + ex); } catch (RuntimeException ex) { Log.w(Constants.TAG, "exception while syncing file: ", ex); + } finally { + if(downloadedFileStream != null) { + try { + downloadedFileStream.close(); + } catch (IOException ex) { + Log.w(Constants.TAG, "IOException while closing synced file: ", ex); + } catch (RuntimeException ex) { + Log.w(Constants.TAG, "exception while closing file: ", ex); + } + } } } } -- cgit v1.2.3