summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-05-02 16:09:26 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-02 16:09:26 -0700
commitbe255f2920d1e4db30f8f4ccfc4cd252a72ad974 (patch)
tree42e17df964b282f317eb148c0703290a46db3184
parentf32330cf1793c44ece35e3f9223469eaddfde492 (diff)
parentade06df0fe3499d66ee5cc29071d41445d1091fa (diff)
downloadframeworks_base-be255f2920d1e4db30f8f4ccfc4cd252a72ad974.zip
frameworks_base-be255f2920d1e4db30f8f4ccfc4cd252a72ad974.tar.gz
frameworks_base-be255f2920d1e4db30f8f4ccfc4cd252a72ad974.tar.bz2
Merge "MediaScanner: Add special casing of WMP album art files to isNoMediaPath()"
-rw-r--r--media/java/android/media/MediaScanner.java66
1 files changed, 37 insertions, 29 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 80cc94e..790eaa3 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -431,34 +431,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;
@@ -1231,6 +1205,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;
@@ -1252,7 +1260,7 @@ public class MediaScanner
}
offset = slashIndex;
}
- return false;
+ return isNoMediaFile(path);
}
public void scanMtpFile(String path, String volumeName, int objectHandle, int format) {