blob: 0ab3f1c6269ac48f49341196aacd3f5cd7a96282 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.content;
18
Jeff Sharkey110a6b62012-03-12 11:12:41 -070019import static android.content.pm.PackageManager.PERMISSION_GRANTED;
20
Dianne Hackborn35654b62013-01-14 17:38:02 -080021import android.app.AppOpsManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.pm.PackageManager;
Dianne Hackborn2af632f2009-07-08 14:56:37 -070023import android.content.pm.PathPermission;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.content.pm.ProviderInfo;
25import android.content.res.AssetFileDescriptor;
26import android.content.res.Configuration;
27import android.database.Cursor;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.database.SQLException;
29import android.net.Uri;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -070030import android.os.AsyncTask;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.os.Binder;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080032import android.os.Bundle;
Jeff Browna7771df2012-05-07 20:06:46 -070033import android.os.CancellationSignal;
34import android.os.ICancellationSignal;
35import android.os.OperationCanceledException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.os.ParcelFileDescriptor;
Dianne Hackborn2af632f2009-07-08 14:56:37 -070037import android.os.Process;
Jeff Brown75ea64f2012-01-25 19:37:13 -080038import android.os.RemoteException;
Dianne Hackbornf02b60a2012-08-16 10:48:27 -070039import android.os.UserHandle;
Vasu Nori0c9e14a2010-08-04 13:31:48 -070040import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041
42import java.io.File;
Marco Nelissen18cb2872011-11-15 11:19:53 -080043import java.io.FileDescriptor;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import java.io.FileNotFoundException;
Dianne Hackborn23fdaf62010-08-06 12:16:55 -070045import java.io.IOException;
Marco Nelissen18cb2872011-11-15 11:19:53 -080046import java.io.PrintWriter;
Fred Quintana03d94902009-05-22 14:23:31 -070047import java.util.ArrayList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048
49/**
50 * Content providers are one of the primary building blocks of Android applications, providing
51 * content to applications. They encapsulate data and provide it to applications through the single
52 * {@link ContentResolver} interface. A content provider is only required if you need to share
53 * data between multiple applications. For example, the contacts data is used by multiple
54 * applications and must be stored in a content provider. If you don't need to share data amongst
55 * multiple applications you can use a database directly via
56 * {@link android.database.sqlite.SQLiteDatabase}.
57 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058 * <p>When a request is made via
59 * a {@link ContentResolver} the system inspects the authority of the given URI and passes the
60 * request to the content provider registered with the authority. The content provider can interpret
61 * the rest of the URI however it wants. The {@link UriMatcher} class is helpful for parsing
62 * URIs.</p>
63 *
64 * <p>The primary methods that need to be implemented are:
65 * <ul>
Dan Egnor6fcc0f0732010-07-27 16:32:17 -070066 * <li>{@link #onCreate} which is called to initialize the provider</li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 * <li>{@link #query} which returns data to the caller</li>
68 * <li>{@link #insert} which inserts new data into the content provider</li>
69 * <li>{@link #update} which updates existing data in the content provider</li>
70 * <li>{@link #delete} which deletes data from the content provider</li>
71 * <li>{@link #getType} which returns the MIME type of data in the content provider</li>
72 * </ul></p>
73 *
Dan Egnor6fcc0f0732010-07-27 16:32:17 -070074 * <p class="caution">Data access methods (such as {@link #insert} and
75 * {@link #update}) may be called from many threads at once, and must be thread-safe.
76 * Other methods (such as {@link #onCreate}) are only called from the application
77 * main thread, and must avoid performing lengthy operations. See the method
78 * descriptions for their expected thread behavior.</p>
79 *
80 * <p>Requests to {@link ContentResolver} are automatically forwarded to the appropriate
81 * ContentProvider instance, so subclasses don't have to worry about the details of
82 * cross-process calls.</p>
Joe Fernandez558459f2011-10-13 16:47:36 -070083 *
84 * <div class="special reference">
85 * <h3>Developer Guides</h3>
86 * <p>For more information about using content providers, read the
87 * <a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>
88 * developer guide.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 */
Dianne Hackbornc68c9132011-07-29 01:25:18 -070090public abstract class ContentProvider implements ComponentCallbacks2 {
Vasu Nori0c9e14a2010-08-04 13:31:48 -070091 private static final String TAG = "ContentProvider";
92
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090093 /*
94 * Note: if you add methods to ContentProvider, you must add similar methods to
95 * MockContentProvider.
96 */
97
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 private Context mContext = null;
Dianne Hackborn2af632f2009-07-08 14:56:37 -070099 private int mMyUid;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 private String mReadPermission;
101 private String mWritePermission;
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700102 private PathPermission[] mPathPermissions;
Dianne Hackbornb424b632010-08-18 15:59:05 -0700103 private boolean mExported;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104
105 private Transport mTransport = new Transport();
106
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700107 /**
108 * Construct a ContentProvider instance. Content providers must be
109 * <a href="{@docRoot}guide/topics/manifest/provider-element.html">declared
110 * in the manifest</a>, accessed with {@link ContentResolver}, and created
111 * automatically by the system, so applications usually do not create
112 * ContentProvider instances directly.
113 *
114 * <p>At construction time, the object is uninitialized, and most fields and
115 * methods are unavailable. Subclasses should initialize themselves in
116 * {@link #onCreate}, not the constructor.
117 *
118 * <p>Content providers are created on the application main thread at
119 * application launch time. The constructor must not perform lengthy
120 * operations, or application startup will be delayed.
121 */
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900122 public ContentProvider() {
123 }
124
125 /**
126 * Constructor just for mocking.
127 *
128 * @param context A Context object which should be some mock instance (like the
129 * instance of {@link android.test.mock.MockContext}).
130 * @param readPermission The read permision you want this instance should have in the
131 * test, which is available via {@link #getReadPermission()}.
132 * @param writePermission The write permission you want this instance should have
133 * in the test, which is available via {@link #getWritePermission()}.
134 * @param pathPermissions The PathPermissions you want this instance should have
135 * in the test, which is available via {@link #getPathPermissions()}.
136 * @hide
137 */
138 public ContentProvider(
139 Context context,
140 String readPermission,
141 String writePermission,
142 PathPermission[] pathPermissions) {
143 mContext = context;
144 mReadPermission = readPermission;
145 mWritePermission = writePermission;
146 mPathPermissions = pathPermissions;
147 }
148
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149 /**
150 * Given an IContentProvider, try to coerce it back to the real
151 * ContentProvider object if it is running in the local process. This can
152 * be used if you know you are running in the same process as a provider,
153 * and want to get direct access to its implementation details. Most
154 * clients should not nor have a reason to use it.
155 *
156 * @param abstractInterface The ContentProvider interface that is to be
157 * coerced.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800158 * @return If the IContentProvider is non-{@code null} and local, returns its actual
159 * ContentProvider instance. Otherwise returns {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800160 * @hide
161 */
162 public static ContentProvider coerceToLocalContentProvider(
163 IContentProvider abstractInterface) {
164 if (abstractInterface instanceof Transport) {
165 return ((Transport)abstractInterface).getContentProvider();
166 }
167 return null;
168 }
169
170 /**
171 * Binder object that deals with remoting.
172 *
173 * @hide
174 */
175 class Transport extends ContentProviderNative {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800176 AppOpsManager mAppOpsManager = null;
Dianne Hackborn961321f2013-02-05 17:22:41 -0800177 int mReadOp = AppOpsManager.OP_NONE;
178 int mWriteOp = AppOpsManager.OP_NONE;
Dianne Hackborn35654b62013-01-14 17:38:02 -0800179
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800180 ContentProvider getContentProvider() {
181 return ContentProvider.this;
182 }
183
Jeff Brownd2183652011-10-09 12:39:53 -0700184 @Override
185 public String getProviderName() {
186 return getContentProvider().getClass().getName();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 }
188
Jeff Brown75ea64f2012-01-25 19:37:13 -0800189 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800190 public Cursor query(String callingPkg, Uri uri, String[] projection,
Jeff Brown75ea64f2012-01-25 19:37:13 -0800191 String selection, String[] selectionArgs, String sortOrder,
Jeff Brown4c1241d2012-02-02 17:05:00 -0800192 ICancellationSignal cancellationSignal) {
Dianne Hackborn5e45ee62013-01-24 19:13:44 -0800193 if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
Dianne Hackbornd7960d12013-01-29 18:55:48 -0800194 return rejectQuery(uri, projection, selection, selectionArgs, sortOrder,
195 CancellationSignal.fromTransport(cancellationSignal));
Dianne Hackborn5e45ee62013-01-24 19:13:44 -0800196 }
Jeff Brown75ea64f2012-01-25 19:37:13 -0800197 return ContentProvider.this.query(uri, projection, selection, selectionArgs, sortOrder,
Jeff Brown4c1241d2012-02-02 17:05:00 -0800198 CancellationSignal.fromTransport(cancellationSignal));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 }
200
Jeff Brown75ea64f2012-01-25 19:37:13 -0800201 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 public String getType(Uri uri) {
203 return ContentProvider.this.getType(uri);
204 }
205
Jeff Brown75ea64f2012-01-25 19:37:13 -0800206 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800207 public Uri insert(String callingPkg, Uri uri, ContentValues initialValues) {
Dianne Hackborn5e45ee62013-01-24 19:13:44 -0800208 if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
Dianne Hackbornd7960d12013-01-29 18:55:48 -0800209 return rejectInsert(uri, initialValues);
Dianne Hackborn5e45ee62013-01-24 19:13:44 -0800210 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 return ContentProvider.this.insert(uri, initialValues);
212 }
213
Jeff Brown75ea64f2012-01-25 19:37:13 -0800214 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800215 public int bulkInsert(String callingPkg, Uri uri, ContentValues[] initialValues) {
216 if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
217 return 0;
218 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 return ContentProvider.this.bulkInsert(uri, initialValues);
220 }
221
Jeff Brown75ea64f2012-01-25 19:37:13 -0800222 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800223 public ContentProviderResult[] applyBatch(String callingPkg,
224 ArrayList<ContentProviderOperation> operations)
Fred Quintana89437372009-05-15 15:10:40 -0700225 throws OperationApplicationException {
226 for (ContentProviderOperation operation : operations) {
227 if (operation.isReadOperation()) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800228 if (enforceReadPermission(callingPkg, operation.getUri())
229 != AppOpsManager.MODE_ALLOWED) {
230 throw new OperationApplicationException("App op not allowed", 0);
231 }
Fred Quintana89437372009-05-15 15:10:40 -0700232 }
233
234 if (operation.isWriteOperation()) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800235 if (enforceWritePermission(callingPkg, operation.getUri())
236 != AppOpsManager.MODE_ALLOWED) {
237 throw new OperationApplicationException("App op not allowed", 0);
238 }
Fred Quintana89437372009-05-15 15:10:40 -0700239 }
240 }
241 return ContentProvider.this.applyBatch(operations);
Fred Quintana6a8d5332009-05-07 17:35:38 -0700242 }
243
Jeff Brown75ea64f2012-01-25 19:37:13 -0800244 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800245 public int delete(String callingPkg, Uri uri, String selection, String[] selectionArgs) {
246 if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
247 return 0;
248 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 return ContentProvider.this.delete(uri, selection, selectionArgs);
250 }
251
Jeff Brown75ea64f2012-01-25 19:37:13 -0800252 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800253 public int update(String callingPkg, Uri uri, ContentValues values, String selection,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800254 String[] selectionArgs) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800255 if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
256 return 0;
257 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 return ContentProvider.this.update(uri, values, selection, selectionArgs);
259 }
260
Jeff Brown75ea64f2012-01-25 19:37:13 -0800261 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800262 public ParcelFileDescriptor openFile(String callingPkg, Uri uri, String mode)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263 throws FileNotFoundException {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800264 enforceFilePermission(callingPkg, uri, mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 return ContentProvider.this.openFile(uri, mode);
266 }
267
Jeff Brown75ea64f2012-01-25 19:37:13 -0800268 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800269 public AssetFileDescriptor openAssetFile(String callingPkg, Uri uri, String mode)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800270 throws FileNotFoundException {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800271 enforceFilePermission(callingPkg, uri, mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800272 return ContentProvider.this.openAssetFile(uri, mode);
273 }
274
Jeff Brown75ea64f2012-01-25 19:37:13 -0800275 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800276 public Bundle call(String callingPkg, String method, String arg, Bundle extras) {
Dianne Hackborn961321f2013-02-05 17:22:41 -0800277 return ContentProvider.this.callFromPackage(callingPkg, method, arg, extras);
Brad Fitzpatrick1877d012010-03-04 17:48:13 -0800278 }
279
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700280 @Override
281 public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
282 return ContentProvider.this.getStreamTypes(uri, mimeTypeFilter);
283 }
284
285 @Override
Dianne Hackborn35654b62013-01-14 17:38:02 -0800286 public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri uri, String mimeType,
287 Bundle opts) throws FileNotFoundException {
288 enforceFilePermission(callingPkg, uri, "r");
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700289 return ContentProvider.this.openTypedAssetFile(uri, mimeType, opts);
290 }
291
Jeff Brown75ea64f2012-01-25 19:37:13 -0800292 @Override
Jeff Brown4c1241d2012-02-02 17:05:00 -0800293 public ICancellationSignal createCancellationSignal() throws RemoteException {
294 return CancellationSignal.createTransport();
Jeff Brown75ea64f2012-01-25 19:37:13 -0800295 }
296
Dianne Hackborn35654b62013-01-14 17:38:02 -0800297 private void enforceFilePermission(String callingPkg, Uri uri, String mode)
298 throws FileNotFoundException, SecurityException {
Jeff Sharkeyba761972013-02-28 15:57:36 -0800299 if (mode != null && mode.indexOf('w') != -1) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800300 if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
301 throw new FileNotFoundException("App op not allowed");
302 }
303 } else {
304 if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
305 throw new FileNotFoundException("App op not allowed");
306 }
307 }
308 }
309
310 private int enforceReadPermission(String callingPkg, Uri uri) throws SecurityException {
311 enforceReadPermissionInner(uri);
Dianne Hackborn961321f2013-02-05 17:22:41 -0800312 if (mReadOp != AppOpsManager.OP_NONE) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800313 return mAppOpsManager.noteOp(mReadOp, Binder.getCallingUid(), callingPkg);
314 }
315 return AppOpsManager.MODE_ALLOWED;
316 }
317
318 private void enforceReadPermissionInner(Uri uri) throws SecurityException {
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700319 final Context context = getContext();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 final int pid = Binder.getCallingPid();
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700321 final int uid = Binder.getCallingUid();
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700322 String missingPerm = null;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700323
Dianne Hackborn0d8af782012-08-17 16:51:54 -0700324 if (UserHandle.isSameApp(uid, mMyUid)) {
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700325 return;
326 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700327
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700328 if (mExported) {
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700329 final String componentPerm = getReadPermission();
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700330 if (componentPerm != null) {
331 if (context.checkPermission(componentPerm, pid, uid) == PERMISSION_GRANTED) {
332 return;
333 } else {
334 missingPerm = componentPerm;
335 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700336 }
337
338 // track if unprotected read is allowed; any denied
339 // <path-permission> below removes this ability
340 boolean allowDefaultRead = (componentPerm == null);
341
342 final PathPermission[] pps = getPathPermissions();
343 if (pps != null) {
344 final String path = uri.getPath();
345 for (PathPermission pp : pps) {
346 final String pathPerm = pp.getReadPermission();
347 if (pathPerm != null && pp.match(path)) {
348 if (context.checkPermission(pathPerm, pid, uid) == PERMISSION_GRANTED) {
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700349 return;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700350 } else {
351 // any denied <path-permission> means we lose
352 // default <provider> access.
353 allowDefaultRead = false;
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700354 missingPerm = pathPerm;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700355 }
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700356 }
357 }
358 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700359
360 // if we passed <path-permission> checks above, and no default
361 // <provider> permission, then allow access.
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700362 if (allowDefaultRead) return;
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700363 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700364
365 // last chance, check against any uri grants
366 if (context.checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_READ_URI_PERMISSION)
367 == PERMISSION_GRANTED) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800368 return;
369 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700370
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700371 final String failReason = mExported
372 ? " requires " + missingPerm + ", or grantUriPermission()"
373 : " requires the provider be exported, or grantUriPermission()";
374 throw new SecurityException("Permission Denial: reading "
375 + ContentProvider.this.getClass().getName() + " uri " + uri + " from pid=" + pid
376 + ", uid=" + uid + failReason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 }
378
Dianne Hackborn35654b62013-01-14 17:38:02 -0800379 private int enforceWritePermission(String callingPkg, Uri uri) throws SecurityException {
380 enforceWritePermissionInner(uri);
Dianne Hackborn961321f2013-02-05 17:22:41 -0800381 if (mWriteOp != AppOpsManager.OP_NONE) {
Dianne Hackborn35654b62013-01-14 17:38:02 -0800382 return mAppOpsManager.noteOp(mWriteOp, Binder.getCallingUid(), callingPkg);
383 }
384 return AppOpsManager.MODE_ALLOWED;
385 }
386
387 private void enforceWritePermissionInner(Uri uri) throws SecurityException {
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700388 final Context context = getContext();
389 final int pid = Binder.getCallingPid();
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700390 final int uid = Binder.getCallingUid();
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700391 String missingPerm = null;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700392
Dianne Hackborn0d8af782012-08-17 16:51:54 -0700393 if (UserHandle.isSameApp(uid, mMyUid)) {
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700394 return;
395 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700396
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700397 if (mExported) {
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700398 final String componentPerm = getWritePermission();
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700399 if (componentPerm != null) {
400 if (context.checkPermission(componentPerm, pid, uid) == PERMISSION_GRANTED) {
401 return;
402 } else {
403 missingPerm = componentPerm;
404 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700405 }
406
407 // track if unprotected write is allowed; any denied
408 // <path-permission> below removes this ability
409 boolean allowDefaultWrite = (componentPerm == null);
410
411 final PathPermission[] pps = getPathPermissions();
412 if (pps != null) {
413 final String path = uri.getPath();
414 for (PathPermission pp : pps) {
415 final String pathPerm = pp.getWritePermission();
416 if (pathPerm != null && pp.match(path)) {
417 if (context.checkPermission(pathPerm, pid, uid) == PERMISSION_GRANTED) {
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700418 return;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700419 } else {
420 // any denied <path-permission> means we lose
421 // default <provider> access.
422 allowDefaultWrite = false;
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700423 missingPerm = pathPerm;
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700424 }
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700425 }
426 }
427 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700428
429 // if we passed <path-permission> checks above, and no default
430 // <provider> permission, then allow access.
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700431 if (allowDefaultWrite) return;
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700432 }
Jeff Sharkey110a6b62012-03-12 11:12:41 -0700433
434 // last chance, check against any uri grants
435 if (context.checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
436 == PERMISSION_GRANTED) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800437 return;
438 }
Jeff Sharkeye5d49332012-03-13 12:13:17 -0700439
440 final String failReason = mExported
441 ? " requires " + missingPerm + ", or grantUriPermission()"
442 : " requires the provider be exported, or grantUriPermission()";
443 throw new SecurityException("Permission Denial: writing "
444 + ContentProvider.this.getClass().getName() + " uri " + uri + " from pid=" + pid
445 + ", uid=" + uid + failReason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 }
447 }
448
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700450 * Retrieves the Context this provider is running in. Only available once
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800451 * {@link #onCreate} has been called -- this will return {@code null} in the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 * constructor.
453 */
454 public final Context getContext() {
455 return mContext;
456 }
457
458 /**
459 * Change the permission required to read data from the content
460 * provider. This is normally set for you from its manifest information
461 * when the provider is first created.
462 *
463 * @param permission Name of the permission required for read-only access.
464 */
465 protected final void setReadPermission(String permission) {
466 mReadPermission = permission;
467 }
468
469 /**
470 * Return the name of the permission required for read-only access to
471 * this content provider. This method can be called from multiple
472 * threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800473 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
474 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800475 */
476 public final String getReadPermission() {
477 return mReadPermission;
478 }
479
480 /**
481 * Change the permission required to read and write data in the content
482 * provider. This is normally set for you from its manifest information
483 * when the provider is first created.
484 *
485 * @param permission Name of the permission required for read/write access.
486 */
487 protected final void setWritePermission(String permission) {
488 mWritePermission = permission;
489 }
490
491 /**
492 * Return the name of the permission required for read/write access to
493 * this content provider. This method can be called from multiple
494 * threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800495 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
496 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 */
498 public final String getWritePermission() {
499 return mWritePermission;
500 }
501
502 /**
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700503 * Change the path-based permission required to read and/or write data in
504 * the content provider. This is normally set for you from its manifest
505 * information when the provider is first created.
506 *
507 * @param permissions Array of path permission descriptions.
508 */
509 protected final void setPathPermissions(PathPermission[] permissions) {
510 mPathPermissions = permissions;
511 }
512
513 /**
514 * Return the path-based permissions required for read and/or write access to
515 * this content provider. This method can be called from multiple
516 * threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800517 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
518 * and Threads</a>.
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700519 */
520 public final PathPermission[] getPathPermissions() {
521 return mPathPermissions;
522 }
523
Dianne Hackborn35654b62013-01-14 17:38:02 -0800524 /** @hide */
525 public final void setAppOps(int readOp, int writeOp) {
526 mTransport.mAppOpsManager = (AppOpsManager)mContext.getSystemService(
527 Context.APP_OPS_SERVICE);
528 mTransport.mReadOp = readOp;
529 mTransport.mWriteOp = writeOp;
530 }
531
Dianne Hackborn961321f2013-02-05 17:22:41 -0800532 /** @hide */
533 public AppOpsManager getAppOpsManager() {
534 return mTransport.mAppOpsManager;
535 }
536
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700537 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700538 * Implement this to initialize your content provider on startup.
539 * This method is called for all registered content providers on the
540 * application main thread at application launch time. It must not perform
541 * lengthy operations, or application startup will be delayed.
542 *
543 * <p>You should defer nontrivial initialization (such as opening,
544 * upgrading, and scanning databases) until the content provider is used
545 * (via {@link #query}, {@link #insert}, etc). Deferred initialization
546 * keeps application startup fast, avoids unnecessary work if the provider
547 * turns out not to be needed, and stops database errors (such as a full
548 * disk) from halting application launch.
549 *
Dan Egnor17876aa2010-07-28 12:28:04 -0700550 * <p>If you use SQLite, {@link android.database.sqlite.SQLiteOpenHelper}
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700551 * is a helpful utility class that makes it easy to manage databases,
552 * and will automatically defer opening until first use. If you do use
553 * SQLiteOpenHelper, make sure to avoid calling
554 * {@link android.database.sqlite.SQLiteOpenHelper#getReadableDatabase} or
555 * {@link android.database.sqlite.SQLiteOpenHelper#getWritableDatabase}
556 * from this method. (Instead, override
557 * {@link android.database.sqlite.SQLiteOpenHelper#onOpen} to initialize the
558 * database when it is first opened.)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 *
560 * @return true if the provider was successfully loaded, false otherwise
561 */
562 public abstract boolean onCreate();
563
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700564 /**
565 * {@inheritDoc}
566 * This method is always called on the application main thread, and must
567 * not perform lengthy operations.
568 *
569 * <p>The default content provider implementation does nothing.
570 * Override this method to take appropriate action.
571 * (Content providers do not usually care about things like screen
572 * orientation, but may want to know about locale changes.)
573 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 public void onConfigurationChanged(Configuration newConfig) {
575 }
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700576
577 /**
578 * {@inheritDoc}
579 * This method is always called on the application main thread, and must
580 * not perform lengthy operations.
581 *
582 * <p>The default content provider implementation does nothing.
583 * Subclasses may override this method to take appropriate action.
584 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 public void onLowMemory() {
586 }
587
Dianne Hackbornc68c9132011-07-29 01:25:18 -0700588 public void onTrimMemory(int level) {
589 }
590
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 /**
Dianne Hackbornd7960d12013-01-29 18:55:48 -0800592 * @hide
593 * Implementation when a caller has performed a query on the content
594 * provider, but that call has been rejected for the operation given
595 * to {@link #setAppOps(int, int)}. The default implementation
596 * rewrites the <var>selection</var> argument to include a condition
597 * that is never true (so will always result in an empty cursor)
598 * and calls through to {@link #query(android.net.Uri, String[], String, String[],
599 * String, android.os.CancellationSignal)} with that.
600 */
601 public Cursor rejectQuery(Uri uri, String[] projection,
602 String selection, String[] selectionArgs, String sortOrder,
603 CancellationSignal cancellationSignal) {
604 // The read is not allowed... to fake it out, we replace the given
605 // selection statement with a dummy one that will always be false.
606 // This way we will get a cursor back that has the correct structure
607 // but contains no rows.
608 if (selection == null) {
609 selection = "'A' = 'B'";
610 } else {
611 selection = "'A' = 'B' AND (" + selection + ")";
612 }
613 return query(uri, projection, selection, selectionArgs, sortOrder, cancellationSignal);
614 }
615
616 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700617 * Implement this to handle query requests from clients.
618 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800619 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
620 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800621 * <p>
622 * Example client call:<p>
623 * <pre>// Request a specific record.
624 * Cursor managedCursor = managedQuery(
Alan Jones81a476f2009-05-21 12:32:17 +1000625 ContentUris.withAppendedId(Contacts.People.CONTENT_URI, 2),
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626 projection, // Which columns to return.
627 null, // WHERE clause.
Alan Jones81a476f2009-05-21 12:32:17 +1000628 null, // WHERE clause value substitution
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800629 People.NAME + " ASC"); // Sort order.</pre>
630 * Example implementation:<p>
631 * <pre>// SQLiteQueryBuilder is a helper class that creates the
632 // proper SQL syntax for us.
633 SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
634
635 // Set the table we're querying.
636 qBuilder.setTables(DATABASE_TABLE_NAME);
637
638 // If the query ends in a specific record number, we're
639 // being asked for a specific record, so set the
640 // WHERE clause in our query.
641 if((URI_MATCHER.match(uri)) == SPECIFIC_MESSAGE){
642 qBuilder.appendWhere("_id=" + uri.getPathLeafId());
643 }
644
645 // Make the query.
646 Cursor c = qBuilder.query(mDb,
647 projection,
648 selection,
649 selectionArgs,
650 groupBy,
651 having,
652 sortOrder);
653 c.setNotificationUri(getContext().getContentResolver(), uri);
654 return c;</pre>
655 *
656 * @param uri The URI to query. This will be the full URI sent by the client;
Alan Jones81a476f2009-05-21 12:32:17 +1000657 * if the client is requesting a specific record, the URI will end in a record number
658 * that the implementation should parse and add to a WHERE or HAVING clause, specifying
659 * that _id value.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800660 * @param projection The list of columns to put into the cursor. If
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800661 * {@code null} all columns are included.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800662 * @param selection A selection criteria to apply when filtering rows.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800663 * If {@code null} then all rows are included.
Alan Jones81a476f2009-05-21 12:32:17 +1000664 * @param selectionArgs You may include ?s in selection, which will be replaced by
665 * the values from selectionArgs, in order that they appear in the selection.
666 * The values will be bound as Strings.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800667 * @param sortOrder How the rows in the cursor should be sorted.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800668 * If {@code null} then the provider is free to define the sort order.
669 * @return a Cursor or {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 */
671 public abstract Cursor query(Uri uri, String[] projection,
672 String selection, String[] selectionArgs, String sortOrder);
673
Fred Quintana5bba6322009-10-05 14:21:12 -0700674 /**
Jeff Brown4c1241d2012-02-02 17:05:00 -0800675 * Implement this to handle query requests from clients with support for cancellation.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800676 * This method can be called from multiple threads, as described in
677 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
678 * and Threads</a>.
679 * <p>
680 * Example client call:<p>
681 * <pre>// Request a specific record.
682 * Cursor managedCursor = managedQuery(
683 ContentUris.withAppendedId(Contacts.People.CONTENT_URI, 2),
684 projection, // Which columns to return.
685 null, // WHERE clause.
686 null, // WHERE clause value substitution
687 People.NAME + " ASC"); // Sort order.</pre>
688 * Example implementation:<p>
689 * <pre>// SQLiteQueryBuilder is a helper class that creates the
690 // proper SQL syntax for us.
691 SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
692
693 // Set the table we're querying.
694 qBuilder.setTables(DATABASE_TABLE_NAME);
695
696 // If the query ends in a specific record number, we're
697 // being asked for a specific record, so set the
698 // WHERE clause in our query.
699 if((URI_MATCHER.match(uri)) == SPECIFIC_MESSAGE){
700 qBuilder.appendWhere("_id=" + uri.getPathLeafId());
701 }
702
703 // Make the query.
704 Cursor c = qBuilder.query(mDb,
705 projection,
706 selection,
707 selectionArgs,
708 groupBy,
709 having,
710 sortOrder);
711 c.setNotificationUri(getContext().getContentResolver(), uri);
712 return c;</pre>
713 * <p>
714 * If you implement this method then you must also implement the version of
Jeff Brown4c1241d2012-02-02 17:05:00 -0800715 * {@link #query(Uri, String[], String, String[], String)} that does not take a cancellation
716 * signal to ensure correct operation on older versions of the Android Framework in
717 * which the cancellation signal overload was not available.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800718 *
719 * @param uri The URI to query. This will be the full URI sent by the client;
720 * if the client is requesting a specific record, the URI will end in a record number
721 * that the implementation should parse and add to a WHERE or HAVING clause, specifying
722 * that _id value.
723 * @param projection The list of columns to put into the cursor. If
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800724 * {@code null} all columns are included.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800725 * @param selection A selection criteria to apply when filtering rows.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800726 * If {@code null} then all rows are included.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800727 * @param selectionArgs You may include ?s in selection, which will be replaced by
728 * the values from selectionArgs, in order that they appear in the selection.
729 * The values will be bound as Strings.
730 * @param sortOrder How the rows in the cursor should be sorted.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800731 * If {@code null} then the provider is free to define the sort order.
732 * @param cancellationSignal A signal to cancel the operation in progress, or {@code null} if none.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800733 * If the operation is canceled, then {@link OperationCanceledException} will be thrown
734 * when the query is executed.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800735 * @return a Cursor or {@code null}.
Jeff Brown75ea64f2012-01-25 19:37:13 -0800736 */
737 public Cursor query(Uri uri, String[] projection,
738 String selection, String[] selectionArgs, String sortOrder,
Jeff Brown4c1241d2012-02-02 17:05:00 -0800739 CancellationSignal cancellationSignal) {
Jeff Brown75ea64f2012-01-25 19:37:13 -0800740 return query(uri, projection, selection, selectionArgs, sortOrder);
741 }
742
743 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700744 * Implement this to handle requests for the MIME type of the data at the
745 * given URI. The returned MIME type should start with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800746 * <code>vnd.android.cursor.item</code> for a single record,
747 * or <code>vnd.android.cursor.dir/</code> for multiple items.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700748 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800749 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
750 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751 *
Dianne Hackborncca1f0e2010-09-26 18:34:53 -0700752 * <p>Note that there are no permissions needed for an application to
753 * access this information; if your content provider requires read and/or
754 * write permissions, or is not exported, all applications can still call
755 * this method regardless of their access permissions. This allows them
756 * to retrieve the MIME type for a URI when dispatching intents.
757 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800758 * @param uri the URI to query.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800759 * @return a MIME type string, or {@code null} if there is no type.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 */
761 public abstract String getType(Uri uri);
762
763 /**
Dianne Hackbornd7960d12013-01-29 18:55:48 -0800764 * @hide
765 * Implementation when a caller has performed an insert on the content
766 * provider, but that call has been rejected for the operation given
767 * to {@link #setAppOps(int, int)}. The default implementation simply
768 * returns a dummy URI that is the base URI with a 0 path element
769 * appended.
770 */
771 public Uri rejectInsert(Uri uri, ContentValues values) {
772 // If not allowed, we need to return some reasonable URI. Maybe the
773 // content provider should be responsible for this, but for now we
774 // will just return the base URI with a dummy '0' tagged on to it.
775 // You shouldn't be able to read if you can't write, anyway, so it
776 // shouldn't matter much what is returned.
777 return uri.buildUpon().appendPath("0").build();
778 }
779
780 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700781 * Implement this to handle requests to insert a new row.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800782 * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
783 * after inserting.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700784 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800785 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
786 * and Threads</a>.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800787 * @param uri The content:// URI of the insertion request. This must not be {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 * @param values A set of column_name/value pairs to add to the database.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800789 * This must not be {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 * @return The URI for the newly inserted item.
791 */
792 public abstract Uri insert(Uri uri, ContentValues values);
793
794 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700795 * Override this to handle requests to insert a set of new rows, or the
796 * default implementation will iterate over the values and call
797 * {@link #insert} on each of them.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800798 * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
799 * after inserting.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700800 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800801 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
802 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800803 *
804 * @param uri The content:// URI of the insertion request.
805 * @param values An array of sets of column_name/value pairs to add to the database.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800806 * This must not be {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800807 * @return The number of values that were inserted.
808 */
809 public int bulkInsert(Uri uri, ContentValues[] values) {
810 int numValues = values.length;
811 for (int i = 0; i < numValues; i++) {
812 insert(uri, values[i]);
813 }
814 return numValues;
815 }
816
817 /**
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700818 * Implement this to handle requests to delete one or more rows.
819 * The implementation should apply the selection clause when performing
820 * deletion, allowing the operation to affect multiple rows in a directory.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyDelete()}
822 * after deleting.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700823 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800824 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
825 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800826 *
827 * <p>The implementation is responsible for parsing out a row ID at the end
828 * of the URI, if a specific row is being deleted. That is, the client would
829 * pass in <code>content://contacts/people/22</code> and the implementation is
830 * responsible for parsing the record number (22) when creating a SQL statement.
831 *
832 * @param uri The full URI to query, including a row ID (if a specific record is requested).
833 * @param selection An optional restriction to apply to rows when deleting.
834 * @return The number of rows affected.
835 * @throws SQLException
836 */
837 public abstract int delete(Uri uri, String selection, String[] selectionArgs);
838
839 /**
Dan Egnor17876aa2010-07-28 12:28:04 -0700840 * Implement this to handle requests to update one or more rows.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700841 * The implementation should update all rows matching the selection
842 * to set the columns according to the provided values map.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800843 * As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
844 * after updating.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700845 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800846 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
847 * and Threads</a>.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800848 *
849 * @param uri The URI to query. This can potentially have a record ID if this
850 * is an update request for a specific record.
Christopher Tate2bc6eb82013-01-03 12:04:08 -0800851 * @param values A set of column_name/value pairs to update in the database.
852 * This must not be {@code null}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800853 * @param selection An optional filter to match rows to update.
854 * @return the number of rows affected.
855 */
856 public abstract int update(Uri uri, ContentValues values, String selection,
857 String[] selectionArgs);
858
859 /**
Dan Egnor17876aa2010-07-28 12:28:04 -0700860 * Override this to handle requests to open a file blob.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700861 * The default implementation always throws {@link FileNotFoundException}.
862 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800863 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
864 * and Threads</a>.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700865 *
Dan Egnor17876aa2010-07-28 12:28:04 -0700866 * <p>This method returns a ParcelFileDescriptor, which is returned directly
867 * to the caller. This way large data (such as images and documents) can be
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700868 * returned without copying the content.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800869 *
870 * <p>The returned ParcelFileDescriptor is owned by the caller, so it is
871 * their responsibility to close it when done. That is, the implementation
872 * of this method should create a new ParcelFileDescriptor for each call.
873 *
Dianne Hackborna53ee352013-02-20 12:47:02 -0800874 * <p class="note">For use in Intents, you will want to implement {@link #getType}
875 * to return the appropriate MIME type for the data returned here with
876 * the same URI. This will allow intent resolution to automatically determine the data MIME
877 * type and select the appropriate matching targets as part of its operation.</p>
878 *
879 * <p class="note">For better interoperability with other applications, it is recommended
880 * that for any URIs that can be opened, you also support queries on them
881 * containing at least the columns specified by {@link android.provider.OpenableColumns}.
882 * You may also want to support other common columns if you have additional meta-data
883 * to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
884 * in {@link android.provider.MediaStore.MediaColumns}.</p>
885 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800886 * @param uri The URI whose file is to be opened.
887 * @param mode Access mode for the file. May be "r" for read-only access,
888 * "rw" for read and write access, or "rwt" for read and write access
889 * that truncates any existing file.
890 *
891 * @return Returns a new ParcelFileDescriptor which you can use to access
892 * the file.
893 *
894 * @throws FileNotFoundException Throws FileNotFoundException if there is
895 * no file associated with the given URI or the mode is invalid.
896 * @throws SecurityException Throws SecurityException if the caller does
897 * not have permission to access the file.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700898 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 * @see #openAssetFile(Uri, String)
900 * @see #openFileHelper(Uri, String)
Dianne Hackborna53ee352013-02-20 12:47:02 -0800901 * @see #getType(android.net.Uri)
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700902 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 public ParcelFileDescriptor openFile(Uri uri, String mode)
904 throws FileNotFoundException {
905 throw new FileNotFoundException("No files supported by provider at "
906 + uri);
907 }
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700908
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800909 /**
910 * This is like {@link #openFile}, but can be implemented by providers
911 * that need to be able to return sub-sections of files, often assets
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700912 * inside of their .apk.
913 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -0800914 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
915 * and Threads</a>.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700916 *
917 * <p>If you implement this, your clients must be able to deal with such
Dan Egnor17876aa2010-07-28 12:28:04 -0700918 * file slices, either directly with
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700919 * {@link ContentResolver#openAssetFileDescriptor}, or by using the higher-level
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800920 * {@link ContentResolver#openInputStream ContentResolver.openInputStream}
921 * or {@link ContentResolver#openOutputStream ContentResolver.openOutputStream}
922 * methods.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700923 *
924 * <p class="note">If you are implementing this to return a full file, you
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800925 * should create the AssetFileDescriptor with
926 * {@link AssetFileDescriptor#UNKNOWN_LENGTH} to be compatible with
Dan Egnor6fcc0f0732010-07-27 16:32:17 -0700927 * applications that can not handle sub-sections of files.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800928 *
Dianne Hackborna53ee352013-02-20 12:47:02 -0800929 * <p class="note">For use in Intents, you will want to implement {@link #getType}
930 * to return the appropriate MIME type for the data returned here with
931 * the same URI. This will allow intent resolution to automatically determine the data MIME
932 * type and select the appropriate matching targets as part of its operation.</p>
933 *
934 * <p class="note">For better interoperability with other applications, it is recommended
935 * that for any URIs that can be opened, you also support queries on them
936 * containing at least the columns specified by {@link android.provider.OpenableColumns}.</p>
937 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800938 * @param uri The URI whose file is to be opened.
939 * @param mode Access mode for the file. May be "r" for read-only access,
940 * "w" for write-only access (erasing whatever data is currently in
941 * the file), "wa" for write-only access to append to any existing data,
942 * "rw" for read and write access on any existing data, and "rwt" for read
943 * and write access that truncates any existing file.
944 *
945 * @return Returns a new AssetFileDescriptor which you can use to access
946 * the file.
947 *
948 * @throws FileNotFoundException Throws FileNotFoundException if there is
949 * no file associated with the given URI or the mode is invalid.
950 * @throws SecurityException Throws SecurityException if the caller does
951 * not have permission to access the file.
952 *
953 * @see #openFile(Uri, String)
954 * @see #openFileHelper(Uri, String)
Dianne Hackborna53ee352013-02-20 12:47:02 -0800955 * @see #getType(android.net.Uri)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800956 */
957 public AssetFileDescriptor openAssetFile(Uri uri, String mode)
958 throws FileNotFoundException {
959 ParcelFileDescriptor fd = openFile(uri, mode);
960 return fd != null ? new AssetFileDescriptor(fd, 0, -1) : null;
961 }
962
963 /**
964 * Convenience for subclasses that wish to implement {@link #openFile}
965 * by looking up a column named "_data" at the given URI.
966 *
967 * @param uri The URI to be opened.
968 * @param mode The file mode. May be "r" for read-only access,
969 * "w" for write-only access (erasing whatever data is currently in
970 * the file), "wa" for write-only access to append to any existing data,
971 * "rw" for read and write access on any existing data, and "rwt" for read
972 * and write access that truncates any existing file.
973 *
974 * @return Returns a new ParcelFileDescriptor that can be used by the
975 * client to access the file.
976 */
977 protected final ParcelFileDescriptor openFileHelper(Uri uri,
978 String mode) throws FileNotFoundException {
979 Cursor c = query(uri, new String[]{"_data"}, null, null, null);
980 int count = (c != null) ? c.getCount() : 0;
981 if (count != 1) {
982 // If there is not exactly one result, throw an appropriate
983 // exception.
984 if (c != null) {
985 c.close();
986 }
987 if (count == 0) {
988 throw new FileNotFoundException("No entry for " + uri);
989 }
990 throw new FileNotFoundException("Multiple items at " + uri);
991 }
992
993 c.moveToFirst();
994 int i = c.getColumnIndex("_data");
995 String path = (i >= 0 ? c.getString(i) : null);
996 c.close();
997 if (path == null) {
998 throw new FileNotFoundException("Column _data not found.");
999 }
1000
1001 int modeBits = ContentResolver.modeToMode(uri, mode);
1002 return ParcelFileDescriptor.open(new File(path), modeBits);
1003 }
1004
1005 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001006 * Called by a client to determine the types of data streams that this
1007 * content provider supports for the given URI. The default implementation
Christopher Tate2bc6eb82013-01-03 12:04:08 -08001008 * returns {@code null}, meaning no types. If your content provider stores data
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001009 * of a particular type, return that MIME type if it matches the given
1010 * mimeTypeFilter. If it can perform type conversions, return an array
1011 * of all supported MIME types that match mimeTypeFilter.
1012 *
1013 * @param uri The data in the content provider being queried.
1014 * @param mimeTypeFilter The type of data the client desires. May be
1015 * a pattern, such as *\/* to retrieve all possible data types.
Christopher Tate2bc6eb82013-01-03 12:04:08 -08001016 * @return Returns {@code null} if there are no possible data streams for the
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001017 * given mimeTypeFilter. Otherwise returns an array of all available
1018 * concrete MIME types.
1019 *
1020 * @see #getType(Uri)
1021 * @see #openTypedAssetFile(Uri, String, Bundle)
Dianne Hackborn1040dc42010-08-26 22:11:06 -07001022 * @see ClipDescription#compareMimeTypes(String, String)
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001023 */
1024 public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
1025 return null;
1026 }
1027
1028 /**
1029 * Called by a client to open a read-only stream containing data of a
1030 * particular MIME type. This is like {@link #openAssetFile(Uri, String)},
1031 * except the file can only be read-only and the content provider may
1032 * perform data conversions to generate data of the desired type.
1033 *
1034 * <p>The default implementation compares the given mimeType against the
Dianne Hackborna53ee352013-02-20 12:47:02 -08001035 * result of {@link #getType(Uri)} and, if they match, simply calls
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001036 * {@link #openAssetFile(Uri, String)}.
1037 *
Dianne Hackborn1040dc42010-08-26 22:11:06 -07001038 * <p>See {@link ClipData} for examples of the use and implementation
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001039 * of this method.
1040 *
Dianne Hackborna53ee352013-02-20 12:47:02 -08001041 * <p class="note">For better interoperability with other applications, it is recommended
1042 * that for any URIs that can be opened, you also support queries on them
1043 * containing at least the columns specified by {@link android.provider.OpenableColumns}.
1044 * You may also want to support other common columns if you have additional meta-data
1045 * to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
1046 * in {@link android.provider.MediaStore.MediaColumns}.</p>
1047 *
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001048 * @param uri The data in the content provider being queried.
1049 * @param mimeTypeFilter The type of data the client desires. May be
1050 * a pattern, such as *\/*, if the caller does not have specific type
1051 * requirements; in this case the content provider will pick its best
1052 * type matching the pattern.
1053 * @param opts Additional options from the client. The definitions of
1054 * these are specific to the content provider being called.
1055 *
1056 * @return Returns a new AssetFileDescriptor from which the client can
1057 * read data of the desired type.
1058 *
1059 * @throws FileNotFoundException Throws FileNotFoundException if there is
1060 * no file associated with the given URI or the mode is invalid.
1061 * @throws SecurityException Throws SecurityException if the caller does
1062 * not have permission to access the data.
1063 * @throws IllegalArgumentException Throws IllegalArgumentException if the
1064 * content provider does not support the requested MIME type.
1065 *
1066 * @see #getStreamTypes(Uri, String)
1067 * @see #openAssetFile(Uri, String)
Dianne Hackborn1040dc42010-08-26 22:11:06 -07001068 * @see ClipDescription#compareMimeTypes(String, String)
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001069 */
1070 public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts)
1071 throws FileNotFoundException {
Dianne Hackborn02dfd262010-08-13 12:34:58 -07001072 if ("*/*".equals(mimeTypeFilter)) {
1073 // If they can take anything, the untyped open call is good enough.
1074 return openAssetFile(uri, "r");
1075 }
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001076 String baseType = getType(uri);
Dianne Hackborn1040dc42010-08-26 22:11:06 -07001077 if (baseType != null && ClipDescription.compareMimeTypes(baseType, mimeTypeFilter)) {
Dianne Hackborn02dfd262010-08-13 12:34:58 -07001078 // Use old untyped open call if this provider has a type for this
1079 // URI and it matches the request.
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001080 return openAssetFile(uri, "r");
1081 }
1082 throw new FileNotFoundException("Can't open " + uri + " as type " + mimeTypeFilter);
1083 }
1084
1085 /**
1086 * Interface to write a stream of data to a pipe. Use with
1087 * {@link ContentProvider#openPipeHelper}.
1088 */
1089 public interface PipeDataWriter<T> {
1090 /**
1091 * Called from a background thread to stream data out to a pipe.
1092 * Note that the pipe is blocking, so this thread can block on
1093 * writes for an arbitrary amount of time if the client is slow
1094 * at reading.
1095 *
1096 * @param output The pipe where data should be written. This will be
1097 * closed for you upon returning from this function.
1098 * @param uri The URI whose data is to be written.
1099 * @param mimeType The desired type of data to be written.
1100 * @param opts Options supplied by caller.
1101 * @param args Your own custom arguments.
1102 */
1103 public void writeDataToPipe(ParcelFileDescriptor output, Uri uri, String mimeType,
1104 Bundle opts, T args);
1105 }
1106
1107 /**
1108 * A helper function for implementing {@link #openTypedAssetFile}, for
1109 * creating a data pipe and background thread allowing you to stream
1110 * generated data back to the client. This function returns a new
1111 * ParcelFileDescriptor that should be returned to the caller (the caller
1112 * is responsible for closing it).
1113 *
1114 * @param uri The URI whose data is to be written.
1115 * @param mimeType The desired type of data to be written.
1116 * @param opts Options supplied by caller.
1117 * @param args Your own custom arguments.
1118 * @param func Interface implementing the function that will actually
1119 * stream the data.
1120 * @return Returns a new ParcelFileDescriptor holding the read side of
1121 * the pipe. This should be returned to the caller for reading; the caller
1122 * is responsible for closing it when done.
1123 */
1124 public <T> ParcelFileDescriptor openPipeHelper(final Uri uri, final String mimeType,
1125 final Bundle opts, final T args, final PipeDataWriter<T> func)
1126 throws FileNotFoundException {
1127 try {
1128 final ParcelFileDescriptor[] fds = ParcelFileDescriptor.createPipe();
1129
1130 AsyncTask<Object, Object, Object> task = new AsyncTask<Object, Object, Object>() {
1131 @Override
1132 protected Object doInBackground(Object... params) {
1133 func.writeDataToPipe(fds[1], uri, mimeType, opts, args);
1134 try {
1135 fds[1].close();
1136 } catch (IOException e) {
1137 Log.w(TAG, "Failure closing pipe", e);
1138 }
1139 return null;
1140 }
1141 };
Dianne Hackborn5d9d03a2011-01-24 13:15:09 -08001142 task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Object[])null);
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001143
1144 return fds[0];
1145 } catch (IOException e) {
1146 throw new FileNotFoundException("failure making pipe");
1147 }
1148 }
1149
1150 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001151 * Returns true if this instance is a temporary content provider.
1152 * @return true if this instance is a temporary content provider
1153 */
1154 protected boolean isTemporary() {
1155 return false;
1156 }
1157
1158 /**
1159 * Returns the Binder object for this provider.
1160 *
1161 * @return the Binder object for this provider
1162 * @hide
1163 */
1164 public IContentProvider getIContentProvider() {
1165 return mTransport;
1166 }
1167
1168 /**
1169 * After being instantiated, this is called to tell the content provider
1170 * about itself.
1171 *
1172 * @param context The context this provider is running in
1173 * @param info Registered information about this content provider
1174 */
1175 public void attachInfo(Context context, ProviderInfo info) {
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001176 /*
1177 * We may be using AsyncTask from binder threads. Make it init here
1178 * so its static handler is on the main thread.
1179 */
1180 AsyncTask.init();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001181
1182 /*
1183 * Only allow it to be set once, so after the content service gives
1184 * this to us clients can't change it.
1185 */
1186 if (mContext == null) {
1187 mContext = context;
Dianne Hackborn2af632f2009-07-08 14:56:37 -07001188 mMyUid = Process.myUid();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 if (info != null) {
1190 setReadPermission(info.readPermission);
1191 setWritePermission(info.writePermission);
Dianne Hackborn2af632f2009-07-08 14:56:37 -07001192 setPathPermissions(info.pathPermissions);
Dianne Hackbornb424b632010-08-18 15:59:05 -07001193 mExported = info.exported;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001194 }
1195 ContentProvider.this.onCreate();
1196 }
1197 }
Fred Quintanace31b232009-05-04 16:01:15 -07001198
1199 /**
Dan Egnor17876aa2010-07-28 12:28:04 -07001200 * Override this to handle requests to perform a batch of operations, or the
1201 * default implementation will iterate over the operations and call
1202 * {@link ContentProviderOperation#apply} on each of them.
1203 * If all calls to {@link ContentProviderOperation#apply} succeed
1204 * then a {@link ContentProviderResult} array with as many
1205 * elements as there were operations will be returned. If any of the calls
Dan Egnor6fcc0f0732010-07-27 16:32:17 -07001206 * fail, it is up to the implementation how many of the others take effect.
1207 * This method can be called from multiple threads, as described in
Scott Main7aee61f2011-02-08 11:25:01 -08001208 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
1209 * and Threads</a>.
Dan Egnor6fcc0f0732010-07-27 16:32:17 -07001210 *
Fred Quintanace31b232009-05-04 16:01:15 -07001211 * @param operations the operations to apply
1212 * @return the results of the applications
Dan Egnor6fcc0f0732010-07-27 16:32:17 -07001213 * @throws OperationApplicationException thrown if any operation fails.
1214 * @see ContentProviderOperation#apply
Fred Quintanace31b232009-05-04 16:01:15 -07001215 */
Fred Quintana03d94902009-05-22 14:23:31 -07001216 public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
Fred Quintanace31b232009-05-04 16:01:15 -07001217 throws OperationApplicationException {
Fred Quintana03d94902009-05-22 14:23:31 -07001218 final int numOperations = operations.size();
1219 final ContentProviderResult[] results = new ContentProviderResult[numOperations];
1220 for (int i = 0; i < numOperations; i++) {
1221 results[i] = operations.get(i).apply(this, results, i);
Fred Quintanace31b232009-05-04 16:01:15 -07001222 }
1223 return results;
1224 }
Brad Fitzpatrick1877d012010-03-04 17:48:13 -08001225
1226 /**
Dianne Hackborn961321f2013-02-05 17:22:41 -08001227 * @hide
1228 * Front-end to {@link #call(String, String, android.os.Bundle)} that provides the name
1229 * of the calling package.
1230 */
1231 public Bundle callFromPackage(String callingPackag, String method, String arg, Bundle extras) {
1232 return call(method, arg, extras);
1233 }
1234
1235 /**
Manuel Roman2c96a0c2010-08-05 16:39:49 -07001236 * Call a provider-defined method. This can be used to implement
Brad Fitzpatrick534c84c2011-01-12 14:06:30 -08001237 * interfaces that are cheaper and/or unnatural for a table-like
1238 * model.
Brad Fitzpatrick1877d012010-03-04 17:48:13 -08001239 *
Christopher Tate2bc6eb82013-01-03 12:04:08 -08001240 * @param method method name to call. Opaque to framework, but should not be {@code null}.
1241 * @param arg provider-defined String argument. May be {@code null}.
1242 * @param extras provider-defined Bundle argument. May be {@code null}.
1243 * @return provider-defined return value. May be {@code null}, which is also
Brad Fitzpatrick534c84c2011-01-12 14:06:30 -08001244 * the default for providers which don't implement any call methods.
Brad Fitzpatrick1877d012010-03-04 17:48:13 -08001245 */
Brad Fitzpatrick534c84c2011-01-12 14:06:30 -08001246 public Bundle call(String method, String arg, Bundle extras) {
Brad Fitzpatrick1877d012010-03-04 17:48:13 -08001247 return null;
1248 }
Vasu Nori0c9e14a2010-08-04 13:31:48 -07001249
1250 /**
Manuel Roman2c96a0c2010-08-05 16:39:49 -07001251 * Implement this to shut down the ContentProvider instance. You can then
1252 * invoke this method in unit tests.
1253 *
Vasu Nori0c9e14a2010-08-04 13:31:48 -07001254 * <p>
Manuel Roman2c96a0c2010-08-05 16:39:49 -07001255 * Android normally handles ContentProvider startup and shutdown
1256 * automatically. You do not need to start up or shut down a
1257 * ContentProvider. When you invoke a test method on a ContentProvider,
1258 * however, a ContentProvider instance is started and keeps running after
1259 * the test finishes, even if a succeeding test instantiates another
1260 * ContentProvider. A conflict develops because the two instances are
1261 * usually running against the same underlying data source (for example, an
1262 * sqlite database).
1263 * </p>
Vasu Nori0c9e14a2010-08-04 13:31:48 -07001264 * <p>
Manuel Roman2c96a0c2010-08-05 16:39:49 -07001265 * Implementing shutDown() avoids this conflict by providing a way to
1266 * terminate the ContentProvider. This method can also prevent memory leaks
1267 * from multiple instantiations of the ContentProvider, and it can ensure
1268 * unit test isolation by allowing you to completely clean up the test
1269 * fixture before moving on to the next test.
1270 * </p>
Vasu Nori0c9e14a2010-08-04 13:31:48 -07001271 */
1272 public void shutdown() {
1273 Log.w(TAG, "implement ContentProvider shutdown() to make sure all database " +
1274 "connections are gracefully shutdown");
1275 }
Marco Nelissen18cb2872011-11-15 11:19:53 -08001276
1277 /**
1278 * Print the Provider's state into the given stream. This gets invoked if
Jeff Sharkey5554b702012-04-11 18:30:51 -07001279 * you run "adb shell dumpsys activity provider &lt;provider_component_name&gt;".
Marco Nelissen18cb2872011-11-15 11:19:53 -08001280 *
Marco Nelissen18cb2872011-11-15 11:19:53 -08001281 * @param fd The raw file descriptor that the dump is being sent to.
1282 * @param writer The PrintWriter to which you should dump your state. This will be
1283 * closed for you after you return.
1284 * @param args additional arguments to the dump request.
Marco Nelissen18cb2872011-11-15 11:19:53 -08001285 */
1286 public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
1287 writer.println("nothing to dump");
1288 }
Brad Fitzpatrick1877d012010-03-04 17:48:13 -08001289}