| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.test.mock; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.content.AttributionSource; |
| 22 |
import android.content.ContentProviderOperation; |
| 23 |
import android.content.ContentProviderResult; |
| 24 |
import android.content.ContentResolver; |
| 25 |
import android.content.ContentValues; |
| 26 |
import android.content.EntityIterator; |
| 27 |
import android.content.IContentProvider; |
| 28 |
import android.content.res.AssetFileDescriptor; |
| 29 |
import android.database.Cursor; |
| 30 |
import android.net.Uri; |
| 31 |
import android.os.AsyncTask; |
| 32 |
import android.os.Bundle; |
| 33 |
import android.os.IBinder; |
| 34 |
import android.os.ICancellationSignal; |
| 35 |
import android.os.ParcelFileDescriptor; |
| 36 |
import android.os.RemoteCallback; |
| 37 |
import android.os.RemoteException; |
| 38 |
|
| 39 |
import java.io.FileNotFoundException; |
| 40 |
import java.util.ArrayList; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public class MockIContentProvider implements IContentProvider { |
| 50 |
@Override |
| 51 |
public int bulkInsert(@NonNull AttributionSource attributionSource, Uri url, |
| 52 |
ContentValues[] initialValues) { |
| 53 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
@SuppressWarnings("unused") |
| 58 |
public int delete(@NonNull AttributionSource attributionSource, Uri url, |
| 59 |
Bundle extras) throws RemoteException { |
| 60 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public String getType(Uri url) { |
| 65 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
@SuppressWarnings("deprecation") |
| 70 |
public void getTypeAsync(Uri uri, RemoteCallback remoteCallback) { |
| 71 |
AsyncTask.SERIAL_EXECUTOR.execute(() -> { |
| 72 |
final Bundle bundle = new Bundle(); |
| 73 |
bundle.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getType(uri)); |
| 74 |
remoteCallback.sendResult(bundle); |
| 75 |
}); |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
@SuppressWarnings("unused") |
| 80 |
public Uri insert(@NonNull AttributionSource attributionSource, Uri url, |
| 81 |
ContentValues initialValues, Bundle extras) throws RemoteException { |
| 82 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public ParcelFileDescriptor openFile(@NonNull AttributionSource attributionSource, |
| 87 |
Uri url, String mode, ICancellationSignal signal) { |
| 88 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public AssetFileDescriptor openAssetFile(@NonNull AttributionSource attributionSource, |
| 93 |
Uri uri, String mode, ICancellationSignal signal) { |
| 94 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 95 |
} |
| 96 |
|
| 97 |
@Override |
| 98 |
public ContentProviderResult[] applyBatch(@NonNull AttributionSource attributionSource, |
| 99 |
String authority, ArrayList<ContentProviderOperation> operations) { |
| 100 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 101 |
} |
| 102 |
|
| 103 |
@Override |
| 104 |
public Cursor query(@NonNull AttributionSource attributionSource, Uri url, |
| 105 |
@Nullable String[] projection, @Nullable Bundle queryArgs, |
| 106 |
@Nullable ICancellationSignal cancellationSignal) { |
| 107 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 108 |
} |
| 109 |
|
| 110 |
public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, |
| 111 |
String sortOrder) { |
| 112 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 113 |
} |
| 114 |
|
| 115 |
@Override |
| 116 |
public int update(@NonNull AttributionSource attributionSource, Uri url, |
| 117 |
ContentValues values, Bundle extras) throws RemoteException { |
| 118 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 119 |
} |
| 120 |
|
| 121 |
@Override |
| 122 |
public Bundle call(@NonNull AttributionSource attributionSource, String authority, |
| 123 |
String method, String request, Bundle args) throws RemoteException { |
| 124 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 125 |
} |
| 126 |
|
| 127 |
@Override |
| 128 |
public IBinder asBinder() { |
| 129 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 130 |
} |
| 131 |
|
| 132 |
@Override |
| 133 |
public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { |
| 134 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 135 |
} |
| 136 |
|
| 137 |
@Override |
| 138 |
public AssetFileDescriptor openTypedAssetFile(@NonNull AttributionSource attributionSource, |
| 139 |
Uri url, String mimeType, Bundle opts, ICancellationSignal signal) |
| 140 |
throws RemoteException, FileNotFoundException { |
| 141 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 142 |
} |
| 143 |
|
| 144 |
@Override |
| 145 |
public ICancellationSignal createCancellationSignal() throws RemoteException { |
| 146 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 147 |
} |
| 148 |
|
| 149 |
@Override |
| 150 |
public Uri canonicalize(@NonNull AttributionSource attributionSource, Uri uri) { |
| 151 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 152 |
} |
| 153 |
|
| 154 |
@Override |
| 155 |
@SuppressWarnings("deprecation") |
| 156 |
public void canonicalizeAsync(@NonNull AttributionSource attributionSource, Uri uri, |
| 157 |
RemoteCallback remoteCallback) { |
| 158 |
AsyncTask.SERIAL_EXECUTOR.execute(() -> { |
| 159 |
final Bundle bundle = new Bundle(); |
| 160 |
bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, |
| 161 |
canonicalize(attributionSource, uri)); |
| 162 |
remoteCallback.sendResult(bundle); |
| 163 |
}); |
| 164 |
} |
| 165 |
|
| 166 |
@Override |
| 167 |
public Uri uncanonicalize(@NonNull AttributionSource attributionSource, Uri uri) { |
| 168 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 169 |
} |
| 170 |
|
| 171 |
@Override |
| 172 |
@SuppressWarnings("deprecation") |
| 173 |
public void uncanonicalizeAsync(@NonNull AttributionSource attributionSource, Uri uri, |
| 174 |
RemoteCallback remoteCallback) { |
| 175 |
AsyncTask.SERIAL_EXECUTOR.execute(() -> { |
| 176 |
final Bundle bundle = new Bundle(); |
| 177 |
bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, |
| 178 |
uncanonicalize(attributionSource, uri)); |
| 179 |
remoteCallback.sendResult(bundle); |
| 180 |
}); |
| 181 |
} |
| 182 |
|
| 183 |
@Override |
| 184 |
public boolean refresh(@NonNull AttributionSource attributionSource, Uri url, Bundle args, |
| 185 |
ICancellationSignal cancellationSignal) throws RemoteException { |
| 186 |
throw new UnsupportedOperationException("unimplemented mock method"); |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
@Override |
| 191 |
public int checkUriPermission(@NonNull AttributionSource attributionSource, Uri uri, int uid, |
| 192 |
int modeFlags) { |
| 193 |
throw new UnsupportedOperationException("unimplemented mock method call"); |
| 194 |
} |
| 195 |
} |