Merge "Revoke the uri permission when the file is deleted" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9064940495
@@ -87,6 +87,14 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
|||||||
|
|
||||||
protected abstract Uri buildNotificationUri(String docId);
|
protected abstract Uri buildNotificationUri(String docId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
@@ -221,6 +229,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String afterDocId = getDocIdForFile(after);
|
final String afterDocId = getDocIdForFile(after);
|
||||||
|
onDocIdDeleted(docId);
|
||||||
moveInMediaStore(visibleFileBefore, getFileForDocId(afterDocId, true));
|
moveInMediaStore(visibleFileBefore, getFileForDocId(afterDocId, true));
|
||||||
|
|
||||||
if (!TextUtils.equals(docId, afterDocId)) {
|
if (!TextUtils.equals(docId, afterDocId)) {
|
||||||
@@ -246,6 +255,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String docId = getDocIdForFile(after);
|
final String docId = getDocIdForFile(after);
|
||||||
|
onDocIdDeleted(sourceDocumentId);
|
||||||
moveInMediaStore(visibleFileBefore, getFileForDocId(docId, true));
|
moveInMediaStore(visibleFileBefore, getFileForDocId(docId, true));
|
||||||
|
|
||||||
return docId;
|
return docId;
|
||||||
@@ -295,6 +305,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
|||||||
throw new IllegalStateException("Failed to delete " + file);
|
throw new IllegalStateException("Failed to delete " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDocIdDeleted(docId);
|
||||||
removeFromMediaStore(visibleFile, isDirectory);
|
removeFromMediaStore(visibleFile, isDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -384,6 +384,12 @@ public class ExternalStorageProvider extends FileSystemProvider {
|
|||||||
return DocumentsContract.buildChildDocumentsUri(AUTHORITY, docId);
|
return DocumentsContract.buildChildDocumentsUri(AUTHORITY, docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDocIdDeleted(String docId) {
|
||||||
|
Uri uri = DocumentsContract.buildDocumentUri(AUTHORITY, docId);
|
||||||
|
getContext().revokeUriPermission(uri, ~0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
|
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
|
||||||
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
|
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
|
||||||
|
|||||||
Reference in New Issue
Block a user