blob: 464abfb1a5147fd533e59af291b7231764a85c4d [file] [log] [blame]
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +09001/*
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
17package android.test.mock;
18
Steve McKayea93fe72016-12-02 11:35:35 -080019import android.annotation.Nullable;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090020import android.content.ContentProviderOperation;
21import android.content.ContentProviderResult;
22import android.content.ContentValues;
23import android.content.EntityIterator;
24import android.content.IContentProvider;
25import android.content.res.AssetFileDescriptor;
26import android.database.Cursor;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090027import android.net.Uri;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080028import android.os.Bundle;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090029import android.os.IBinder;
Jeff Browna7771df2012-05-07 20:06:46 -070030import android.os.ICancellationSignal;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090031import android.os.ParcelFileDescriptor;
32import android.os.RemoteException;
33
Dianne Hackborn23fdaf62010-08-06 12:16:55 -070034import java.io.FileNotFoundException;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090035import 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 Fitzpatrick1877d012010-03-04 17:48:13 -080042 * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden.
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090043 */
44public class MockIContentProvider implements IContentProvider {
Steve McKayea93fe72016-12-02 11:35:35 -080045 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -070046 public int bulkInsert(String callingPackage, @Nullable String featureId, Uri url,
47 ContentValues[] initialValues) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090048 throw new UnsupportedOperationException("unimplemented mock method");
49 }
50
Steve McKayea93fe72016-12-02 11:35:35 -080051 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090052 @SuppressWarnings("unused")
Philip P. Moltmann128b7032019-09-27 08:44:12 -070053 public int delete(String callingPackage, @Nullable String featureId, Uri url,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070054 Bundle extras) throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090055 throw new UnsupportedOperationException("unimplemented mock method");
56 }
57
Steve McKayea93fe72016-12-02 11:35:35 -080058 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090059 public String getType(Uri url) {
60 throw new UnsupportedOperationException("unimplemented mock method");
61 }
62
Steve McKayea93fe72016-12-02 11:35:35 -080063 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090064 @SuppressWarnings("unused")
Philip P. Moltmann128b7032019-09-27 08:44:12 -070065 public Uri insert(String callingPackage, @Nullable String featureId, Uri url,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -070066 ContentValues initialValues, Bundle extras) throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090067 throw new UnsupportedOperationException("unimplemented mock method");
68 }
69
Steve McKayea93fe72016-12-02 11:35:35 -080070 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -070071 public ParcelFileDescriptor openFile(String callingPackage, @Nullable String featureId,
72 Uri url, String mode, ICancellationSignal signal, IBinder callerToken) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090073 throw new UnsupportedOperationException("unimplemented mock method");
74 }
75
Steve McKayea93fe72016-12-02 11:35:35 -080076 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -070077 public AssetFileDescriptor openAssetFile(String callingPackage, @Nullable String featureId,
78 Uri uri, String mode, ICancellationSignal signal) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090079 throw new UnsupportedOperationException("unimplemented mock method");
80 }
81
Steve McKayea93fe72016-12-02 11:35:35 -080082 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -070083 public ContentProviderResult[] applyBatch(String callingPackage, @Nullable String featureId,
84 String authority, ArrayList<ContentProviderOperation> operations) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090085 throw new UnsupportedOperationException("unimplemented mock method");
86 }
87
Steve McKayea93fe72016-12-02 11:35:35 -080088 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -070089 public Cursor query(String callingPackage, @Nullable String featureId, Uri url,
90 @Nullable String[] projection, @Nullable Bundle queryArgs,
91 @Nullable ICancellationSignal cancellationSignal) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090092 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 McKayea93fe72016-12-02 11:35:35 -0800100 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700101 public int update(String callingPackage, @Nullable String featureId, Uri url,
Jeff Sharkeye9fe1522019-11-15 12:45:15 -0700102 ContentValues values, Bundle extras) throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900103 throw new UnsupportedOperationException("unimplemented mock method");
104 }
105
Steve McKayea93fe72016-12-02 11:35:35 -0800106 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700107 public Bundle call(String callingPackage, @Nullable String featureId, String authority,
108 String method, String request, Bundle args) throws RemoteException {
Brad Fitzpatrick1877d012010-03-04 17:48:13 -0800109 throw new UnsupportedOperationException("unimplemented mock method");
110 }
111
Steve McKayea93fe72016-12-02 11:35:35 -0800112 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900113 public IBinder asBinder() {
114 throw new UnsupportedOperationException("unimplemented mock method");
115 }
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700116
Steve McKayea93fe72016-12-02 11:35:35 -0800117 @Override
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700118 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
119 throw new UnsupportedOperationException("unimplemented mock method");
120 }
121
Steve McKayea93fe72016-12-02 11:35:35 -0800122 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700123 public AssetFileDescriptor openTypedAssetFile(String callingPackage,
124 @Nullable String featureId, Uri url, String mimeType, Bundle opts,
125 ICancellationSignal signal) throws RemoteException, FileNotFoundException {
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700126 throw new UnsupportedOperationException("unimplemented mock method");
127 }
Jeff Brown75ea64f2012-01-25 19:37:13 -0800128
129 @Override
Jeff Brown4c1241d2012-02-02 17:05:00 -0800130 public ICancellationSignal createCancellationSignal() throws RemoteException {
Jeff Brown75ea64f2012-01-25 19:37:13 -0800131 throw new UnsupportedOperationException("unimplemented mock method");
132 }
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700133
134 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700135 public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri)
136 throws RemoteException {
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700137 throw new UnsupportedOperationException("unimplemented mock method");
138 }
139
140 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700141 public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri)
142 throws RemoteException {
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700143 throw new UnsupportedOperationException("unimplemented mock method");
144 }
Ben Lin1cf454f2016-11-10 13:50:54 -0800145
146 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700147 public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, Bundle args,
Ben Lin1cf454f2016-11-10 13:50:54 -0800148 ICancellationSignal cancellationSignal) throws RemoteException {
149 throw new UnsupportedOperationException("unimplemented mock method");
150 }
Jeff Sharkey9edef252019-05-20 14:00:17 -0600151
152 /** {@hide} */
153 @Override
Philip P. Moltmann128b7032019-09-27 08:44:12 -0700154 public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid,
155 int modeFlags) {
Jeff Sharkey9edef252019-05-20 14:00:17 -0600156 throw new UnsupportedOperationException("unimplemented mock method call");
157 }
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900158}