Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6a5f79c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove extra revokeUriPermission call in FileSystemProvider" into main

parents e88ceefb 8e636cc4
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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);
    }

+4 −1
Original line number Diff line number Diff line
@@ -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);
    }