summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-10-15 12:43:04 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-15 12:43:04 -0700
commitf9360e2fdc28e98d2f5c0fb25c18d2f1e6b32645 (patch)
tree1cf1443e9e42f0c377047cd7125eb8b0188334ee /ui
parent137f02d0e961b5fb761868db85e7f43966f35d52 (diff)
parent57c4e9180e3a339dba984f1c8dff76ef18443a7a (diff)
downloadandroid_packages_providers_DownloadProvider-f9360e2fdc28e98d2f5c0fb25c18d2f1e6b32645.tar.gz
android_packages_providers_DownloadProvider-f9360e2fdc28e98d2f5c0fb25c18d2f1e6b32645.tar.bz2
android_packages_providers_DownloadProvider-f9360e2fdc28e98d2f5c0fb25c18d2f1e6b32645.zip
am 57c4e918: am e00c3120: bug:3069735 in Download UI app, handle deletes correctly
Merge commit '57c4e9180e3a339dba984f1c8dff76ef18443a7a' * commit '57c4e9180e3a339dba984f1c8dff76ef18443a7a': bug:3069735 in Download UI app, handle deletes correctly
Diffstat (limited to 'ui')
-rw-r--r--ui/src/com/android/providers/downloads/ui/DownloadList.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/ui/src/com/android/providers/downloads/ui/DownloadList.java b/ui/src/com/android/providers/downloads/ui/DownloadList.java
index f1cb91fe..33f821f6 100644
--- a/ui/src/com/android/providers/downloads/ui/DownloadList.java
+++ b/ui/src/com/android/providers/downloads/ui/DownloadList.java
@@ -33,6 +33,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.Downloads;
+import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -51,7 +52,6 @@ import android.widget.Toast;
import com.android.providers.downloads.ui.DownloadItem.DownloadSelectListener;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
@@ -86,6 +86,7 @@ public class DownloadList extends Activity
private int mLocalUriColumnId;
private int mMediaTypeColumnId;
private int mReasonColumndId;
+ private int mMediaProviderUriId;
private boolean mIsSortedBySize = false;
private Set<Long> mSelectedIds = new HashSet<Long>();
@@ -148,6 +149,9 @@ public class DownloadList extends Activity
mDateSortedCursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE);
mReasonColumndId =
mDateSortedCursor.getColumnIndexOrThrow(DownloadManager.COLUMN_REASON);
+ mMediaProviderUriId =
+ mDateSortedCursor.getColumnIndexOrThrow(
+ DownloadManager.COLUMN_MEDIAPROVIDER_URI);
mDateSortedAdapter = new DateSortedDownloadAdapter(this, mDateSortedCursor, this);
mDateOrderedListView.setAdapter(mDateSortedAdapter);
@@ -588,30 +592,25 @@ public class DownloadList extends Activity
if (isComplete && localUri != null) {
String path = Uri.parse(localUri).getPath();
if (path.startsWith(Environment.getExternalStorageDirectory().getPath())) {
- String mediaType = mDateSortedCursor.getString(mMediaTypeColumnId);
- deleteDownloadedFile(path, mediaType);
+ String mediaProviderUri = mDateSortedCursor.getString(mMediaProviderUriId);
+ if (TextUtils.isEmpty(mediaProviderUri)) {
+ // downloads database doesn't have the mediaprovider_uri. It means
+ // this download occurred before mediaprovider_uri column existed
+ // in downloads table. Since MediaProvider needs the mediaprovider_uri to
+ // delete this download, just set the 'deleted' flag to 1 on this row
+ // in the database. DownloadService, upon seeing this flag set to 1, will
+ // re-scan the file and get the MediaProviderUri and then delete the file
+ mDownloadManager.markRowDeleted(downloadId);
+ return;
+ } else {
+ getContentResolver().delete(Uri.parse(mediaProviderUri), null, null);
+ }
}
}
}
mDownloadManager.remove(downloadId);
}
- /**
- * Delete the file at the given path. Try sending an intent to delete it, but if that goes
- * unhandled, delete it ourselves.
- * @param path path to the file to delete
- */
- private void deleteDownloadedFile(String path, String mediaType) {
- Intent intent = new Intent(Intent.ACTION_DELETE);
- File file = new File(path);
- intent.setDataAndType(Uri.fromFile(file), mediaType);
- try {
- startActivity(intent);
- } catch (ActivityNotFoundException exc) {
- file.delete();
- }
- }
-
@Override
public boolean isDownloadSelected(long id) {
return mSelectedIds.contains(id);