use of android.content.ContentProvider in project VirtualAPK by didi.
the class RemoteContentProvider method applyBatch.
@NonNull
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) throws OperationApplicationException {
try {
Field uriField = ContentProviderOperation.class.getDeclaredField("mUri");
uriField.setAccessible(true);
for (ContentProviderOperation operation : operations) {
Uri pluginUri = Uri.parse(operation.getUri().getQueryParameter(KEY_URI));
uriField.set(operation, pluginUri);
}
} catch (Exception e) {
return new ContentProviderResult[0];
}
if (operations.size() > 0) {
ContentProvider provider = getContentProvider(operations.get(0).getUri());
if (provider != null) {
return provider.applyBatch(operations);
}
}
return new ContentProviderResult[0];
}
use of android.content.ContentProvider in project VirtualAPK by didi.
the class RemoteContentProvider method update.
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
ContentProvider provider = getContentProvider(uri);
Uri pluginUri = Uri.parse(uri.getQueryParameter(KEY_URI));
if (provider != null) {
return provider.update(pluginUri, values, selection, selectionArgs);
}
return 0;
}
use of android.content.ContentProvider in project robolectric by robolectric.
the class ShadowContentProviderTest method testSetCallingPackage.
@Config(minSdk = KITKAT)
@Test
public void testSetCallingPackage() {
ContentProvider provider = new TestContentProvider1();
shadowOf(provider).setCallingPackage("calling-package");
assertThat(provider.getCallingPackage()).isEqualTo("calling-package");
}
use of android.content.ContentProvider in project robolectric by robolectric.
the class ShadowContentResolver method bulkInsert.
/**
* If a {@link ContentProvider} is registered for the given {@link Uri}, its {@link
* ContentProvider#bulkInsert(Uri, ContentValues[])} method will be invoked.
*
* Tests can verify that this method was called using {@link #getStatements()} or {@link
* #getInsertStatements()}.
*
* If no appropriate {@link ContentProvider} is found, no action will be taken and the number
* of rows in {@code values} will be returned.
*/
@Implementation
protected final int bulkInsert(Uri url, ContentValues[] values) {
ContentProvider provider = getProvider(url, getContext());
InsertStatement insertStatement = new InsertStatement(url, provider, values);
statements.add(insertStatement);
insertStatements.add(insertStatement);
if (provider != null) {
return provider.bulkInsert(url, values);
} else {
return values.length;
}
}
use of android.content.ContentProvider in project robolectric by robolectric.
the class ShadowContentResolver method query.
@Implementation
protected final Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
ContentProvider provider = getProvider(uri, getContext());
if (provider != null) {
return provider.query(uri, projection, selection, selectionArgs, sortOrder);
} else {
BaseCursor returnCursor = getCursor(uri);
if (returnCursor == null) {
return null;
}
returnCursor.setQuery(uri, projection, selection, selectionArgs, sortOrder);
return returnCursor;
}
}
Aggregations