The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Scott Kennedy | 9f78f65 | 2015-03-01 15:29:25 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Artur Satayev | e23a0eb | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 20 | import android.compat.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.res.AssetFileDescriptor; |
| 22 | import android.database.Cursor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.net.Uri; |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 24 | import android.os.Build; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 25 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.os.IBinder; |
Jeff Brown | a7771df | 2012-05-07 20:06:46 -0700 | [diff] [blame] | 27 | import android.os.ICancellationSignal; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.os.IInterface; |
| 29 | import android.os.ParcelFileDescriptor; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 30 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
| 32 | import java.io.FileNotFoundException; |
Fred Quintana | 03d9490 | 2009-05-22 14:23:31 -0700 | [diff] [blame] | 33 | import java.util.ArrayList; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * The ipc interface to talk to a content provider. |
| 37 | * @hide |
| 38 | */ |
| 39 | public interface IContentProvider extends IInterface { |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 40 | public Cursor query(String callingPkg, @Nullable String featureId, Uri url, |
| 41 | @Nullable String[] projection, |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 42 | @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) |
| 43 | throws RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | public String getType(Uri url) throws RemoteException; |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 45 | @Deprecated |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 46 | @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 Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 51 | return insert(callingPkg, null, url, initialValues, null); |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 52 | } |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 53 | public Uri insert(String callingPkg, String featureId, Uri url, ContentValues initialValues, |
| 54 | Bundle extras) throws RemoteException; |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 55 | @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 Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 71 | return delete(callingPkg, null, url, |
| 72 | ContentResolver.createSqlQueryBundle(selection, selectionArgs)); |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 73 | } |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 74 | public int delete(String callingPkg, String featureId, Uri url, Bundle extras) |
| 75 | throws RemoteException; |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 76 | @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 Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 82 | return update(callingPkg, null, url, values, |
| 83 | ContentResolver.createSqlQueryBundle(selection, selectionArgs)); |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 84 | } |
| 85 | public int update(String callingPkg, String featureId, Uri url, ContentValues values, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 86 | Bundle extras) throws RemoteException; |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 87 | |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 88 | 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 Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 98 | throws RemoteException, OperationApplicationException; |
| 99 | |
| 100 | @Deprecated |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 101 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link " |
| 102 | + "ContentProviderClient#call(java.lang.String, java.lang.String, android.os.Bundle)} " |
| 103 | + "instead") |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 104 | public default Bundle call(String callingPkg, String method, |
| 105 | @Nullable String arg, @Nullable Bundle extras) throws RemoteException { |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 106 | return call(callingPkg, null, "unknown", method, arg, extras); |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 109 | public Bundle call(String callingPkg, @Nullable String featureId, String authority, |
| 110 | String method, @Nullable String arg, @Nullable Bundle extras) throws RemoteException; |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 111 | |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 112 | public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid, |
| 113 | int modeFlags) throws RemoteException; |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 114 | |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 115 | public ICancellationSignal createCancellationSignal() throws RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 117 | public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) |
| 118 | throws RemoteException; |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 119 | |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 120 | 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 Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 124 | @Nullable Bundle extras, ICancellationSignal cancellationSignal) throws RemoteException; |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 125 | |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 126 | // Data interchange. |
| 127 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException; |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 128 | |
| 129 | public AssetFileDescriptor openTypedAssetFile(String callingPkg, @Nullable String featureId, |
| 130 | Uri url, String mimeType, Bundle opts, ICancellationSignal signal) |
| 131 | throws RemoteException, FileNotFoundException; |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 132 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | /* IPC constants */ |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 134 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | static final String descriptor = "android.content.IContentProvider"; |
| 136 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 137 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | 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 Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 146 | static final int APPLY_BATCH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 19; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 147 | static final int CALL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 20; |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 148 | 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 Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 150 | static final int CREATE_CANCELATION_SIGNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 23; |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 151 | static final int CANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 24; |
| 152 | static final int UNCANONICALIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 25; |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 153 | static final int REFRESH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 26; |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 154 | static final int CHECK_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 27; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | } |