1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.content;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.res.AssetFileDescriptor;
22 import android.database.Cursor;
23 import android.net.Uri;
24 import android.os.Bundle;
25 import android.os.CancellationSignal;
26 import android.os.ParcelFileDescriptor;
27 import android.os.RemoteException;
28 
29 import java.io.FileNotFoundException;
30 import java.util.ArrayList;
31 
32 /**
33  * Interface representing calls that can be made to {@link ContentProvider}
34  * instances.
35  * <p>
36  * These methods have been extracted into a general interface so that APIs can
37  * be flexible in accepting either a {@link ContentProvider}, a
38  * {@link ContentResolver}, or a {@link ContentProviderClient}.
39  *
40  * @hide
41  */
42 public interface ContentInterface {
query(@onNull Uri uri, @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)43     public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
44             @Nullable Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)
45             throws RemoteException;
46 
getType(@onNull Uri uri)47     public @Nullable String getType(@NonNull Uri uri) throws RemoteException;
48 
getStreamTypes(@onNull Uri uri, @NonNull String mimeTypeFilter)49     public @Nullable String[] getStreamTypes(@NonNull Uri uri, @NonNull String mimeTypeFilter)
50             throws RemoteException;
51 
canonicalize(@onNull Uri uri)52     public @Nullable Uri canonicalize(@NonNull Uri uri) throws RemoteException;
53 
uncanonicalize(@onNull Uri uri)54     public @Nullable Uri uncanonicalize(@NonNull Uri uri) throws RemoteException;
55 
refresh(@onNull Uri uri, @Nullable Bundle extras, @Nullable CancellationSignal cancellationSignal)56     public boolean refresh(@NonNull Uri uri, @Nullable Bundle extras,
57             @Nullable CancellationSignal cancellationSignal) throws RemoteException;
58 
checkUriPermission(@onNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags)59     public int checkUriPermission(@NonNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags)
60             throws RemoteException;
61 
insert(@onNull Uri uri, @Nullable ContentValues initialValues, @Nullable Bundle extras)62     public @Nullable Uri insert(@NonNull Uri uri, @Nullable ContentValues initialValues,
63             @Nullable Bundle extras) throws RemoteException;
64 
bulkInsert(@onNull Uri uri, @NonNull ContentValues[] initialValues)65     public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] initialValues)
66             throws RemoteException;
67 
delete(@onNull Uri uri, @Nullable Bundle extras)68     public int delete(@NonNull Uri uri, @Nullable Bundle extras) throws RemoteException;
69 
update(@onNull Uri uri, @Nullable ContentValues values, @Nullable Bundle extras)70     public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable Bundle extras)
71             throws RemoteException;
72 
openFile(@onNull Uri uri, @NonNull String mode, @Nullable CancellationSignal signal)73     public @Nullable ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode,
74             @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException;
75 
openAssetFile(@onNull Uri uri, @NonNull String mode, @Nullable CancellationSignal signal)76     public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri uri, @NonNull String mode,
77             @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException;
78 
openTypedAssetFile(@onNull Uri uri, @NonNull String mimeTypeFilter, @Nullable Bundle opts, @Nullable CancellationSignal signal)79     public @Nullable AssetFileDescriptor openTypedAssetFile(@NonNull Uri uri,
80             @NonNull String mimeTypeFilter, @Nullable Bundle opts,
81             @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException;
82 
applyBatch(@onNull String authority, @NonNull ArrayList<ContentProviderOperation> operations)83     public @NonNull ContentProviderResult[] applyBatch(@NonNull String authority,
84             @NonNull ArrayList<ContentProviderOperation> operations)
85             throws RemoteException, OperationApplicationException;
86 
call(@onNull String authority, @NonNull String method, @Nullable String arg, @Nullable Bundle extras)87     public @Nullable Bundle call(@NonNull String authority, @NonNull String method,
88             @Nullable String arg, @Nullable Bundle extras) throws RemoteException;
89 }
90