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

Commit 8e636cc4 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

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
parent 7e2ebfcd
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);
    }