1 /*
2  * Copyright (C) 2006 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.Nullable;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.content.res.AssetFileDescriptor;
22 import android.database.Cursor;
23 import android.net.Uri;
24 import android.os.Build;
25 import android.os.Bundle;
26 import android.os.IBinder;
27 import android.os.ICancellationSignal;
28 import android.os.IInterface;
29 import android.os.ParcelFileDescriptor;
30 import android.os.RemoteException;
31 
32 import java.io.FileNotFoundException;
33 import java.util.ArrayList;
34 
35 /**
36  * The ipc interface to talk to a content provider.
37  * @hide
38  */
39 public interface IContentProvider extends IInterface {
query(String callingPkg, Uri url, @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal)40     public Cursor query(String callingPkg, Uri url, @Nullable String[] projection,
41             @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal)
42             throws RemoteException;
getType(Uri url)43     public String getType(Uri url) throws RemoteException;
44     @UnsupportedAppUsage
insert(String callingPkg, Uri url, ContentValues initialValues)45     public Uri insert(String callingPkg, Uri url, ContentValues initialValues)
46             throws RemoteException;
47     @UnsupportedAppUsage
bulkInsert(String callingPkg, Uri url, ContentValues[] initialValues)48     public int bulkInsert(String callingPkg, Uri url, ContentValues[] initialValues)
49             throws RemoteException;
50     @UnsupportedAppUsage
delete(String callingPkg, Uri url, String selection, String[] selectionArgs)51     public int delete(String callingPkg, Uri url, String selection, String[] selectionArgs)
52             throws RemoteException;
53     @UnsupportedAppUsage
update(String callingPkg, Uri url, ContentValues values, String selection, String[] selectionArgs)54     public int update(String callingPkg, Uri url, ContentValues values, String selection,
55             String[] selectionArgs) throws RemoteException;
openFile( String callingPkg, Uri url, String mode, ICancellationSignal signal, IBinder callerToken)56     public ParcelFileDescriptor openFile(
57             String callingPkg, Uri url, String mode, ICancellationSignal signal,
58             IBinder callerToken)
59             throws RemoteException, FileNotFoundException;
openAssetFile( String callingPkg, Uri url, String mode, ICancellationSignal signal)60     public AssetFileDescriptor openAssetFile(
61             String callingPkg, Uri url, String mode, ICancellationSignal signal)
62             throws RemoteException, FileNotFoundException;
63 
64     @Deprecated
applyBatch(String callingPkg, ArrayList<ContentProviderOperation> operations)65     public default ContentProviderResult[] applyBatch(String callingPkg,
66             ArrayList<ContentProviderOperation> operations)
67                     throws RemoteException, OperationApplicationException {
68         return applyBatch(callingPkg, "unknown", operations);
69     }
70 
applyBatch(String callingPkg, String authority, ArrayList<ContentProviderOperation> operations)71     public ContentProviderResult[] applyBatch(String callingPkg, String authority,
72             ArrayList<ContentProviderOperation> operations)
73             throws RemoteException, OperationApplicationException;
74 
75     @Deprecated
76     @UnsupportedAppUsage
call(String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras)77     public default Bundle call(String callingPkg, String method,
78             @Nullable String arg, @Nullable Bundle extras) throws RemoteException {
79         return call(callingPkg, "unknown", method, arg, extras);
80     }
81 
call(String callingPkg, String authority, String method, @Nullable String arg, @Nullable Bundle extras)82     public Bundle call(String callingPkg, String authority, String method,
83             @Nullable String arg, @Nullable Bundle extras) throws RemoteException;
84 
createCancellationSignal()85     public ICancellationSignal createCancellationSignal() throws RemoteException;
86 
canonicalize(String callingPkg, Uri uri)87     public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException;
uncanonicalize(String callingPkg, Uri uri)88     public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException;
89 
refresh(String callingPkg, Uri url, @Nullable Bundle args, ICancellationSignal cancellationSignal)90     public boolean refresh(String callingPkg, Uri url, @Nullable Bundle args,
91             ICancellationSignal cancellationSignal) throws RemoteException;
92 
93     // Data interchange.
getStreamTypes(Uri url, String mimeTypeFilter)94     public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException;
openTypedAssetFile(String callingPkg, Uri url, String mimeType, Bundle opts, ICancellationSignal signal)95     public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri url, String mimeType,
96             Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException;
97 
98     /* IPC constants */
99     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
100     static final String descriptor = "android.content.IContentProvider";
101 
102     @UnsupportedAppUsage
103     static final int QUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
104     static final int GET_TYPE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
105     static final int INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;
106     static final int DELETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;
107     static final int UPDATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 9;
108     static final int BULK_INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 12;
109     static final int OPEN_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 13;
110     static final int OPEN_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 14;
111     static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19;
112     static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20;
113     static final int GET_STREAM_TYPES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 21;
114     static final int OPEN_TYPED_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 22;
115     static final int CREATE_CANCELATION_SIGNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 23;
116     static final int CANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 24;
117     static final int UNCANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 25;
118     static final int REFRESH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 26;
119 }
120