diff options
| author | 2023-03-01 14:34:42 +0000 | |
|---|---|---|
| committer | 2023-03-01 15:55:43 +0000 | |
| commit | f81e11d51ca758037198249178ae86d2fb7b3792 (patch) | |
| tree | ed84f4d4c07ae52920f6f712fecdbd114b7c0c1d | |
| parent | 8128beb12a6dea98700321a716d7e64105df6536 (diff) | |
Restricting DocumentsProvider#getType by implementing getTypeAnonymous
- getTypeAnonymous can be accessed by anyone. It does not reveal any sensitive information.
Bug: b/271262541
Test: build and manual test
Change-Id: I300a3be0904c44214f3ab206c30314855feaa57b
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/provider/DocumentsProvider.java | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index a7f69374ff00..600adde36063 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -36849,6 +36849,7 @@ package android.provider { method public String[] getDocumentStreamTypes(String, String); method public String getDocumentType(String) throws java.io.FileNotFoundException; method public final String getType(android.net.Uri); + method @Nullable public final String getTypeAnonymous(@NonNull android.net.Uri); method public final android.net.Uri insert(android.net.Uri, android.content.ContentValues); method public boolean isChildDocument(String, String); method public String moveDocument(String, String, String) throws java.io.FileNotFoundException; diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java index 07d500176fe5..5b527c70b4f7 100644 --- a/core/java/android/provider/DocumentsProvider.java +++ b/core/java/android/provider/DocumentsProvider.java @@ -979,6 +979,19 @@ public abstract class DocumentsProvider extends ContentProvider { } /** + * An unrestricted version of getType, which does not reveal sensitive information + */ + @Override + public final @Nullable String getTypeAnonymous(@NonNull Uri uri) { + switch (mMatcher.match(uri)) { + case MATCH_ROOT: + return DocumentsContract.Root.MIME_TYPE_ITEM; + default: + return null; + } + } + + /** * Implementation is provided by the parent class. Can be overridden to * provide additional functionality, but subclasses <em>must</em> always * call the superclass. If the superclass returns {@code null}, the subclass |