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
17package android.content;
18
19import android.content.res.AssetFileDescriptor;
20import android.database.Cursor;
21import android.net.Uri;
22import android.os.Bundle;
23import android.os.IBinder;
24import android.os.ICancellationSignal;
25import android.os.IInterface;
26import android.os.ParcelFileDescriptor;
27import android.os.RemoteException;
28
29import java.io.FileNotFoundException;
30import java.util.ArrayList;
31
32/**
33 * The ipc interface to talk to a content provider.
34 * @hide
35 */
36public interface IContentProvider extends IInterface {
37    public Cursor query(Uri url, String[] projection, String selection,
38            String[] selectionArgs, String sortOrder, ICancellationSignal cancellationSignal)
39                    throws RemoteException;
40    public String getType(Uri url) throws RemoteException;
41    public Uri insert(Uri url, ContentValues initialValues)
42            throws RemoteException;
43    public int bulkInsert(Uri url, ContentValues[] initialValues) throws RemoteException;
44    public int delete(Uri url, String selection, String[] selectionArgs)
45            throws RemoteException;
46    public int update(Uri url, ContentValues values, String selection,
47            String[] selectionArgs) throws RemoteException;
48    public ParcelFileDescriptor openFile(Uri url, String mode)
49            throws RemoteException, FileNotFoundException;
50    public AssetFileDescriptor openAssetFile(Uri url, String mode)
51            throws RemoteException, FileNotFoundException;
52    public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
53            throws RemoteException, OperationApplicationException;
54    public Bundle call(String method, String arg, Bundle extras) throws RemoteException;
55    public ICancellationSignal createCancellationSignal() throws RemoteException;
56
57    // Data interchange.
58    public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException;
59    public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
60            throws RemoteException, FileNotFoundException;
61
62    /* IPC constants */
63    static final String descriptor = "android.content.IContentProvider";
64
65    static final int QUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
66    static final int GET_TYPE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
67    static final int INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;
68    static final int DELETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;
69    static final int UPDATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 9;
70    static final int BULK_INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 12;
71    static final int OPEN_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 13;
72    static final int OPEN_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 14;
73    static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19;
74    static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20;
75    static final int GET_STREAM_TYPES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 21;
76    static final int OPEN_TYPED_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 22;
77    static final int CREATE_CANCELATION_SIGNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 23;
78}
79