Handle null local URI when deleting a download.
Steve Howard [Thu, 30 Sep 2010 18:39:40 +0000 (11:39 -0700)]
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.

Change-Id: Icfe8dc2a6fead03b09cabe684c713fb6f0e6c1ab

ui/src/com/android/providers/downloads/ui/DownloadList.java

index bb33153..f1cb91f 100644 (file)
@@ -582,9 +582,11 @@ public class DownloadList extends Activity
     private void deleteDownload(long downloadId) {
         if (moveToDownload(downloadId)) {
             int status = mDateSortedCursor.getInt(mStatusColumnId);
-            if (status == DownloadManager.STATUS_SUCCESSFUL
-                    || status == DownloadManager.STATUS_FAILED) {
-                String path = Uri.parse(mDateSortedCursor.getString(mLocalUriColumnId)).getPath();
+            boolean isComplete = status == DownloadManager.STATUS_SUCCESSFUL
+                    || status == DownloadManager.STATUS_FAILED;
+            String localUri = mDateSortedCursor.getString(mLocalUriColumnId);
+            if (isComplete && localUri != null) {
+                String path = Uri.parse(localUri).getPath();
                 if (path.startsWith(Environment.getExternalStorageDirectory().getPath())) {
                     String mediaType = mDateSortedCursor.getString(mMediaTypeColumnId);
                     deleteDownloadedFile(path, mediaType);