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

Commit 6e412ada authored by Nicolas Prevot's avatar Nicolas Prevot
Browse files

Allowing a ContentProvider to have a null authority.

In this case, it will not be possible to query it with any uri.

BUG: 17414813

Change-Id: I76e8ad91539904f3c52b5a3436b2f1bd5e4d0fdf
parent 5f183f06
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -639,6 +639,7 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
     * @param authorities the semi-colon separated authorities of the ContentProvider.
     */
    protected final void setAuthorities(String authorities) {
        if (authorities != null) {
            if (authorities.indexOf(';') == -1) {
                mAuthority = authorities;
                mAuthorities = null;
@@ -647,16 +648,19 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
                mAuthorities = authorities.split(";");
            }
        }
    }

    /** @hide */
    protected final boolean matchesOurAuthorities(String authority) {
        if (mAuthority != null) {
            return mAuthority.equals(authority);
        }
        if (mAuthorities != null) {
            int length = mAuthorities.length;
            for (int i = 0; i < length; i++) {
                if (mAuthorities[i].equals(authority)) return true;
            }
        }
        return false;
    }