diff options
author | Mike Lockwood <lockwood@android.com> | 2011-08-01 09:31:57 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-01 09:31:57 -0700 |
commit | 6031b5de9639a5c32c6e5dac56da991ba63ad444 (patch) | |
tree | aa743b5656807c32aafa52ae53c6d25a758dd7b9 | |
parent | 9a6c7383b3d3000b33c5835851331edcacc47811 (diff) | |
parent | e5d0495d5206167c597efcd81436a0f881f069f9 (diff) | |
download | frameworks_base-6031b5de9639a5c32c6e5dac56da991ba63ad444.zip frameworks_base-6031b5de9639a5c32c6e5dac56da991ba63ad444.tar.gz frameworks_base-6031b5de9639a5c32c6e5dac56da991ba63ad444.tar.bz2 |
Merge "MediaScanner: Move genre table management to MediaProvider"
-rw-r--r-- | core/java/android/provider/MediaStore.java | 8 | ||||
-rw-r--r-- | media/java/android/media/MediaScanner.java | 55 |
2 files changed, 10 insertions, 53 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index f799af3..5da3114 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -1148,6 +1148,14 @@ public final class MediaStore { * <P>Type: INTEGER (boolean)</P> */ public static final String IS_NOTIFICATION = "is_notification"; + + /** + * The genre of the audio file, if any + * <P>Type: TEXT</P> + * Does not exist in the database - only used by the media scanner for inserts. + * @hide + */ + public static final String GENRE = "genre"; } /** diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 58f9432..8339e4b 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -40,7 +40,6 @@ import android.provider.MediaStore.Audio; import android.provider.MediaStore.Files; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; -import android.provider.MediaStore.Audio.Genres; import android.provider.MediaStore.Audio.Playlists; import android.sax.Element; import android.sax.ElementListener; @@ -138,11 +137,6 @@ public class MediaScanner private static final int PATH_PLAYLISTS_COLUMN_INDEX = 1; private static final int DATE_MODIFIED_PLAYLISTS_COLUMN_INDEX = 2; - private static final String[] GENRE_LOOKUP_PROJECTION = new String[] { - Audio.Genres._ID, // 0 - Audio.Genres.NAME, // 1 - }; - private static final String RINGTONES_DIR = "/ringtones/"; private static final String NOTIFICATIONS_DIR = "/notifications/"; private static final String ALARMS_DIR = "/alarms/"; @@ -311,10 +305,9 @@ public class MediaScanner private Uri mVideoUri; private Uri mImagesUri; private Uri mThumbsUri; - private Uri mGenresUri; private Uri mPlaylistsUri; private Uri mFilesUri; - private boolean mProcessPlaylists, mProcessGenres; + private boolean mProcessPlaylists; private int mMtpObjectHandle; private final String mExternalStoragePath; @@ -413,7 +406,6 @@ public class MediaScanner private HashMap<String, FileCacheEntry> mFileCache; private ArrayList<FileCacheEntry> mPlayLists; - private HashMap<String, Uri> mGenreCache; private DrmManagerClient mDrmManagerClient = null; @@ -735,6 +727,7 @@ public class MediaScanner map.put(Audio.Media.ALBUM, (mAlbum != null && mAlbum.length() > 0) ? mAlbum : MediaStore.UNKNOWN_STRING); map.put(Audio.Media.COMPOSER, mComposer); + map.put(Audio.Media.GENRE, mGenre); if (mYear != 0) { map.put(Audio.Media.YEAR, mYear); } @@ -894,46 +887,6 @@ public class MediaScanner values.remove(MediaStore.MediaColumns.DATA); mMediaProvider.update(result, values, null, null); } - if (mProcessGenres && mGenre != null) { - String genre = mGenre; - Uri uri = mGenreCache.get(genre); - if (uri == null) { - Cursor cursor = null; - try { - // see if the genre already exists - cursor = mMediaProvider.query( - mGenresUri, - GENRE_LOOKUP_PROJECTION, MediaStore.Audio.Genres.NAME + "=?", - new String[] { genre }, null); - if (cursor == null || cursor.getCount() == 0) { - // genre does not exist, so create the genre in the genre table - values = new ContentValues(); - values.put(MediaStore.Audio.Genres.NAME, genre); - uri = mMediaProvider.insert(mGenresUri, values); - } else { - // genre already exists, so compute its Uri - cursor.moveToNext(); - uri = ContentUris.withAppendedId(mGenresUri, cursor.getLong(0)); - } - if (uri != null) { - uri = Uri.withAppendedPath(uri, Genres.Members.CONTENT_DIRECTORY); - mGenreCache.put(genre, uri); - } - } finally { - // release the cursor if it exists - if (cursor != null) { - cursor.close(); - } - } - } - - if (uri != null) { - // add entry to audio_genre_map - values = new ContentValues(); - values.put(MediaStore.Audio.Genres.Members.AUDIO_ID, Long.valueOf(rowId)); - mMediaProvider.insert(uri, values); - } - } if (notifications && !mDefaultNotificationSet) { if (TextUtils.isEmpty(mDefaultNotificationFilename) || @@ -1181,7 +1134,6 @@ public class MediaScanner pruneDeadThumbnailFiles(); // allow GC to clean up - mGenreCache = null; mPlayLists = null; mFileCache = null; mMediaProvider = null; @@ -1199,9 +1151,6 @@ public class MediaScanner if (!volumeName.equals("internal")) { // we only support playlists on external media mProcessPlaylists = true; - mProcessGenres = true; - mGenreCache = new HashMap<String, Uri>(); - mGenresUri = Genres.getContentUri(volumeName); mPlaylistsUri = Playlists.getContentUri(volumeName); mCaseInsensitivePaths = true; |