diff options
author | Mike Lockwood <lockwood@android.com> | 2011-05-04 08:57:59 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-04 08:57:59 -0700 |
commit | 63de615ddb3cb81bbb5b548693faca971d182a6d (patch) | |
tree | 46104b084d9cfba6e81ad20f34e40113acc7704b /media/java | |
parent | 0faefb72fb8917c9408f7b71c2bac5a9d5f264c2 (diff) | |
parent | 36132a488b2974db9a90da809c2f3eeab99a4427 (diff) | |
download | frameworks_base-63de615ddb3cb81bbb5b548693faca971d182a6d.zip frameworks_base-63de615ddb3cb81bbb5b548693faca971d182a6d.tar.gz frameworks_base-63de615ddb3cb81bbb5b548693faca971d182a6d.tar.bz2 |
am 36132a48: DO NOT MERGE MediaScanner: Add special casing of WMP album art files to isNoMediaPath()
* commit '36132a488b2974db9a90da809c2f3eeab99a4427':
DO NOT MERGE MediaScanner: Add special casing of WMP album art files to isNoMediaPath()
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/MediaScanner.java | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index cd300ef..d1eb388 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -432,34 +432,8 @@ public class MediaScanner mFileSize = fileSize; if (!isDirectory) { - // special case certain file names - // I use regionMatches() instead of substring() below - // to avoid memory allocation - int lastSlash = path.lastIndexOf('/'); - if (lastSlash >= 0 && lastSlash + 2 < path.length()) { - if (!noMedia) { - // ignore those ._* files created by MacOS - if (path.regionMatches(lastSlash + 1, "._", 0, 2)) { - noMedia = true; - } - - // ignore album art files created by Windows Media Player: - // Folder.jpg, AlbumArtSmall.jpg, AlbumArt_{...}_Large.jpg - // and AlbumArt_{...}_Small.jpg - if (path.regionMatches(true, path.length() - 4, ".jpg", 0, 4)) { - if (path.regionMatches(true, lastSlash + 1, "AlbumArt_{", 0, 10) || - path.regionMatches(true, lastSlash + 1, "AlbumArt.", 0, 9)) { - noMedia = true; - } - int length = path.length() - lastSlash - 1; - if ((length == 17 && path.regionMatches( - true, lastSlash + 1, "AlbumArtSmall", 0, 13)) || - (length == 10 - && path.regionMatches(true, lastSlash + 1, "Folder", 0, 6))) { - noMedia = true; - } - } - } + if (!noMedia && isNoMediaFile(path)) { + noMedia = true; } mNoMedia = noMedia; @@ -1233,6 +1207,40 @@ public class MediaScanner } } + private static boolean isNoMediaFile(String path) { + File file = new File(path); + if (file.isDirectory()) return false; + + // special case certain file names + // I use regionMatches() instead of substring() below + // to avoid memory allocation + int lastSlash = path.lastIndexOf('/'); + if (lastSlash >= 0 && lastSlash + 2 < path.length()) { + // ignore those ._* files created by MacOS + if (path.regionMatches(lastSlash + 1, "._", 0, 2)) { + return true; + } + + // ignore album art files created by Windows Media Player: + // Folder.jpg, AlbumArtSmall.jpg, AlbumArt_{...}_Large.jpg + // and AlbumArt_{...}_Small.jpg + if (path.regionMatches(true, path.length() - 4, ".jpg", 0, 4)) { + if (path.regionMatches(true, lastSlash + 1, "AlbumArt_{", 0, 10) || + path.regionMatches(true, lastSlash + 1, "AlbumArt.", 0, 9)) { + return true; + } + int length = path.length() - lastSlash - 1; + if ((length == 17 && path.regionMatches( + true, lastSlash + 1, "AlbumArtSmall", 0, 13)) || + (length == 10 + && path.regionMatches(true, lastSlash + 1, "Folder", 0, 6))) { + return true; + } + } + } + return false; + } + public static boolean isNoMediaPath(String path) { if (path == null) return false; @@ -1254,7 +1262,7 @@ public class MediaScanner } offset = slashIndex; } - return false; + return isNoMediaFile(path); } public void scanMtpFile(String path, String volumeName, int objectHandle, int format) { |