diff options
author | Marco Nelissen <marcone@google.com> | 2012-02-07 08:28:02 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-07 08:28:02 -0800 |
commit | f047c14f23abd94b3fb04f56dded13b66236ca53 (patch) | |
tree | 88905ce02bd53c8747fdd1047626492c2aece492 | |
parent | fb2cfa223b47db3ee46df22dcdb92f4fb013dcdd (diff) | |
parent | ac259f17a0a6ba9e363bbf0c268c5942aab392c1 (diff) | |
download | frameworks_base-f047c14f23abd94b3fb04f56dded13b66236ca53.zip frameworks_base-f047c14f23abd94b3fb04f56dded13b66236ca53.tar.gz frameworks_base-f047c14f23abd94b3fb04f56dded13b66236ca53.tar.bz2 |
Merge "Make media scanner use new delete-parameter"
-rw-r--r-- | core/java/android/provider/MediaStore.java | 12 | ||||
-rw-r--r-- | media/java/android/media/MediaScanner.java | 18 |
2 files changed, 20 insertions, 10 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index d11219b..d3ad63d 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -70,6 +70,18 @@ public final class MediaStore { public static final String UNHIDE_CALL = "unhide"; /** + * This is for internal use by the media scanner only. + * Name of the (optional) Uri parameter that determines whether to skip deleting + * the file pointed to by the _data column, when deleting the database entry. + * The only appropriate value for this parameter is "false", in which case the + * delete will be skipped. Note especially that setting this to true, or omitting + * the parameter altogether, will perform the default action, which is different + * for different types of media. + * @hide + */ + public static final String PARAM_DELETE_DATA = "deletedata"; + + /** * Activity Action: Launch a music player. * The activity should be able to play, browse, or manipulate music files stored on the device. * 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); |