summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Huang <tonyychuang@google.com>2018-09-11 09:09:12 (GMT)
committerWang Han <416810799@qq.com>2019-08-17 13:55:56 (GMT)
commit23e35f6f310b59d8e24d059b4826694686314837 (patch)
treebbf0a05bd205425dea5ff5365406c5666aa61709
parent6d414fb909c986751cc50429cb5c8532678f2bb3 (diff)
downloadframeworks_base-23e35f6f310b59d8e24d059b4826694686314837.zip
frameworks_base-23e35f6f310b59d8e24d059b4826694686314837.tar.gz
frameworks_base-23e35f6f310b59d8e24d059b4826694686314837.tar.bz2
Fix ExternalStorageProvider always throw exception when rename
ExternalStorageProvider always throw exception when renameDocument because it will check file exist when getFileForDocId. However, beforeVisibleFile is not exist after rename, it will throw exception. Fix it by put getting beforeVisibleFile before rename. Test: manual test rename in DocumentsUI Test: atest RenameActualProviderUiTest Fix: 113302685 Fix: 115304092 Change-Id: I45d60d2f940e3dbc2b121f7cd28acc3c2d085ec4 Merged-In: I45d60d2f940e3dbc2b121f7cd28acc3c2d085ec4
-rw-r--r--core/java/com/android/internal/content/FileSystemProvider.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/java/com/android/internal/content/FileSystemProvider.java b/core/java/com/android/internal/content/FileSystemProvider.java
index b591163..f90eab1 100644
--- a/core/java/com/android/internal/content/FileSystemProvider.java
+++ b/core/java/com/android/internal/content/FileSystemProvider.java
@@ -236,6 +236,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
displayName = FileUtils.buildValidFatFilename(displayName);
final File before = getFileForDocId(docId);
+ final File beforeVisibleFile = getFileForDocId(docId, true);
final File after = FileUtils.buildUniqueFile(before.getParentFile(), displayName);
if (!before.renameTo(after)) {
throw new IllegalStateException("Failed to rename to " + after);
@@ -245,7 +246,6 @@ public abstract class FileSystemProvider extends DocumentsProvider {
onDocIdChanged(docId);
onDocIdChanged(afterDocId);
- final File beforeVisibleFile = getFileForDocId(docId, true);
final File afterVisibleFile = getFileForDocId(afterDocId, true);
moveInMediaStore(beforeVisibleFile, afterVisibleFile);