Loading media/java/android/media/MediaScanner.java +83 −61 Original line number Diff line number Diff line Loading @@ -1194,8 +1194,26 @@ public class MediaScanner } mMtpObjectHandle = objectHandle; try { initialize(volumeName); try { if (MediaFile.isPlayListFileType(fileType)) { // 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()); } if (mCaseInsensitivePaths) { key = path.toLowerCase(); } FileCacheEntry entry = mFileCache.get(key); if (entry != null) { processPlayList(entry); } } else { // MTP will create a file entry for us so we don't want to do it in prescan prescan(path, false); Loading @@ -1206,6 +1224,7 @@ public class MediaScanner // always scan the file, so we can return the content://media Uri for existing files mClient.doScanFile(path, mediaFileType.mimeType, lastModifiedSeconds, file.length(), true); } } catch (RemoteException e) { Log.e(TAG, "RemoteException in MediaScanner.scanFile()", e); } finally { Loading Loading @@ -1285,8 +1304,7 @@ public class MediaScanner } } // if the match is not for an audio file, bail out if (bestMatch == null || ! mAudioUri.equals(bestMatch.mTableUri)) { if (bestMatch == null) { return false; } Loading Loading @@ -1431,14 +1449,8 @@ public class MediaScanner } } private void processPlayLists() throws RemoteException { Iterator<FileCacheEntry> iterator = mPlayLists.iterator(); while (iterator.hasNext()) { FileCacheEntry entry = iterator.next(); private void processPlayList(FileCacheEntry entry) throws RemoteException { String path = entry.mPath; // only process playlist files if they are new or have been modified since the last scan if (entry.mLastModifiedChanged) { ContentValues values = new ContentValues(); int lastSlash = path.lastIndexOf('/'); if (lastSlash < 0) throw new IllegalArgumentException("bad path " + path); Loading Loading @@ -1471,12 +1483,13 @@ public class MediaScanner MediaFile.MediaFileType mediaFileType = MediaFile.getFileType(path); int fileType = (mediaFileType == null ? 0 : mediaFileType.fileType); if (fileType == MediaFile.FILE_TYPE_M3U) if (fileType == MediaFile.FILE_TYPE_M3U) { processM3uPlayList(path, playListDirectory, membersUri, values); else if (fileType == MediaFile.FILE_TYPE_PLS) } else if (fileType == MediaFile.FILE_TYPE_PLS) { processPlsPlayList(path, playListDirectory, membersUri, values); else if (fileType == MediaFile.FILE_TYPE_WPL) } else if (fileType == MediaFile.FILE_TYPE_WPL) { processWplPlayList(path, playListDirectory, membersUri); } Cursor cursor = mMediaProvider.query(membersUri, PLAYLIST_MEMBERS_PROJECTION, null, null, null); Loading @@ -1489,6 +1502,15 @@ public class MediaScanner if (cursor != null) cursor.close(); } } private void processPlayLists() throws RemoteException { Iterator<FileCacheEntry> iterator = mPlayLists.iterator(); while (iterator.hasNext()) { FileCacheEntry entry = iterator.next(); // only process playlist files if they are new or have been modified since the last scan if (entry.mLastModifiedChanged) { processPlayList(entry); } } } Loading Loading
media/java/android/media/MediaScanner.java +83 −61 Original line number Diff line number Diff line Loading @@ -1194,8 +1194,26 @@ public class MediaScanner } mMtpObjectHandle = objectHandle; try { initialize(volumeName); try { if (MediaFile.isPlayListFileType(fileType)) { // 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()); } if (mCaseInsensitivePaths) { key = path.toLowerCase(); } FileCacheEntry entry = mFileCache.get(key); if (entry != null) { processPlayList(entry); } } else { // MTP will create a file entry for us so we don't want to do it in prescan prescan(path, false); Loading @@ -1206,6 +1224,7 @@ public class MediaScanner // always scan the file, so we can return the content://media Uri for existing files mClient.doScanFile(path, mediaFileType.mimeType, lastModifiedSeconds, file.length(), true); } } catch (RemoteException e) { Log.e(TAG, "RemoteException in MediaScanner.scanFile()", e); } finally { Loading Loading @@ -1285,8 +1304,7 @@ public class MediaScanner } } // if the match is not for an audio file, bail out if (bestMatch == null || ! mAudioUri.equals(bestMatch.mTableUri)) { if (bestMatch == null) { return false; } Loading Loading @@ -1431,14 +1449,8 @@ public class MediaScanner } } private void processPlayLists() throws RemoteException { Iterator<FileCacheEntry> iterator = mPlayLists.iterator(); while (iterator.hasNext()) { FileCacheEntry entry = iterator.next(); private void processPlayList(FileCacheEntry entry) throws RemoteException { String path = entry.mPath; // only process playlist files if they are new or have been modified since the last scan if (entry.mLastModifiedChanged) { ContentValues values = new ContentValues(); int lastSlash = path.lastIndexOf('/'); if (lastSlash < 0) throw new IllegalArgumentException("bad path " + path); Loading Loading @@ -1471,12 +1483,13 @@ public class MediaScanner MediaFile.MediaFileType mediaFileType = MediaFile.getFileType(path); int fileType = (mediaFileType == null ? 0 : mediaFileType.fileType); if (fileType == MediaFile.FILE_TYPE_M3U) if (fileType == MediaFile.FILE_TYPE_M3U) { processM3uPlayList(path, playListDirectory, membersUri, values); else if (fileType == MediaFile.FILE_TYPE_PLS) } else if (fileType == MediaFile.FILE_TYPE_PLS) { processPlsPlayList(path, playListDirectory, membersUri, values); else if (fileType == MediaFile.FILE_TYPE_WPL) } else if (fileType == MediaFile.FILE_TYPE_WPL) { processWplPlayList(path, playListDirectory, membersUri); } Cursor cursor = mMediaProvider.query(membersUri, PLAYLIST_MEMBERS_PROJECTION, null, null, null); Loading @@ -1489,6 +1502,15 @@ public class MediaScanner if (cursor != null) cursor.close(); } } private void processPlayLists() throws RemoteException { Iterator<FileCacheEntry> iterator = mPlayLists.iterator(); while (iterator.hasNext()) { FileCacheEntry entry = iterator.next(); // only process playlist files if they are new or have been modified since the last scan if (entry.mLastModifiedChanged) { processPlayList(entry); } } } Loading