Merge "Allow files to be created under download dirs from MediaStore." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2699f04e82
@@ -247,7 +247,6 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
}
|
||||
childId = getDocIdForFile(file);
|
||||
onDocIdChanged(childId);
|
||||
addFolderToMediaStore(getFileForDocId(childId, true));
|
||||
} else {
|
||||
try {
|
||||
if (!file.createNewFile()) {
|
||||
@@ -259,19 +258,11 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
throw new IllegalStateException("Failed to touch " + file + ": " + e);
|
||||
}
|
||||
}
|
||||
MediaStore.scanFile(getContext(), file);
|
||||
|
||||
return childId;
|
||||
}
|
||||
|
||||
private void addFolderToMediaStore(@Nullable File visibleFolder) {
|
||||
// visibleFolder is null if we're adding a folder to external thumb drive or SD card.
|
||||
if (visibleFolder != null) {
|
||||
assert (visibleFolder.isDirectory());
|
||||
|
||||
MediaStore.scanFile(getContext(), visibleFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String renameDocument(String docId, String displayName) throws FileNotFoundException {
|
||||
// Since this provider treats renames as generating a completely new
|
||||
@@ -293,7 +284,6 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
moveInMediaStore(beforeVisibleFile, afterVisibleFile);
|
||||
|
||||
if (!TextUtils.equals(docId, afterDocId)) {
|
||||
scanFile(afterVisibleFile);
|
||||
return afterDocId;
|
||||
} else {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user