diff options
| author | 2010-12-17 12:11:29 -0800 | |
|---|---|---|
| committer | 2010-12-17 12:27:47 -0800 | |
| commit | fbc4939d2b51d511858846363bf02c7c9f851ed2 (patch) | |
| tree | a78592a82dd6e37d339ad4385f6287d8b6be868e | |
| parent | 5eb40a85fb4887501e13cceb5d25bf325cbb2875 (diff) | |
MediaScanner: Fix handling of .nomedia files in directories
In particular, fix the code that prevents the database triggers from deleting
files when a .nomedia file is added to a directory
Change-Id: Ie913223f3b1bbf9122842a675b96d4baac3b1c6f
Signed-off-by: Mike Lockwood <lockwood@android.com>
| -rw-r--r-- | media/java/android/media/MediaScanner.java | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 365fd65c8750..ae6dd6135a6e 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -388,7 +388,14 @@ public class MediaScanner String prop = SystemProperties.get("drm.service.enabled"); return prop != null && prop.equals("true"); } - + + private final String mediaToExternalPath(String path) { + if (mMediaStoragePath != null && path.startsWith(mMediaStoragePath)) { + path = mExternalStoragePath + path.substring(mMediaStoragePath.length()); + } + return path; + } + private class MyMediaScannerClient implements MediaScannerClient { private String mArtist; @@ -463,12 +470,9 @@ public class MediaScanner } } - String key = path; - if (mMediaStoragePath != null && key.startsWith(mMediaStoragePath)) { - // MediaProvider uses external variant of path for _data, so we need to match - // against that path instead. - key = mExternalStoragePath + key.substring(mMediaStoragePath.length()); - } + // MediaProvider uses external variant of path for _data, so we need to match + // against that path instead. + String key = mediaToExternalPath(path); if (mCaseInsensitivePaths) { key = path.toLowerCase(); } @@ -881,6 +885,8 @@ public class MediaScanner } public void addNoMediaFolder(String path) { + path = mediaToExternalPath(path); + ContentValues values = new ContentValues(); values.put(MediaStore.Images.ImageColumns.DATA, ""); String [] pathSpec = new String[] {path + '%'}; @@ -939,11 +945,9 @@ public class MediaScanner } if (filePath != null) { - if (mMediaStoragePath != null && filePath.startsWith(mMediaStoragePath)) { - // MediaProvider uses external variant of path for _data, so we need to query - // using that path instead. - filePath = mExternalStoragePath + filePath.substring(mMediaStoragePath.length()); - } + // MediaProvider uses external variant of path for _data, so we need to query + // using that path instead. + filePath = mediaToExternalPath(filePath); // query for only one file where = Files.FileColumns.DATA + "=?"; @@ -1212,12 +1216,9 @@ public class MediaScanner // build file cache so we can look up tracks in the playlist prescan(null, true); - String key = path; - if (mMediaStoragePath != null && key.startsWith(mMediaStoragePath)) { - // MediaProvider uses external variant of path for _data, so we need to match - // against that path instead. - key = mExternalStoragePath + key.substring(mMediaStoragePath.length()); - } + // MediaProvider uses external variant of path for _data, so we need to match + // against that path instead. + String key = mediaToExternalPath(path); if (mCaseInsensitivePaths) { key = path.toLowerCase(); } |