IContentProvider.java revision 1877d0158b529663b8315482e7346a7bcaa96166
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.database.CursorWindow;
22import android.database.IBulkCursor;
23import android.database.IContentObserver;
24import android.net.Uri;
25import android.os.Bundle;
26import android.os.IBinder;
27import android.os.IInterface;
28import android.os.ParcelFileDescriptor;
29import android.os.RemoteException;
30
31import java.io.FileNotFoundException;
32import java.util.ArrayList;
33
34/**
35 * The ipc interface to talk to a content provider.
36 * @hide
37 */
38public interface IContentProvider extends IInterface {
39    /**
40     * @hide - hide this because return type IBulkCursor and parameter
41     * IContentObserver are system private classes.
42     */
43    public IBulkCursor bulkQuery(Uri url, String[] projection,
44            String selection, String[] selectionArgs, String sortOrder, IContentObserver observer,
45            CursorWindow window) throws RemoteException;
46    public Cursor query(Uri url, String[] projection, String selection,
47            String[] selectionArgs, String sortOrder) throws RemoteException;
48    public String getType(Uri url) throws RemoteException;
49    public Uri insert(Uri url, ContentValues initialValues)
50            throws RemoteException;
51    public int bulkInsert(Uri url, ContentValues[] initialValues) throws RemoteException;
52    public int delete(Uri url, String selection, String[] selectionArgs)
53            throws RemoteException;
54    public int update(Uri url, ContentValues values, String selection,
55            String[] selectionArgs) throws RemoteException;
56    public ParcelFileDescriptor openFile(Uri url, String mode)
57            throws RemoteException, FileNotFoundException;
58    public AssetFileDescriptor openAssetFile(Uri url, String mode)
59            throws RemoteException, FileNotFoundException;
60    public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
61            throws RemoteException, OperationApplicationException;
62    /**
63     * @hide -- until interface has proven itself
64     *
65     * Call an provider-defined method.  This can be used to implement
66     * interfaces that are cheaper than using a Cursor.
67     *
68     * @param method Method name to call.  Opaque to framework.
69     * @param request Nullable String argument passed to method.
70     * @param args Nullable Bundle argument passed to method.
71     */
72    public Bundle call(String method, String request, Bundle args) throws RemoteException;
73
74    /* IPC constants */
75    static final String descriptor = "android.content.IContentProvider";
76
77    static final int QUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
78    static final int GET_TYPE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
79    static final int INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;
80    static final int DELETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;
81    static final int UPDATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 9;
82    static final int BULK_INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 12;
83    static final int OPEN_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 13;
84    static final int OPEN_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 14;
85    static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19;
86    static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20;
87}
88