Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.test.mock; |
| 18 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 20 | import android.content.ContentProviderOperation; |
| 21 | import android.content.ContentProviderResult; |
| 22 | import android.content.ContentValues; |
| 23 | import android.content.EntityIterator; |
| 24 | import android.content.IContentProvider; |
| 25 | import android.content.res.AssetFileDescriptor; |
| 26 | import android.database.Cursor; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 27 | import android.net.Uri; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 29 | import android.os.IBinder; |
Jeff Brown | a7771df | 2012-05-07 20:06:46 -0700 | [diff] [blame] | 30 | import android.os.ICancellationSignal; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 31 | import android.os.ParcelFileDescriptor; |
| 32 | import android.os.RemoteException; |
| 33 | |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 34 | import java.io.FileNotFoundException; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 35 | import java.util.ArrayList; |
| 36 | |
| 37 | /** |
| 38 | * Mock implementation of IContentProvider. All methods are non-functional and throw |
| 39 | * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to |
| 40 | * implement behavior needed for tests. |
| 41 | * |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 42 | * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden. |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 43 | */ |
| 44 | public class MockIContentProvider implements IContentProvider { |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 45 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 46 | public int bulkInsert(String callingPackage, @Nullable String featureId, Uri url, |
| 47 | ContentValues[] initialValues) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 48 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 49 | } |
| 50 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 51 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 52 | @SuppressWarnings("unused") |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 53 | public int delete(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 54 | Bundle extras) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 55 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 56 | } |
| 57 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 58 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 59 | public String getType(Uri url) { |
| 60 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 61 | } |
| 62 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 63 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 64 | @SuppressWarnings("unused") |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 65 | public Uri insert(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 66 | ContentValues initialValues, Bundle extras) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 67 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 68 | } |
| 69 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 70 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 71 | public ParcelFileDescriptor openFile(String callingPackage, @Nullable String featureId, |
| 72 | Uri url, String mode, ICancellationSignal signal, IBinder callerToken) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 73 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 74 | } |
| 75 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 76 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 77 | public AssetFileDescriptor openAssetFile(String callingPackage, @Nullable String featureId, |
| 78 | Uri uri, String mode, ICancellationSignal signal) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 79 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 80 | } |
| 81 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 82 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 83 | public ContentProviderResult[] applyBatch(String callingPackage, @Nullable String featureId, |
| 84 | String authority, ArrayList<ContentProviderOperation> operations) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 85 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 86 | } |
| 87 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 88 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 89 | public Cursor query(String callingPackage, @Nullable String featureId, Uri url, |
| 90 | @Nullable String[] projection, @Nullable Bundle queryArgs, |
| 91 | @Nullable ICancellationSignal cancellationSignal) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 92 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 93 | } |
| 94 | |
| 95 | public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, |
| 96 | String sortOrder) { |
| 97 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 98 | } |
| 99 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 100 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 101 | public int update(String callingPackage, @Nullable String featureId, Uri url, |
Jeff Sharkey | e9fe152 | 2019-11-15 12:45:15 -0700 | [diff] [blame] | 102 | ContentValues values, Bundle extras) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 103 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 104 | } |
| 105 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 106 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 107 | public Bundle call(String callingPackage, @Nullable String featureId, String authority, |
| 108 | String method, String request, Bundle args) throws RemoteException { |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 109 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 110 | } |
| 111 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 112 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 113 | public IBinder asBinder() { |
| 114 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 115 | } |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 116 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 117 | @Override |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 118 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { |
| 119 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 120 | } |
| 121 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 122 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 123 | public AssetFileDescriptor openTypedAssetFile(String callingPackage, |
| 124 | @Nullable String featureId, Uri url, String mimeType, Bundle opts, |
| 125 | ICancellationSignal signal) throws RemoteException, FileNotFoundException { |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 126 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 127 | } |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 128 | |
| 129 | @Override |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 130 | public ICancellationSignal createCancellationSignal() throws RemoteException { |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 131 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 132 | } |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 133 | |
| 134 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 135 | public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) |
| 136 | throws RemoteException { |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 137 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 138 | } |
| 139 | |
| 140 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 141 | public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri) |
| 142 | throws RemoteException { |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 143 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 144 | } |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 145 | |
| 146 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 147 | public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, Bundle args, |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 148 | ICancellationSignal cancellationSignal) throws RemoteException { |
| 149 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 150 | } |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 151 | |
| 152 | /** {@hide} */ |
| 153 | @Override |
Philip P. Moltmann | 128b703 | 2019-09-27 08:44:12 -0700 | [diff] [blame] | 154 | public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid, |
| 155 | int modeFlags) { |
Jeff Sharkey | 9edef25 | 2019-05-20 14:00:17 -0600 | [diff] [blame] | 156 | throw new UnsupportedOperationException("unimplemented mock method call"); |
| 157 | } |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 158 | } |