diff options
author | Dongwon Kang <dwkang@google.com> | 2011-08-18 18:04:46 +0900 |
---|---|---|
committer | Dongwon Kang <dwkang@google.com> | 2011-09-08 10:50:40 +0900 |
commit | 7d92a22d9dec42a45cd55fd77d0a86b4b9c6e9df (patch) | |
tree | 2cd3a616c04a91fe89e5a5b6016e011eea959c68 /media | |
parent | 9f443fb6e70f4dafdc9610385c66425410bb3ff1 (diff) | |
download | frameworks_base-7d92a22d9dec42a45cd55fd77d0a86b4b9c6e9df.zip frameworks_base-7d92a22d9dec42a45cd55fd77d0a86b4b9c6e9df.tar.gz frameworks_base-7d92a22d9dec42a45cd55fd77d0a86b4b9c6e9df.tar.bz2 |
MediaScanner: To query row ids of music files when handling playlists.
Change-Id: I3c2a803618bfdaf4915f2487669952d5e3b4dd32
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaScanner.java | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 65818a1..2859bfb 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -314,14 +314,14 @@ public class MediaScanner // WARNING: Bulk inserts sounded like a great idea and gave us a good performance improvement, // but unfortunately it also introduced a number of bugs. Many of those bugs were fixed, - // but (at least) two problems are still outstanding: + // but (at least) one problem is still outstanding: // - // 1) Bulk inserts broke the code that sets the default ringtones on first boot - // 2) Bulk inserts broke file based playlists in the case where the playlist is processed - // at the same time the files in the playlist are inserted in the database + // - Bulk inserts broke the code that sets the default ringtones, notifications, and alarms + // on first boot // - // These problems might be solvable by moving the logic to the media provider instead, - // but for now we are disabling bulk inserts until we have solid fixes for these problems. + // This problem might be solvable by moving the logic to the media provider or disabling bulk + // inserts only for those cases. For now, we are disabling bulk inserts until we have a solid + // fix for this problem. private static final boolean ENABLE_BULK_INSERTS = false; // used when scanning the image database so we know whether we have to prune @@ -1439,7 +1439,22 @@ public class MediaScanner } try { - // OK, now we need to add this to the database + // check rowid is set. Rowid may be missing if it is inserted by bulkInsert(). + if (bestMatch.mRowId == 0) { + Cursor c = mMediaProvider.query(mAudioUri, ID_PROJECTION, + MediaStore.Files.FileColumns.DATA + "=?", + new String[] { bestMatch.mPath }, null); + if (c != null) { + if (c.moveToNext()) { + bestMatch.mRowId = c.getLong(0); + } + c.close(); + } + if (bestMatch.mRowId == 0) { + return false; + } + } + // OK, now we are ready to add this to the database values.clear(); values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(index)); values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, Long.valueOf(bestMatch.mRowId)); |