blob: fc2a4644b9949170d5d087564580d7217db94113 [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
Dianne Hackborn35654b62013-01-14 17:38:02 -080046 public int bulkInsert(String callingPackage, Uri url, ContentValues[] initialValues) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090047 throw new UnsupportedOperationException("unimplemented mock method");
48 }
49
Steve McKayea93fe72016-12-02 11:35:35 -080050 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090051 @SuppressWarnings("unused")
Dianne Hackborn35654b62013-01-14 17:38:02 -080052 public int delete(String callingPackage, Uri url, String selection, String[] selectionArgs)
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090053 throws RemoteException {
54 throw new UnsupportedOperationException("unimplemented mock method");
55 }
56
Steve McKayea93fe72016-12-02 11:35:35 -080057 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090058 public String getType(Uri url) {
59 throw new UnsupportedOperationException("unimplemented mock method");
60 }
61
Steve McKayea93fe72016-12-02 11:35:35 -080062 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090063 @SuppressWarnings("unused")
Dianne Hackborn35654b62013-01-14 17:38:02 -080064 public Uri insert(String callingPackage, Uri url, ContentValues initialValues)
65 throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090066 throw new UnsupportedOperationException("unimplemented mock method");
67 }
68
Steve McKayea93fe72016-12-02 11:35:35 -080069 @Override
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070070 public ParcelFileDescriptor openFile(
Dianne Hackbornff170242014-11-19 10:59:01 -080071 String callingPackage, Uri url, String mode, ICancellationSignal signal,
72 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
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070077 public AssetFileDescriptor openAssetFile(
78 String callingPackage, 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
Jeff Sharkey633a13e2018-12-07 12:00:45 -070083 public ContentProviderResult[] applyBatch(String callingPackage, String authority,
Dianne Hackborn35654b62013-01-14 17:38:02 -080084 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
89 public Cursor query(String callingPackage, Uri url, @Nullable String[] projection,
90 @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090091 throw new UnsupportedOperationException("unimplemented mock method");
92 }
93
94 public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs,
95 String sortOrder) {
96 throw new UnsupportedOperationException("unimplemented mock method");
97 }
98
Steve McKayea93fe72016-12-02 11:35:35 -080099 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800100 public int update(String callingPackage, Uri url, ContentValues values, String selection,
101 String[] selectionArgs) throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900102 throw new UnsupportedOperationException("unimplemented mock method");
103 }
104
Steve McKayea93fe72016-12-02 11:35:35 -0800105 @Override
Jeff Sharkey633a13e2018-12-07 12:00:45 -0700106 public Bundle call(String callingPackage, String authority, String method, String request,
107 Bundle args) throws RemoteException {
Brad Fitzpatrick1877d012010-03-04 17:48:13 -0800108 throw new UnsupportedOperationException("unimplemented mock method");
109 }
110
Steve McKayea93fe72016-12-02 11:35:35 -0800111 @Override
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900112 public IBinder asBinder() {
113 throw new UnsupportedOperationException("unimplemented mock method");
114 }
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700115
Steve McKayea93fe72016-12-02 11:35:35 -0800116 @Override
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700117 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
118 throw new UnsupportedOperationException("unimplemented mock method");
119 }
120
Steve McKayea93fe72016-12-02 11:35:35 -0800121 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800122 public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType,
Jeff Sharkeybd3b9022013-08-20 15:20:04 -0700123 Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700124 throw new UnsupportedOperationException("unimplemented mock method");
125 }
Jeff Brown75ea64f2012-01-25 19:37:13 -0800126
127 @Override
Jeff Brown4c1241d2012-02-02 17:05:00 -0800128 public ICancellationSignal createCancellationSignal() throws RemoteException {
Jeff Brown75ea64f2012-01-25 19:37:13 -0800129 throw new UnsupportedOperationException("unimplemented mock method");
130 }
Dianne Hackborn38ed2a42013-09-06 16:17:22 -0700131
132 @Override
133 public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException {
134 throw new UnsupportedOperationException("unimplemented mock method");
135 }
136
137 @Override
138 public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException {
139 throw new UnsupportedOperationException("unimplemented mock method");
140 }
Ben Lin1cf454f2016-11-10 13:50:54 -0800141
142 @Override
143 public boolean refresh(String callingPkg, Uri url, Bundle args,
144 ICancellationSignal cancellationSignal) throws RemoteException {
145 throw new UnsupportedOperationException("unimplemented mock method");
146 }
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900147}