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

Commit f81e11d5 authored by Ashish Kumar's avatar Ashish Kumar
Browse files

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
parent 8128beb1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+13 −0
Original line number Diff line number Diff line
@@ -978,6 +978,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