blob: 6f477ff17c6716d435b71c395c83105c0e1f67f2 [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;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080030import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031
32import java.io.FileNotFoundException;
Fred Quintana03d94902009-05-22 14:23:31 -070033import java.util.ArrayList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034
35/**
36 * The ipc interface to talk to a content provider.
37 * @hide
38 */
39public interface IContentProvider extends IInterface {
Philip P. Moltmann128b7032019-09-27 08:44:12 -070040 public Cursor query(String callingPkg, @Nullable String featureId, Uri url,
41 @Nullable String[] projection,
Steve McKayea93fe72016-12-02 11:35:35 -080042 @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal)
43 throws RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044 public String getType(Uri url) throws RemoteException;
Jeff Sharkey633a13e2018-12-07 12:00:45 -070045 @Deprecated
Philip P. Moltmann128b7032019-09-27 08:44:12 -070046 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
47 + "ContentProviderClient#insert(android.net.Uri, android.content.ContentValues)} "
48 + "instead")
49 public default Uri insert(String callingPkg, Uri url, ContentValues initialValues)
50 throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070051 return insert(callingPkg, null, url, initialValues, null);
Jeff Sharkey633a13e2018-12-07 12:00:45 -070052 }
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070053 public Uri insert(String callingPkg, String featureId, Uri url, ContentValues initialValues,
54 Bundle extras) throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -070055 @Deprecated
56 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
57 + "ContentProviderClient#bulkInsert(android.net.Uri, android.content.ContentValues[])"
58 + "} instead")
59 public default int bulkInsert(String callingPkg, Uri url, ContentValues[] initialValues)
60 throws RemoteException {
61 return bulkInsert(callingPkg, null, url, initialValues);
62 }
63 public int bulkInsert(String callingPkg, String featureId, Uri url,
64 ContentValues[] initialValues) throws RemoteException;
65 @Deprecated
66 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
67 + "ContentProviderClient#delete(android.net.Uri, java.lang.String, java.lang"
68 + ".String[])} instead")
69 public default int delete(String callingPkg, Uri url, String selection, String[] selectionArgs)
70 throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070071 return delete(callingPkg, null, url,
72 ContentResolver.createSqlQueryBundle(selection, selectionArgs));
Philip P. Moltmann128b7032019-09-27 08:44:12 -070073 }
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070074 public int delete(String callingPkg, String featureId, Uri url, Bundle extras)
75 throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -070076 @Deprecated
77 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
78 + "ContentProviderClient#update(android.net.Uri, android.content.ContentValues, java"
79 + ".lang.String, java.lang.String[])} instead")
80 public default int update(String callingPkg, Uri url, ContentValues values, String selection,
81 String[] selectionArgs) throws RemoteException {
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070082 return update(callingPkg, null, url, values,
83 ContentResolver.createSqlQueryBundle(selection, selectionArgs));
Philip P. Moltmann128b7032019-09-27 08:44:12 -070084 }
85 public int update(String callingPkg, String featureId, Uri url, ContentValues values,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070086 Bundle extras) throws RemoteException;
Jeff Sharkey633a13e2018-12-07 12:00:45 -070087
Philip P. Moltmann128b7032019-09-27 08:44:12 -070088 public ParcelFileDescriptor openFile(String callingPkg, @Nullable String featureId, Uri url,
89 String mode, ICancellationSignal signal, IBinder callerToken)
90 throws RemoteException, FileNotFoundException;
91
92 public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String featureId,
93 Uri url, String mode, ICancellationSignal signal)
94 throws RemoteException, FileNotFoundException;
95
96 public ContentProviderResult[] applyBatch(String callingPkg, @Nullable String featureId,
97 String authority, ArrayList<ContentProviderOperation> operations)
Jeff Sharkey633a13e2018-12-07 12:00:45 -070098 throws RemoteException, OperationApplicationException;
99
100 @Deprecated
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700101 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link "
102 + "ContentProviderClient#call(java.lang.String, java.lang.String, android.os.Bundle)} "
103 + "instead")
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700104 public default Bundle call(String callingPkg, String method,
105 @Nullable String arg, @Nullable Bundle extras) throws RemoteException {
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700106 return call(callingPkg, null, "unknown", method, arg, extras);
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700107 }
108
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700109 public Bundle call(String callingPkg, @Nullable String featureId, String authority,
110 String method, @Nullable String arg, @Nullable Bundle extras) throws RemoteException;
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700111
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700112 public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid,
113 int modeFlags) throws RemoteException;
Jeff Sharkey9edef252019-05-20 14:00:17 -0600114
Jeff Brown4c1241d2012-02-02 17:05:00 -0800115 public ICancellationSignal createCancellationSignal() throws RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700117 public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri)
118 throws RemoteException;
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700119
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700120 public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri)
121 throws RemoteException;
122
123 public boolean refresh(String callingPkg, @Nullable String featureId, Uri url,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -0700124 @Nullable Bundle extras, ICancellationSignal cancellationSignal) throws RemoteException;
Ben Lin1cf454f2016-11-10 13:50:54 -0800125
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700126 // Data interchange.
127 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException;
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700128
129 public AssetFileDescriptor openTypedAssetFile(String callingPkg, @Nullable String featureId,
130 Uri url, String mimeType, Bundle opts, ICancellationSignal signal)
131 throws RemoteException, FileNotFoundException;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700132
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800133 /* IPC constants */
Mathew Inwood8c854f82018-09-14 12:35:36 +0100134 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800135 static final String descriptor = "android.content.IContentProvider";
136
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100137 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 static final int QUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
139 static final int GET_TYPE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
140 static final int INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;
141 static final int DELETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;
142 static final int UPDATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 9;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800143 static final int BULK_INSERT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 12;
144 static final int OPEN_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 13;
145 static final int OPEN_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 14;
Fred Quintana89437372009-05-15 15:10:40 -0700146 static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -0800147 static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700148 static final int GET_STREAM_TYPES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 21;
149 static final int OPEN_TYPED_ASSET_FILE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 22;
Jeff Brown75ea64f2012-01-25 19:37:13 -0800150 static final int CREATE_CANCELATION_SIGNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 23;
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700151 static final int CANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 24;
152 static final int UNCANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 25;
Ben Lin1cf454f2016-11-10 13:50:54 -0800153 static final int REFRESH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 26;
Jeff Sharkey9edef252019-05-20 14:00:17 -0600154 static final int CHECK_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 27;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155}