Add volume name while creating files in public volume
Previously, files created in public volume were added to database with
volume name as VOLUME_EXTERNAL_PRIMARY. Changed insertFileForFuse to
extract volume name from path when inserting a file using RELATIVE_PATH
and DISPLAY_NAME.
Test: atest packages/providers/MediaProvider
Bug: 150366834
Change-Id: Ibd7a64de4f35b6e2b8a4690fdfcf7cd7d3d1ed49
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 762dbf4..f50c7fd 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -6093,6 +6093,7 @@
if (useData) {
values.put(FileColumns.DATA, getAbsoluteSanitizedPath(path));
} else {
+ values.put(FileColumns.VOLUME_NAME, extractVolumeName(path));
values.put(FileColumns.RELATIVE_PATH, extractRelativePath(path));
values.put(FileColumns.DISPLAY_NAME, extractDisplayName(path));
}