Merge "Revoke the uri permission when the file is deleted" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2b52397d56
@@ -93,6 +93,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(
|
||||
@@ -243,6 +251,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
|
||||
final String afterDocId = getDocIdForFile(after);
|
||||
onDocIdChanged(docId);
|
||||
onDocIdDeleted(docId);
|
||||
onDocIdChanged(afterDocId);
|
||||
|
||||
final File beforeVisibleFile = getFileForDocId(docId, true);
|
||||
@@ -274,6 +283,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
|
||||
final String docId = getDocIdForFile(after);
|
||||
onDocIdChanged(sourceDocumentId);
|
||||
onDocIdDeleted(sourceDocumentId);
|
||||
onDocIdChanged(docId);
|
||||
moveInMediaStore(visibleFileBefore, getFileForDocId(docId, true));
|
||||
|
||||
@@ -325,6 +335,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
}
|
||||
|
||||
onDocIdChanged(docId);
|
||||
onDocIdDeleted(docId);
|
||||
removeFromMediaStore(visibleFile, isDirectory);
|
||||
}
|
||||
|
||||
|
||||
@@ -430,6 +430,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));
|
||||
|
||||
Reference in New Issue
Block a user