blob: 4658ba109d5f1c02011d6ae400261772961d9082 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
Scott Kennedy9f78f652015-03-01 15:29:25 -080019import android.annotation.Nullable;
Artur Satayeve23a0eb2019-12-10 17:47:52 +000020import android.compat.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.res.AssetFileDescriptor;
22import android.database.Cursor;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.net.Uri;
Mathew Inwood8c854f82018-09-14 12:35:36 +010024import android.os.Build;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080025import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.os.IBinder;
Jeff Browna7771df2012-05-07 20:06:46 -070027import android.os.ICancellationSignal;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.os.IInterface;
29import android.os.ParcelFileDescriptor;
Dmitri Plotnikovd55a3872020-01-16 17:00:02 -080030import android.os.RemoteCallback;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080031import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
33import java.io.FileNotFoundException;
Fred Quintana03d94902009-05-22 14:23:31 -070034import java.util.ArrayList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035
36/**
37 * The ipc interface to talk to a content provider.
38 * @hide
39 */
40public interface IContentProvider extends IInterface {
Philip P. Moltmann128b7032019-09-27 08:44:12 -070041 public Cursor query(String callingPkg, @Nullable String featureId, Uri url,
42 @Nullable String[] projection,
Steve McKayea93fe72016-12-02 11:35:35 -080043 @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal)
44 throws RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 public String getType(Uri url) throws RemoteException;
Dmitri Plotnikovd55a3872020-01-16 17:00:02 -080046
47 /**
48 * An oneway version of getType. The functionality is exactly the same, except that the
49 * call returns immediately, and the resulting type is returned when available via
50 * a binder callback.
51 */
52 void getTypeAsync(Uri uri, RemoteCallback callback) throws RemoteException;
53
Jeff Sharkey633a13e2018-12-07 12:00:45 -070054 @Deprecated
Philip P. Moltmann128b7032019-09-27 08:44:12 -070055 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
56 + "ContentProviderClient#insert(android.net.Uri, android.content.ContentValues)} "
57 + "instead")
58 public default Uri insert(String callingPkg, Uri url, ContentValues initialValues)
59 throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070060 return insert(callingPkg, null, url, initialValues, null);
Jeff Sharkey633a13e2018-12-07 12:00:45 -070061 }
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070062 public Uri insert(String callingPkg, String featureId, Uri url, ContentValues initialValues,
63 Bundle extras) throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -070064 @Deprecated
65 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
66 + "ContentProviderClient#bulkInsert(android.net.Uri, android.content.ContentValues[])"
67 + "} instead")
68 public default int bulkInsert(String callingPkg, Uri url, ContentValues[] initialValues)
69 throws RemoteException {
70 return bulkInsert(callingPkg, null, url, initialValues);
71 }
72 public int bulkInsert(String callingPkg, String featureId, Uri url,
73 ContentValues[] initialValues) throws RemoteException;
74 @Deprecated
75 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
76 + "ContentProviderClient#delete(android.net.Uri, java.lang.String, java.lang"
77 + ".String[])} instead")
78 public default int delete(String callingPkg, Uri url, String selection, String[] selectionArgs)
79 throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070080 return delete(callingPkg, null, url,
81 ContentResolver.createSqlQueryBundle(selection, selectionArgs));
Philip P. Moltmann128b7032019-09-27 08:44:12 -070082 }
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070083 public int delete(String callingPkg, String featureId, Uri url, Bundle extras)
84 throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -070085 @Deprecated
86 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
87 + "ContentProviderClient#update(android.net.Uri, android.content.ContentValues, java"
88 + ".lang.String, java.lang.String[])} instead")
89 public default int update(String callingPkg, Uri url, ContentValues values, String selection,
90 String[] selectionArgs) throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070091 return update(callingPkg, null, url, values,
92 ContentResolver.createSqlQueryBundle(selection, selectionArgs));
Philip P. Moltmann128b7032019-09-27 08:44:12 -070093 }
94 public int update(String callingPkg, String featureId, Uri url, ContentValues values,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070095 Bundle extras) throws RemoteException;
Jeff Sharkey633a13e2018-12-07 12:00:45 -070096
Philip P. Moltmann128b7032019-09-27 08:44:12 -070097 public ParcelFileDescriptor openFile(String callingPkg, @Nullable String featureId, Uri url,
98 String mode, ICancellationSignal signal, IBinder callerToken)
99 throws RemoteException, FileNotFoundException;
100
101 public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String featureId,
102 Uri url, String mode, ICancellationSignal signal)
103 throws RemoteException, FileNotFoundException;
104
105 public ContentProviderResult[] applyBatch(String callingPkg, @Nullable String featureId,
106 String authority, ArrayList<ContentProviderOperation> operations)
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700107 throws RemoteException, OperationApplicationException;
108
109 @Deprecated
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700110 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
111 + "ContentProviderClient#call(java.lang.String, java.lang.String, android.os.Bundle)} "
112 + "instead")
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700113 public default Bundle call(String callingPkg, String method,
114 @Nullable String arg, @Nullable Bundle extras) throws RemoteException {
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700115 return call(callingPkg, null, "unknown", method, arg, extras);
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700116 }
117
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700118 public Bundle call(String callingPkg, @Nullable String featureId, String authority,
119 String method, @Nullable String arg, @Nullable Bundle extras) throws RemoteException;
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700120
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700121 public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid,
122 int modeFlags) throws RemoteException;
Jeff Sharkey9edef252019-05-20 14:00:17 -0600123
Jeff Brown4c1241d2012-02-02 17:05:00 -0800124 public ICancellationSignal createCancellationSignal() throws RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800125
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700126 public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri)
127 throws RemoteException;
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700128
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700129 public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri)
130 throws RemoteException;
131
132 public boolean refresh(String callingPkg, @Nullable String featureId, Uri url,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -0700133 @Nullable Bundle extras, ICancellationSignal cancellationSignal) throws RemoteException;
Ben Lin1cf454f2016-11-10 13:50:54 -0800134
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700135 // Data interchange.
136 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700137
138 public AssetFileDescriptor openTypedAssetFile(String callingPkg, @Nullable String featureId,
139 Uri url, String mimeType, Bundle opts, ICancellationSignal signal)
140 throws RemoteException, FileNotFoundException;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700141
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800142 /* IPC constants */
Mathew Inwood8c854f82018-09-14 12:35:36 +0100143 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800144 static final String descriptor = "android.content.IContentProvider";
145
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100146 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 static final int QUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
148 static final int GET_TYPE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
149 static final int INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;
150 static final int DELETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;
151 static final int UPDATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 9;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800152 static final int BULK_INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 12;
153 static final int OPEN_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 13;
154 static final int OPEN_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 14;
Fred Quintana89437372009-05-15 15:10:40 -0700155 static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -0800156 static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700157 static final int GET_STREAM_TYPES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 21;
158 static final int OPEN_TYPED_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 22;
Jeff Brown75ea64f2012-01-25 19:37:13 -0800159 static final int CREATE_CANCELATION_SIGNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 23;
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700160 static final int CANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 24;
161 static final int UNCANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 25;
Ben Lin1cf454f2016-11-10 13:50:54 -0800162 static final int REFRESH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 26;
Jeff Sharkey9edef252019-05-20 14:00:17 -0600163 static final int CHECK_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 27;
Dmitri Plotnikovd55a3872020-01-16 17:00:02 -0800164 int GET_TYPE_ASYNC_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 28;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800165}