Skip to content

Commit 81e85bb

Browse files
committed
Ensure we compute display name when needed
Since the media scanner no longer uses an in memory cache, it always found an entry for files inserted via MTP, which made it follow a different code path than before, which in turn made the media provider skip computing the display name column. By clearing the row id in the media scanner when handling an mtp request, we steer it back to the correct code path. b/6297105 b/6525450 Change-Id: I624522b176a0057d246ce3040598af255b00a141
1 parent a2c628f commit 81e85bb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

media/java/android/media/MediaScanner.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,13 @@ public Uri doScanFile(String path, String mimeType, long lastModified,
523523
try {
524524
FileEntry entry = beginFile(path, mimeType, lastModified,
525525
fileSize, isDirectory, noMedia);
526+
527+
// if this file was just inserted via mtp, set the rowid to zero
528+
// (even though it already exists in the database), to trigger
529+
// the correct code path for updating its entry
530+
if (mMtpObjectHandle != 0) {
531+
entry.mRowId = 0;
532+
}
526533
// rescan for metadata if file was modified since last scan
527534
if (entry != null && (entry.mLastModifiedChanged || scanAlways)) {
528535
if (noMedia) {

0 commit comments

Comments
 (0)