summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-07-13 16:50:29 -0400
committerMike Lockwood <lockwood@android.com>2011-07-13 16:50:29 -0400
commit45aaa2a345292bb6d600822db602f25e261c0e50 (patch)
tree1f4ef0cea8fec34992d30f2986f0915c9fc6fbe1
parent67d464f47e842d5069e993408fd51ec122ad8019 (diff)
downloadframeworks_base-45aaa2a345292bb6d600822db602f25e261c0e50.zip
frameworks_base-45aaa2a345292bb6d600822db602f25e261c0e50.tar.gz
frameworks_base-45aaa2a345292bb6d600822db602f25e261c0e50.tar.bz2
MediaScanner: fix breakage in updates
To facilitate bulk inserts, we changed the media scanner to use the file URI instead of the audio, video or image media URIs. However we should still use the media URIs for updating existing records Bug: 5021925 Change-Id: I6143dc1d00350192170428a5e951b52ef9223734 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--media/java/android/media/MediaScanner.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index e8ddd2d..e89be08 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -835,6 +835,9 @@ public class MediaScanner
}
}
+ // For inserts we always use the file URI so we can insert in bulk.
+ // For updates we compute the URI based on the media type.
+ Uri tableUri = mFilesUri;
Uri result = null;
if (rowId == 0) {
if (mMtpObjectHandle != 0) {
@@ -850,7 +853,7 @@ public class MediaScanner
if (mFileInserter != null) {
result = mFileInserter.insert(values);
} else {
- result = mMediaProvider.insert(mFilesUri, values);
+ result = mMediaProvider.insert(tableUri, values);
}
if (result != null) {
@@ -858,8 +861,18 @@ public class MediaScanner
entry.mRowId = rowId;
}
} else {
+ if (!mNoMedia) {
+ if (MediaFile.isVideoFileType(mFileType)) {
+ tableUri = mVideoUri;
+ } else if (MediaFile.isImageFileType(mFileType)) {
+ tableUri = mImagesUri;
+ } else if (MediaFile.isAudioFileType(mFileType)) {
+ tableUri = mAudioUri;
+ }
+ }
+
// updated file
- result = ContentUris.withAppendedId(mFilesUri, rowId);
+ result = ContentUris.withAppendedId(tableUri, rowId);
// path should never change, and we want to avoid replacing mixed cased paths
// with squashed lower case paths
values.remove(MediaStore.MediaColumns.DATA);
@@ -909,19 +922,19 @@ public class MediaScanner
if (notifications && !mDefaultNotificationSet) {
if (TextUtils.isEmpty(mDefaultNotificationFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename)) {
- setSettingIfNotSet(Settings.System.NOTIFICATION_SOUND, mFilesUri, rowId);
+ setSettingIfNotSet(Settings.System.NOTIFICATION_SOUND, tableUri, rowId);
mDefaultNotificationSet = true;
}
} else if (ringtones && !mDefaultRingtoneSet) {
if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
- setSettingIfNotSet(Settings.System.RINGTONE, mFilesUri, rowId);
+ setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
mDefaultRingtoneSet = true;
}
} else if (alarms && !mDefaultAlarmSet) {
if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) {
- setSettingIfNotSet(Settings.System.ALARM_ALERT, mFilesUri, rowId);
+ setSettingIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId);
mDefaultAlarmSet = true;
}
}