1 /* 2 * Copyright (C) 2018 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.content; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.res.AssetFileDescriptor; 22 import android.database.Cursor; 23 import android.net.Uri; 24 import android.os.Bundle; 25 import android.os.CancellationSignal; 26 import android.os.ParcelFileDescriptor; 27 import android.os.RemoteException; 28 29 import java.io.FileNotFoundException; 30 import java.util.ArrayList; 31 32 /** 33 * Interface representing calls that can be made to {@link ContentProvider} 34 * instances. 35 * <p> 36 * These methods have been extracted into a general interface so that APIs can 37 * be flexible in accepting either a {@link ContentProvider}, a 38 * {@link ContentResolver}, or a {@link ContentProviderClient}. 39 * 40 * @hide 41 */ 42 public interface ContentInterface { query(@onNull Uri uri, @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)43 public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection, 44 @Nullable Bundle queryArgs, @Nullable CancellationSignal cancellationSignal) 45 throws RemoteException; 46 getType(@onNull Uri uri)47 public @Nullable String getType(@NonNull Uri uri) throws RemoteException; 48 getStreamTypes(@onNull Uri uri, @NonNull String mimeTypeFilter)49 public @Nullable String[] getStreamTypes(@NonNull Uri uri, @NonNull String mimeTypeFilter) 50 throws RemoteException; 51 canonicalize(@onNull Uri uri)52 public @Nullable Uri canonicalize(@NonNull Uri uri) throws RemoteException; 53 uncanonicalize(@onNull Uri uri)54 public @Nullable Uri uncanonicalize(@NonNull Uri uri) throws RemoteException; 55 refresh(@onNull Uri uri, @Nullable Bundle args, @Nullable CancellationSignal cancellationSignal)56 public boolean refresh(@NonNull Uri uri, @Nullable Bundle args, 57 @Nullable CancellationSignal cancellationSignal) throws RemoteException; 58 insert(@onNull Uri uri, @Nullable ContentValues initialValues)59 public @Nullable Uri insert(@NonNull Uri uri, @Nullable ContentValues initialValues) 60 throws RemoteException; 61 bulkInsert(@onNull Uri uri, @NonNull ContentValues[] initialValues)62 public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] initialValues) 63 throws RemoteException; 64 delete(@onNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs)65 public int delete(@NonNull Uri uri, @Nullable String selection, 66 @Nullable String[] selectionArgs) throws RemoteException; 67 update(@onNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs)68 public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, 69 @Nullable String[] selectionArgs) throws RemoteException; 70 openFile(@onNull Uri uri, @NonNull String mode, @Nullable CancellationSignal signal)71 public @Nullable ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode, 72 @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException; 73 openAssetFile(@onNull Uri uri, @NonNull String mode, @Nullable CancellationSignal signal)74 public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri uri, @NonNull String mode, 75 @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException; 76 openTypedAssetFile(@onNull Uri uri, @NonNull String mimeTypeFilter, @Nullable Bundle opts, @Nullable CancellationSignal signal)77 public @Nullable AssetFileDescriptor openTypedAssetFile(@NonNull Uri uri, 78 @NonNull String mimeTypeFilter, @Nullable Bundle opts, 79 @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException; 80 applyBatch(@onNull String authority, @NonNull ArrayList<ContentProviderOperation> operations)81 public @NonNull ContentProviderResult[] applyBatch(@NonNull String authority, 82 @NonNull ArrayList<ContentProviderOperation> operations) 83 throws RemoteException, OperationApplicationException; 84 call(@onNull String authority, @NonNull String method, @Nullable String arg, @Nullable Bundle extras)85 public @Nullable Bundle call(@NonNull String authority, @NonNull String method, 86 @Nullable String arg, @Nullable Bundle extras) throws RemoteException; 87 } 88