diff options
author | Marco Nelissen <marcone@google.com> | 2011-03-29 13:29:42 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2011-03-29 13:29:42 -0700 |
commit | 3e5e8055942ee8179675b8ed11d40ca12dbe42e6 (patch) | |
tree | 603973d3f3fdb7eabf80f2bf40c228814b3b5f20 /media | |
parent | 60355780eaa7d80a76a5481ab033606bcfb630fd (diff) | |
download | frameworks_base-3e5e8055942ee8179675b8ed11d40ca12dbe42e6.zip frameworks_base-3e5e8055942ee8179675b8ed11d40ca12dbe42e6.tar.gz frameworks_base-3e5e8055942ee8179675b8ed11d40ca12dbe42e6.tar.bz2 |
Fix media scanner uri handling.
If a file was originally considered a video file (because it had
a .mp4 extension, for example), but was then discovered to have
only an audio track, it would update the type, but not the URI
for insertion into the media provider.
Change-Id: Ifdf3a177750f1e71ca5a058fa534d272e1505653
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaScanner.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 6b9f2fb..02f3902 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -347,7 +347,6 @@ public class MediaScanner private BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options(); private static class FileCacheEntry { - Uri mTableUri; long mRowId; String mPath; long mLastModified; @@ -355,8 +354,7 @@ public class MediaScanner boolean mSeenInFileSystem; boolean mLastModifiedChanged; - FileCacheEntry(Uri tableUri, long rowId, String path, long lastModified, int format) { - mTableUri = tableUri; + FileCacheEntry(long rowId, String path, long lastModified, int format) { mRowId = rowId; mPath = path; mLastModified = lastModified; @@ -367,7 +365,7 @@ public class MediaScanner @Override public String toString() { - return mPath + " mTableUri: " + mTableUri + " mRowId: " + mRowId; + return mPath + " mRowId: " + mRowId; } } @@ -491,23 +489,10 @@ public class MediaScanner long delta = (entry != null) ? (lastModified - entry.mLastModified) : 0; boolean wasModified = delta > 1 || delta < -1; if (entry == null || wasModified) { - Uri tableUri; - if (isDirectory) { - tableUri = mFilesUri; - } else if (MediaFile.isVideoFileType(mFileType)) { - tableUri = mVideoUri; - } else if (MediaFile.isImageFileType(mFileType)) { - tableUri = mImagesUri; - } else if (MediaFile.isAudioFileType(mFileType)) { - tableUri = mAudioUri; - } else { - tableUri = mFilesUri; - } if (wasModified) { entry.mLastModified = lastModified; - entry.mTableUri = tableUri; } else { - entry = new FileCacheEntry(tableUri, 0, path, lastModified, + entry = new FileCacheEntry(0, path, lastModified, (isDirectory ? MtpConstants.FORMAT_ASSOCIATION : 0)); mFileCache.put(key, entry); } @@ -829,7 +814,14 @@ public class MediaScanner } } - Uri tableUri = entry.mTableUri; + Uri tableUri = mFilesUri; + if (MediaFile.isVideoFileType(mFileType)) { + tableUri = mVideoUri; + } else if (MediaFile.isImageFileType(mFileType)) { + tableUri = mImagesUri; + } else if (MediaFile.isAudioFileType(mFileType)) { + tableUri = mAudioUri; + } Uri result = null; if (rowId == 0) { if (mMtpObjectHandle != 0) { @@ -1021,13 +1013,13 @@ public class MediaScanner // Only consider entries with absolute path names. // This allows storing URIs in the database without the // media scanner removing them. - if (path.startsWith("/")) { + if (path != null && path.startsWith("/")) { String key = path; if (mCaseInsensitivePaths) { key = path.toLowerCase(); } - FileCacheEntry entry = new FileCacheEntry(mFilesUri, rowId, path, + FileCacheEntry entry = new FileCacheEntry(rowId, path, lastModified, format); mFileCache.put(key, entry); } |