summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ivan Chiang <chiangi@google.com> 2025-03-11 04:45:43 +0000
committer Ivan Chiang <chiangi@google.com> 2025-03-21 05:11:19 +0000
commit8e636cc4f3951572bf75ef25bc63af904074612b (patch)
tree0104271019dbfcd5ffb3145ac3332ba1e813ff6f
parent7e2ebfcd40833f1cd28a40e341bbd665676803c9 (diff)
Remove extra revokeUriPermission call in FileSystemProvider
Currently, DocumentsProvider already handles the revokeUriPermission for the original Uri in the renameDocument case. Don't need to call revokeUriPermission in FileSystemProvider. It causes the new Uri to not be granted the original permissions. Flag: EXEMPT Bug fix Bug: 402270863 Test: Manual Change-Id: I53da748c3f9cf1fe0575692ccf313f6528b40e38
-rw-r--r--core/java/com/android/internal/content/FileSystemProvider.java11
-rw-r--r--packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java5
2 files changed, 11 insertions, 5 deletions
diff --git a/core/java/com/android/internal/content/FileSystemProvider.java b/core/java/com/android/internal/content/FileSystemProvider.java
index 0801dd8c0bd8..fc74a179f66e 100644
--- a/core/java/com/android/internal/content/FileSystemProvider.java
+++ b/core/java/com/android/internal/content/FileSystemProvider.java
@@ -119,7 +119,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
* Callback indicating that the given document has been deleted or moved. This gives
* the provider a hook to revoke the uri permissions.
*/
- protected void onDocIdDeleted(String docId) {
+ protected void onDocIdDeleted(String docId, boolean shouldRevokeUriPermission) {
// Default is no-op
}
@@ -292,7 +292,6 @@ public abstract class FileSystemProvider extends DocumentsProvider {
final String afterDocId = getDocIdForFile(after);
onDocIdChanged(docId);
- onDocIdDeleted(docId);
onDocIdChanged(afterDocId);
final File afterVisibleFile = getFileForDocId(afterDocId, true);
@@ -301,6 +300,10 @@ public abstract class FileSystemProvider extends DocumentsProvider {
updateMediaStore(getContext(), afterVisibleFile);
if (!TextUtils.equals(docId, afterDocId)) {
+ // DocumentsProvider handles the revoking / granting uri permission for the docId and
+ // the afterDocId in the renameDocument case. Don't need to call revokeUriPermission
+ // for the docId here.
+ onDocIdDeleted(docId, /* shouldRevokeUriPermission */ false);
return afterDocId;
} else {
return null;
@@ -324,7 +327,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
final String docId = getDocIdForFile(after);
onDocIdChanged(sourceDocumentId);
- onDocIdDeleted(sourceDocumentId);
+ onDocIdDeleted(sourceDocumentId, /* shouldRevokeUriPermission */ true);
onDocIdChanged(docId);
// update the database
updateMediaStore(getContext(), visibleFileBefore);
@@ -362,7 +365,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
}
onDocIdChanged(docId);
- onDocIdDeleted(docId);
+ onDocIdDeleted(docId, /* shouldRevokeUriPermission */ true);
updateMediaStore(getContext(), visibleFile);
}
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
index defbc1142adb..28b891ebc3c9 100644
--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -596,7 +596,10 @@ public class ExternalStorageProvider extends FileSystemProvider {
}
@Override
- protected void onDocIdDeleted(String docId) {
+ protected void onDocIdDeleted(String docId, boolean shouldRevokeUriPermission) {
+ if (!shouldRevokeUriPermission) {
+ return;
+ }
Uri uri = DocumentsContract.buildDocumentUri(AUTHORITY, docId);
getContext().revokeUriPermission(uri, ~0);
}