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

Commit 78c8bbdf 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 pi-dev am:...

Merge "Revoke the uri permission when the file is deleted" into pi-dev am: 2b52397d am: 9095b67c

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

Change-Id: Ic42474e16756dbd77c3a343ba1f7cbf95b2c10c8
parents 5a39301c 9095b67c
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -108,6 +108,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(
@@ -278,6 +286,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {

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

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

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

@@ -336,6 +346,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
        }

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

+6 −0
Original line number Diff line number Diff line
@@ -434,6 +434,12 @@ 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));