The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 2 | * Copyright (C) 2009 The Android Open Source Project |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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.test.mock; |
| 18 | |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 21 | import android.content.ContentProvider; |
Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 22 | import android.content.ContentProviderOperation; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 23 | import android.content.ContentProviderResult; |
| 24 | import android.content.ContentValues; |
| 25 | import android.content.Context; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 26 | import android.content.IContentProvider; |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 27 | import android.content.Intent; |
Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 28 | import android.content.OperationApplicationException; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 29 | import android.content.pm.PathPermission; |
| 30 | import android.content.pm.ProviderInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.content.res.AssetFileDescriptor; |
| 32 | import android.database.Cursor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.net.Uri; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 34 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | import android.os.IBinder; |
Jeff Brown | a7771df | 2012-05-07 20:06:46 -0700 | [diff] [blame] | 36 | import android.os.ICancellationSignal; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | import android.os.ParcelFileDescriptor; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 38 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
| 40 | import java.io.FileNotFoundException; |
Fred Quintana | 03d9490 | 2009-05-22 14:23:31 -0700 | [diff] [blame] | 41 | import java.util.ArrayList; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | |
| 43 | /** |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 44 | * Mock implementation of ContentProvider. All methods are non-functional and throw |
| 45 | * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | * implement behavior needed for tests. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | */ |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 48 | public class MockContentProvider extends ContentProvider { |
| 49 | /* |
| 50 | * Note: if you add methods to ContentProvider, you must add similar methods to |
| 51 | * MockContentProvider. |
| 52 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 54 | /** |
| 55 | * IContentProvider that directs all calls to this MockContentProvider. |
| 56 | */ |
| 57 | private class InversionIContentProvider implements IContentProvider { |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 58 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 59 | public ContentProviderResult[] applyBatch(String callingPackage, |
| 60 | @Nullable String featureId, String authority, |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 61 | ArrayList<ContentProviderOperation> operations) |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 62 | throws RemoteException, OperationApplicationException { |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 63 | return MockContentProvider.this.applyBatch(authority, operations); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 64 | } |
| 65 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 66 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 67 | public int bulkInsert(String callingPackage, @Nullable String featureId, Uri url, |
| 68 | ContentValues[] initialValues) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 69 | return MockContentProvider.this.bulkInsert(url, initialValues); |
| 70 | } |
| 71 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 72 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 73 | public int delete(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 74 | Bundle extras) throws RemoteException { |
| 75 | return MockContentProvider.this.delete(url, extras); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 76 | } |
| 77 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 78 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 79 | public String getType(Uri url) throws RemoteException { |
| 80 | return MockContentProvider.this.getType(url); |
| 81 | } |
| 82 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 83 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 84 | public Uri insert(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 85 | ContentValues initialValues, Bundle extras) throws RemoteException { |
| 86 | return MockContentProvider.this.insert(url, initialValues, extras); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 87 | } |
| 88 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 89 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 90 | public AssetFileDescriptor openAssetFile(String callingPackage, |
| 91 | @Nullable String featureId, Uri url, String mode, ICancellationSignal signal) |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 92 | throws RemoteException, FileNotFoundException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 93 | return MockContentProvider.this.openAssetFile(url, mode); |
| 94 | } |
| 95 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 96 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 97 | public ParcelFileDescriptor openFile(String callingPackage, @Nullable String featureId, |
| 98 | Uri url, String mode, ICancellationSignal signal, IBinder callerToken) |
| 99 | throws RemoteException, FileNotFoundException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 100 | return MockContentProvider.this.openFile(url, mode); |
| 101 | } |
| 102 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 103 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 104 | public Cursor query(String callingPackage, @Nullable String featureId, Uri url, |
| 105 | @Nullable String[] projection, @Nullable Bundle queryArgs, |
| 106 | @Nullable ICancellationSignal cancellationSignal) throws RemoteException { |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 107 | return MockContentProvider.this.query(url, projection, queryArgs, null); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 108 | } |
| 109 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 110 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 111 | public int update(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 112 | ContentValues values, Bundle extras) throws RemoteException { |
| 113 | return MockContentProvider.this.update(url, values, extras); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 114 | } |
| 115 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 116 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 117 | public Bundle call(String callingPackage, @Nullable String featureId, String authority, |
| 118 | String method, String request, Bundle args) throws RemoteException { |
Jeff Sharkey | 633a13e | 2018-12-07 12:00:45 -0700 | [diff] [blame] | 119 | return MockContentProvider.this.call(authority, method, request, args); |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 122 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 123 | public IBinder asBinder() { |
Sudheer Shanka | fe7668a | 2018-12-16 15:52:33 -0800 | [diff] [blame] | 124 | return MockContentProvider.this.getIContentProviderBinder(); |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 125 | } |
| 126 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 127 | @Override |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 128 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { |
| 129 | return MockContentProvider.this.getStreamTypes(url, mimeTypeFilter); |
| 130 | } |
| 131 | |
Jeff Brown | d218365 | 2011-10-09 12:39:53 -0700 | [diff] [blame] | 132 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 133 | public AssetFileDescriptor openTypedAssetFile(String callingPackage, |
| 134 | @Nullable String featureId, Uri url, String mimeType, Bundle opts, |
| 135 | ICancellationSignal signal) throws RemoteException, FileNotFoundException { |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 136 | return MockContentProvider.this.openTypedAssetFile(url, mimeType, opts); |
| 137 | } |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 138 | |
| 139 | @Override |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 140 | public ICancellationSignal createCancellationSignal() throws RemoteException { |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 141 | return null; |
| 142 | } |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 143 | |
| 144 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 145 | public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) |
| 146 | throws RemoteException { |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 147 | return MockContentProvider.this.canonicalize(uri); |
| 148 | } |
| 149 | |
| 150 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 151 | public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri) |
| 152 | throws RemoteException { |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 153 | return MockContentProvider.this.uncanonicalize(uri); |
| 154 | } |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 155 | |
| 156 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 157 | public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, |
| 158 | Bundle args, ICancellationSignal cancellationSignal) throws RemoteException { |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 159 | return MockContentProvider.this.refresh(url, args); |
| 160 | } |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 161 | |
| 162 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 163 | public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, |
| 164 | int uid, int modeFlags) { |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 165 | return MockContentProvider.this.checkUriPermission(uri, uid, modeFlags); |
| 166 | } |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 167 | } |
| 168 | private final InversionIContentProvider mIContentProvider = new InversionIContentProvider(); |
| 169 | |
| 170 | /** |
| 171 | * A constructor using {@link MockContext} instance as a Context in it. |
| 172 | */ |
| 173 | protected MockContentProvider() { |
| 174 | super(new MockContext(), "", "", null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | } |
| 176 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 177 | /** |
| 178 | * A constructor accepting a Context instance, which is supposed to be the subclasss of |
| 179 | * {@link MockContext}. |
| 180 | */ |
| 181 | public MockContentProvider(Context context) { |
| 182 | super(context, "", "", null); |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * A constructor which initialize four member variables which |
| 187 | * {@link android.content.ContentProvider} have internally. |
| 188 | * |
| 189 | * @param context A Context object which should be some mock instance (like the |
| 190 | * instance of {@link android.test.mock.MockContext}). |
| 191 | * @param readPermission The read permision you want this instance should have in the |
| 192 | * test, which is available via {@link #getReadPermission()}. |
| 193 | * @param writePermission The write permission you want this instance should have |
| 194 | * in the test, which is available via {@link #getWritePermission()}. |
| 195 | * @param pathPermissions The PathPermissions you want this instance should have |
| 196 | * in the test, which is available via {@link #getPathPermissions()}. |
| 197 | */ |
| 198 | public MockContentProvider(Context context, |
| 199 | String readPermission, |
| 200 | String writePermission, |
| 201 | PathPermission[] pathPermissions) { |
| 202 | super(context, readPermission, writePermission, pathPermissions); |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public int delete(Uri uri, String selection, String[] selectionArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 208 | } |
| 209 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 210 | @Override |
| 211 | public String getType(Uri uri) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 213 | } |
| 214 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 215 | @Override |
| 216 | public Uri insert(Uri uri, ContentValues values) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 217 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 218 | } |
| 219 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 220 | @Override |
| 221 | public boolean onCreate() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 223 | } |
| 224 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 225 | @Override |
| 226 | public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, |
| 227 | String sortOrder) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 228 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 229 | } |
| 230 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 231 | @Override |
| 232 | public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 233 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 234 | } |
Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 235 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 236 | /** |
| 237 | * If you're reluctant to implement this manually, please just call super.bulkInsert(). |
| 238 | */ |
| 239 | @Override |
| 240 | public int bulkInsert(Uri uri, ContentValues[] values) { |
Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 241 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 242 | } |
| 243 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 244 | @Override |
| 245 | public void attachInfo(Context context, ProviderInfo info) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 247 | } |
| 248 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 249 | @Override |
| 250 | public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) { |
| 251 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 252 | } |
| 253 | |
| 254 | /** |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 255 | * @hide |
| 256 | */ |
| 257 | @Override |
| 258 | public Bundle call(String method, String request, Bundle args) { |
| 259 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 260 | } |
| 261 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 262 | @Override |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 263 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) { |
| 264 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 265 | } |
| 266 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 267 | @Override |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 268 | public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts) { |
| 269 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 270 | } |
| 271 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 272 | /** |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 273 | * @hide |
| 274 | */ |
| 275 | public boolean refresh(Uri url, Bundle args) { |
| 276 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 277 | } |
| 278 | |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 279 | /** {@hide} */ |
| 280 | @Override |
| 281 | public int checkUriPermission(@NonNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags) { |
| 282 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 283 | } |
| 284 | |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 285 | /** |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 286 | * Returns IContentProvider which calls back same methods in this class. |
| 287 | * By overriding this class, we avoid the mechanism hidden behind ContentProvider |
| 288 | * (IPC, etc.) |
| 289 | * |
| 290 | * @hide |
| 291 | */ |
| 292 | @Override |
| 293 | public final IContentProvider getIContentProvider() { |
| 294 | return mIContentProvider; |
| 295 | } |
Paul Duffin | 772b692 | 2017-12-22 16:13:15 +0000 | [diff] [blame] | 296 | |
| 297 | /** |
Sudheer Shanka | fe7668a | 2018-12-16 15:52:33 -0800 | [diff] [blame] | 298 | * @hide |
| 299 | */ |
| 300 | public IBinder getIContentProviderBinder() { |
| 301 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 302 | } |
| 303 | |
| 304 | /** |
Paul Duffin | 772b692 | 2017-12-22 16:13:15 +0000 | [diff] [blame] | 305 | * Like {@link #attachInfo(Context, android.content.pm.ProviderInfo)}, but for use |
| 306 | * when directly instantiating the provider for testing. |
| 307 | * |
| 308 | * <p>Provided for use by {@code android.test.ProviderTestCase2} and |
| 309 | * {@code android.test.RenamingDelegatingContext}. |
| 310 | * |
| 311 | * @deprecated Use a mocking framework like <a href="https://github.com/mockito/mockito">Mockito</a>. |
| 312 | * New tests should be written using the |
| 313 | * <a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>. |
| 314 | */ |
| 315 | @Deprecated |
| 316 | public static void attachInfoForTesting( |
| 317 | ContentProvider provider, Context context, ProviderInfo providerInfo) { |
| 318 | provider.attachInfoForTesting(context, providerInfo); |
| 319 | } |
Fred Quintana | f99e2e0 | 2009-12-09 16:00:40 -0800 | [diff] [blame] | 320 | } |