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

Commit c0c15697 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revoke the uri permission when the file is deleted" into rvc-qpr-dev am: 0827205f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12455088

Change-Id: I4d9259997d3095cafcd3a981ba9d1c1b4dc1daab
parents 3c117830 0827205f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -113,6 +113,14 @@ public abstract class FileSystemProvider extends DocumentsProvider {
        // Default is no-op
    }

    /**
     * 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) {
        // Default is no-op
    }

    @Override
    public boolean onCreate() {
        throw new UnsupportedOperationException(
@@ -283,6 +291,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {

        final String afterDocId = getDocIdForFile(after);
        onDocIdChanged(docId);
        onDocIdDeleted(docId);
        onDocIdChanged(afterDocId);

        final File afterVisibleFile = getFileForDocId(afterDocId, true);
@@ -312,6 +321,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {

        final String docId = getDocIdForFile(after);
        onDocIdChanged(sourceDocumentId);
        onDocIdDeleted(sourceDocumentId);
        onDocIdChanged(docId);
        moveInMediaStore(visibleFileBefore, getFileForDocId(docId, true));

@@ -343,6 +353,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
        }

        onDocIdChanged(docId);
        onDocIdDeleted(docId);
        removeFromMediaStore(visibleFile);
    }

+7 −0
Original line number Diff line number Diff line
@@ -482,6 +482,13 @@ public class ExternalStorageProvider extends FileSystemProvider {
        }
    }

    @Override
    protected void onDocIdDeleted(String docId) {
        Uri uri = DocumentsContract.buildDocumentUri(AUTHORITY, docId);
        getContext().revokeUriPermission(uri, ~0);
    }


    @Override
    public Cursor queryRoots(String[] projection) throws FileNotFoundException {
        final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));