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

Commit c6a93462 authored by Pinyao Ting's avatar Pinyao Ting Committed by Android (Google) Code Review
Browse files

Merge "include a requireContext method for better kotlin inter-operability"

parents bdc3d07f 6dcd113c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9490,6 +9490,7 @@ package android.content {
    method @Nullable public android.database.Cursor query(@NonNull android.net.Uri, @Nullable String[], @Nullable String, @Nullable String[], @Nullable String, @Nullable android.os.CancellationSignal);
    method @Nullable public android.database.Cursor query(@NonNull android.net.Uri, @Nullable String[], @Nullable android.os.Bundle, @Nullable android.os.CancellationSignal);
    method public boolean refresh(android.net.Uri, @Nullable android.os.Bundle, @Nullable android.os.CancellationSignal);
    method @NonNull public final android.content.Context requireContext();
    method public final void restoreCallingIdentity(@NonNull android.content.ContentProvider.CallingIdentity);
    method protected final void setPathPermissions(@Nullable android.content.pm.PathPermission[]);
    method protected final void setReadPermission(@Nullable String);
+17 −0
Original line number Diff line number Diff line
@@ -833,6 +833,23 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
        return mContext;
    }

    /**
     * Retrieves a Non-Nullable Context this provider is running in, this is intended to be called
     * after {@link #onCreate}. When called before context was created, an IllegalStateException
     * will be thrown.
     * <p>
     * Note A provider must be declared in the manifest and created automatically by the system,
     * and context is only available after {@link #onCreate} is called.
     */
    @NonNull
    public final Context requireContext() {
        final Context ctx = getContext();
        if (ctx == null) {
            throw new IllegalStateException("Cannot find context from the provider.");
        }
        return ctx;
    }

    /**
     * Set the calling package, returning the current value (or {@code null})
     * which can be used later to restore the previous state.