summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2012-02-07 07:54:39 -0800
committerMarco Nelissen <marcone@google.com>2012-02-07 07:54:39 -0800
commitac259f17a0a6ba9e363bbf0c268c5942aab392c1 (patch)
treed0a50cf43ea9e1bc11cc439e80a90fcb2bbee9aa /media
parent8ca8a69d5801ad4b809e7b9dbf53bd728820924b (diff)
downloadframeworks_base-ac259f17a0a6ba9e363bbf0c268c5942aab392c1.zip
frameworks_base-ac259f17a0a6ba9e363bbf0c268c5942aab392c1.tar.gz
frameworks_base-ac259f17a0a6ba9e363bbf0c268c5942aab392c1.tar.bz2
Make media scanner use new delete-parameter
This speeds up the media scan case where many files were deleted or moved. Change-Id: I86e6fc6d0968eebf24923c0b5587b90d309721bb
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaScanner.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 1c13fff..9dc9cef 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -1176,15 +1176,14 @@ public class MediaScanner
}
if (fileMissing) {
- // Clear the file path to prevent the _DELETE_FILE database hook
- // in the media provider from deleting the file.
+ // Tell the provider to not delete the file.
// If the file is truly gone the delete is unnecessary, and we want to avoid
- // accidentally deleting files that are really there.
- ContentValues values = new ContentValues();
- values.put(Files.FileColumns.DATA, "");
- values.put(Files.FileColumns.DATE_MODIFIED, 0);
- mMediaProvider.update(ContentUris.withAppendedId(mFilesUri, entry.mRowId),
- values, null, null);
+ // accidentally deleting files that are really there (this may happen if the
+ // filesystem is mounted and unmounted while the scanner is running).
+ Uri.Builder builder = mFilesUri.buildUpon();
+ builder.appendEncodedPath(String.valueOf(entry.mRowId));
+ builder.appendQueryParameter(MediaStore.PARAM_DELETE_DATA, "false");
+ Uri missingUri = builder.build();
// do not delete missing playlists, since they may have been modified by the user.
// the user can delete them in the media player instead.
@@ -1193,8 +1192,7 @@ public class MediaScanner
int fileType = (mediaFileType == null ? 0 : mediaFileType.fileType);
if (!MediaFile.isPlayListFileType(fileType)) {
- mMediaProvider.delete(ContentUris.withAppendedId(mFilesUri, entry.mRowId),
- null, null);
+ mMediaProvider.delete(missingUri, null, null);
iterator.remove();
if (entry.mPath.toLowerCase(Locale.US).endsWith("/.nomedia")) {
File f = new File(path);