Skip to content

Commit ec74abb

Browse files
Mikael2 SvenssonJohan Redestig
authored andcommitted
Change in media scanner to set correct date
When the media scanner scanned a single file, the modified date (DATE_MODIFIED) was not correctly set in the content provider. It was set as milliseconds but should have been set as seconds. This caused downloaded media items to display wrongly in the camera album, since the date was wrong. Change-Id: I24cd92215c26f579eb33a4a3890f96c6ef9ec8c0
1 parent e99c012 commit ec74abb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

media/java/android/media/MediaScanner.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,12 @@ public Uri scanSingleFile(String path, String volumeName, String mimeType) {
12031203
prescan(path);
12041204

12051205
File file = new File(path);
1206+
1207+
// lastModified is in milliseconds on Files.
1208+
long lastModifiedSeconds = file.lastModified() / 1000;
1209+
12061210
// always scan the file, so we can return the content://media Uri for existing files
1207-
return mClient.doScanFile(path, mimeType, file.lastModified(), file.length(), true);
1211+
return mClient.doScanFile(path, mimeType, lastModifiedSeconds, file.length(), true);
12081212
} catch (RemoteException e) {
12091213
Log.e(TAG, "RemoteException in MediaScanner.scanFile()", e);
12101214
return null;

0 commit comments

Comments
 (0)