summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2019-04-15 03:27:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-15 03:27:32 +0000
commitb9c822d6b72be2885a00cc5533b4cdd460f23e2b (patch)
tree44ab0fb894183bb196b5acd179aed3ae44c47e83
parentcf44c4115880569034271637fb941399d57456d3 (diff)
parentdb73a7da263849c9109cb6f906a01ca0c61d8da4 (diff)
Merge "Renaming or moving files should initiate scan." into qt-dev
-rw-r--r--core/java/com/android/internal/content/FileSystemProvider.java32
1 files changed, 5 insertions, 27 deletions
diff --git a/core/java/com/android/internal/content/FileSystemProvider.java b/core/java/com/android/internal/content/FileSystemProvider.java
index 18c4b467dfba..a7244a744abf 100644
--- a/core/java/com/android/internal/content/FileSystemProvider.java
+++ b/core/java/com/android/internal/content/FileSystemProvider.java
@@ -332,33 +332,11 @@ public abstract class FileSystemProvider extends DocumentsProvider {
}
private void moveInMediaStore(@Nullable File oldVisibleFile, @Nullable File newVisibleFile) {
- // visibleFolders are null if we're moving a document in external thumb drive or SD card.
- //
- // They should be all null or not null at the same time. File#renameTo() doesn't work across
- // volumes so an exception will be thrown before calling this method.
- if (oldVisibleFile != null && newVisibleFile != null) {
- final long token = Binder.clearCallingIdentity();
-
- try {
- final ContentResolver resolver = getContext().getContentResolver();
- final Uri externalUri = newVisibleFile.isDirectory()
- ? MediaStore.Files.getDirectoryUri("external")
- : MediaStore.Files.getContentUri("external");
-
- ContentValues values = new ContentValues();
- values.put(MediaStore.Files.FileColumns.DATA, newVisibleFile.getAbsolutePath());
-
- // Logic borrowed from MtpDatabase.
- // note - we are relying on a special case in MediaProvider.update() to update
- // the paths for all children in the case where this is a directory.
- final String path = oldVisibleFile.getAbsolutePath();
- resolver.update(externalUri,
- values,
- "_data LIKE ? AND lower(_data)=lower(?)",
- new String[]{path, path});
- } finally {
- Binder.restoreCallingIdentity(token);
- }
+ if (oldVisibleFile != null) {
+ MediaStore.scanFile(getContext(), oldVisibleFile);
+ }
+ if (newVisibleFile != null) {
+ MediaStore.scanFile(getContext(), newVisibleFile);
}
}