@Implements(value=android.content.ContentResolver.class) public class ShadowContentResolver extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ShadowContentResolver.DeleteStatement
A statement used to delete content in a
ContentProvider . |
static class |
ShadowContentResolver.InsertStatement
A statement used to insert content into a
ContentProvider . |
static class |
ShadowContentResolver.NotifiedUri |
static class |
ShadowContentResolver.Statement
A statement used to modify content in a
ContentProvider . |
static class |
ShadowContentResolver.Status |
static class |
ShadowContentResolver.UpdateStatement
A statement used to update content in a
ContentProvider . |
Constructor and Description |
---|
ShadowContentResolver() |
Modifier and Type | Method and Description |
---|---|
protected android.content.ContentProviderClient |
acquireContentProviderClient(java.lang.String name) |
protected android.content.ContentProviderClient |
acquireContentProviderClient(android.net.Uri uri) |
protected android.content.IContentProvider |
acquireProvider(java.lang.String name) |
protected android.content.IContentProvider |
acquireProvider(android.net.Uri uri) |
protected android.content.ContentProviderClient |
acquireUnstableContentProviderClient(java.lang.String name) |
protected android.content.ContentProviderClient |
acquireUnstableContentProviderClient(android.net.Uri uri) |
protected android.content.IContentProvider |
acquireUnstableProvider(java.lang.String name) |
protected android.content.IContentProvider |
acquireUnstableProvider(android.net.Uri uri) |
protected static void |
addPeriodicSync(android.accounts.Account account,
java.lang.String authority,
android.os.Bundle extras,
long pollFrequency) |
protected android.content.ContentProviderResult[] |
applyBatch(java.lang.String authority,
java.util.ArrayList<android.content.ContentProviderOperation> operations) |
protected int |
bulkInsert(android.net.Uri url,
android.content.ContentValues[] values)
If a
ContentProvider is registered for the given Uri , its ContentProvider.bulkInsert(Uri, ContentValues[]) method will be invoked. |
protected android.os.Bundle |
call(android.net.Uri uri,
java.lang.String method,
java.lang.String arg,
android.os.Bundle extras) |
protected static void |
cancelSync(android.accounts.Account account,
java.lang.String authority) |
protected int |
delete(android.net.Uri url,
java.lang.String where,
java.lang.String[] selectionArgs)
If a
ContentProvider is registered for the given Uri , its ContentProvider.delete(Uri, String, String[]) method will be invoked. |
java.util.Collection<android.database.ContentObserver> |
getContentObservers(android.net.Uri uri)
Returns the content observers registered for updates under the given URI.
|
java.util.List<android.content.ContentProviderOperation> |
getContentProviderOperations(java.lang.String authority) |
java.util.List<android.net.Uri> |
getDeletedUris() |
java.util.List<ShadowContentResolver.DeleteStatement> |
getDeleteStatements()
Returns the list of
ShadowContentResolver.DeleteStatement s for corresponding calls to ContentResolver.delete(Uri, String, String[]) . |
java.util.List<ShadowContentResolver.InsertStatement> |
getInsertStatements()
Returns the list of
ShadowContentResolver.InsertStatement s for corresponding calls to ContentResolver.insert(Uri, ContentValues) or ContentResolver.bulkInsert(Uri, ContentValues[]) . |
protected static int |
getIsSyncable(android.accounts.Account account,
java.lang.String authority) |
protected static boolean |
getMasterSyncAutomatically() |
java.util.List<ShadowContentResolver.NotifiedUri> |
getNotifiedUris() |
protected static java.util.List<android.content.PeriodicSync> |
getPeriodicSyncs(android.accounts.Account account,
java.lang.String authority) |
protected java.util.List<android.content.UriPermission> |
getPersistedUriPermissions() |
static android.content.ContentProvider |
getProvider(android.net.Uri uri) |
java.util.List<ShadowContentResolver.Statement> |
getStatements()
Returns the list of
ShadowContentResolver.InsertStatement s, ShadowContentResolver.UpdateStatement s, and ShadowContentResolver.DeleteStatement s invoked on this ContentResolver . |
static ShadowContentResolver.Status |
getStatus(android.accounts.Account account,
java.lang.String authority) |
static ShadowContentResolver.Status |
getStatus(android.accounts.Account account,
java.lang.String authority,
boolean create)
Retrieve information on the status of the given account.
|
protected static android.content.SyncAdapterType[] |
getSyncAdapterTypes() |
protected static boolean |
getSyncAutomatically(android.accounts.Account account,
java.lang.String authority) |
protected java.lang.String |
getType(android.net.Uri uri) |
java.util.List<ShadowContentResolver.UpdateStatement> |
getUpdateStatements()
Returns the list of
ShadowContentResolver.UpdateStatement s for corresponding calls to ContentResolver.update(Uri, ContentValues, String, String[]) . |
protected android.net.Uri |
insert(android.net.Uri url,
android.content.ContentValues values)
If a
ContentProvider is registered for the given Uri , its ContentProvider.insert(Uri, ContentValues) method will be invoked. |
protected static boolean |
isSyncActive(android.accounts.Account account,
java.lang.String authority) |
protected void |
notifyChange(android.net.Uri uri,
android.database.ContentObserver observer) |
protected void |
notifyChange(android.net.Uri uri,
android.database.ContentObserver observer,
boolean syncToNetwork) |
protected java.io.InputStream |
openInputStream(android.net.Uri uri) |
protected java.io.OutputStream |
openOutputStream(android.net.Uri uri) |
protected android.database.Cursor |
query(android.net.Uri uri,
java.lang.String[] projection,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String sortOrder) |
protected android.database.Cursor |
query(android.net.Uri uri,
java.lang.String[] projection,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String sortOrder,
android.os.CancellationSignal cancellationSignal) |
protected void |
registerContentObserver(android.net.Uri uri,
boolean notifyForDescendents,
android.database.ContentObserver observer) |
protected void |
registerContentObserver(android.net.Uri uri,
boolean notifyForDescendents,
android.database.ContentObserver observer,
int userHandle) |
void |
registerInputStream(android.net.Uri uri,
java.io.InputStream inputStream) |
void |
registerOutputStream(android.net.Uri uri,
java.io.OutputStream outputStream) |
static void |
registerProviderInternal(java.lang.String authority,
android.content.ContentProvider provider)
Internal-only method, do not use!
|
protected void |
releasePersistableUriPermission(android.net.Uri uri,
int modeFlags) |
protected static void |
removePeriodicSync(android.accounts.Account account,
java.lang.String authority,
android.os.Bundle extras) |
protected static void |
requestSync(android.accounts.Account account,
java.lang.String authority,
android.os.Bundle extras) |
static void |
reset() |
void |
setContentProviderResult(android.content.ContentProviderResult[] contentProviderResults) |
void |
setCursor(BaseCursor cursor) |
void |
setCursor(android.net.Uri uri,
BaseCursor cursorForUri) |
protected static void |
setIsSyncable(android.accounts.Account account,
java.lang.String authority,
int syncable) |
protected static void |
setMasterSyncAutomatically(boolean sync) |
void |
setNextDatabaseIdForInserts(int nextId) |
static void |
setSyncAdapterTypes(android.content.SyncAdapterType[] syncAdapterTypes)
Sets the SyncAdapterType array which will be returned by
getSyncAdapterTypes() . |
protected static void |
setSyncAutomatically(android.accounts.Account account,
java.lang.String authority,
boolean sync) |
protected void |
takePersistableUriPermission(android.net.Uri uri,
int modeFlags) |
protected void |
unregisterContentObserver(android.database.ContentObserver observer) |
protected int |
update(android.net.Uri uri,
android.content.ContentValues values,
java.lang.String where,
java.lang.String[] selectionArgs)
If a
ContentProvider is registered for the given Uri , its ContentProvider.update(Uri, ContentValues, String, String[]) method will be invoked. |
protected static void |
validateSyncExtrasBundle(android.os.Bundle extras) |
@Resetter public static void reset()
public void registerInputStream(android.net.Uri uri, java.io.InputStream inputStream)
public void registerOutputStream(android.net.Uri uri, java.io.OutputStream outputStream)
@Implementation protected final java.io.InputStream openInputStream(android.net.Uri uri)
@Implementation protected final java.io.OutputStream openOutputStream(android.net.Uri uri)
@Implementation protected final android.net.Uri insert(android.net.Uri url, android.content.ContentValues values)
If a ContentProvider
is registered for the given Uri
, its ContentProvider.insert(Uri, ContentValues)
method will be invoked.
Tests can verify that this method was called using getStatements()
or getInsertStatements()
.
If no appropriate ContentProvider
is found, no action will be taken and a Uri
including the incremented value set with setNextDatabaseIdForInserts(int)
will returned.
@Implementation protected int update(android.net.Uri uri, android.content.ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)
If a ContentProvider
is registered for the given Uri
, its ContentProvider.update(Uri, ContentValues, String, String[])
method will be invoked.
Tests can verify that this method was called using getStatements()
or getUpdateStatements()
.
ContentProvider
is found, no action will be taken and 1 will be returned.@Implementation protected final android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)
@Implementation protected android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder, android.os.CancellationSignal cancellationSignal)
@Implementation protected java.lang.String getType(android.net.Uri uri)
@Implementation protected android.os.Bundle call(android.net.Uri uri, java.lang.String method, java.lang.String arg, android.os.Bundle extras)
@Implementation protected final android.content.ContentProviderClient acquireContentProviderClient(java.lang.String name)
@Implementation protected final android.content.ContentProviderClient acquireContentProviderClient(android.net.Uri uri)
@Implementation protected final android.content.ContentProviderClient acquireUnstableContentProviderClient(java.lang.String name)
@Implementation protected final android.content.ContentProviderClient acquireUnstableContentProviderClient(android.net.Uri uri)
@Implementation protected final android.content.IContentProvider acquireProvider(java.lang.String name)
@Implementation protected final android.content.IContentProvider acquireProvider(android.net.Uri uri)
@Implementation protected final android.content.IContentProvider acquireUnstableProvider(java.lang.String name)
@Implementation protected final android.content.IContentProvider acquireUnstableProvider(android.net.Uri uri)
@Implementation protected final int delete(android.net.Uri url, java.lang.String where, java.lang.String[] selectionArgs)
If a ContentProvider
is registered for the given Uri
, its ContentProvider.delete(Uri, String, String[])
method will be invoked.
Tests can verify that this method was called using getDeleteStatements()
or getDeletedUris()
.
If no appropriate ContentProvider
is found, no action will be taken and 1
will be returned.
@Implementation protected final int bulkInsert(android.net.Uri url, android.content.ContentValues[] values)
If a ContentProvider
is registered for the given Uri
, its ContentProvider.bulkInsert(Uri, ContentValues[])
method will be invoked.
Tests can verify that this method was called using getStatements()
or getInsertStatements()
.
If no appropriate ContentProvider
is found, no action will be taken and the number of rows in values
will be returned.
@Implementation protected void notifyChange(android.net.Uri uri, android.database.ContentObserver observer, boolean syncToNetwork)
@Implementation protected void notifyChange(android.net.Uri uri, android.database.ContentObserver observer)
@Implementation protected android.content.ContentProviderResult[] applyBatch(java.lang.String authority, java.util.ArrayList<android.content.ContentProviderOperation> operations) throws android.content.OperationApplicationException
android.content.OperationApplicationException
@Implementation protected static void requestSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)
@Implementation protected static void cancelSync(android.accounts.Account account, java.lang.String authority)
@Implementation protected static boolean isSyncActive(android.accounts.Account account, java.lang.String authority)
@Implementation protected static void setIsSyncable(android.accounts.Account account, java.lang.String authority, int syncable)
@Implementation protected static int getIsSyncable(android.accounts.Account account, java.lang.String authority)
@Implementation protected static boolean getSyncAutomatically(android.accounts.Account account, java.lang.String authority)
@Implementation protected static void setSyncAutomatically(android.accounts.Account account, java.lang.String authority, boolean sync)
@Implementation protected static void addPeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras, long pollFrequency)
@Implementation protected static void removePeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)
@Implementation protected static java.util.List<android.content.PeriodicSync> getPeriodicSyncs(android.accounts.Account account, java.lang.String authority)
@Implementation protected static void validateSyncExtrasBundle(android.os.Bundle extras)
@Implementation protected static void setMasterSyncAutomatically(boolean sync)
@Implementation protected static boolean getMasterSyncAutomatically()
@Implementation(minSdk=19) protected void takePersistableUriPermission(android.net.Uri uri, int modeFlags)
@Implementation(minSdk=19) protected void releasePersistableUriPermission(android.net.Uri uri, int modeFlags)
@Implementation(minSdk=19) protected java.util.List<android.content.UriPermission> getPersistedUriPermissions()
public static android.content.ContentProvider getProvider(android.net.Uri uri)
public static void registerProviderInternal(java.lang.String authority, android.content.ContentProvider provider)
Internal-only method, do not use!
Instead, use
ProviderInfo info = new ProviderInfo();
info.authority = authority;
Robolectric.buildContentProvider(ContentProvider.class).create(info);
public static ShadowContentResolver.Status getStatus(android.accounts.Account account, java.lang.String authority)
public static ShadowContentResolver.Status getStatus(android.accounts.Account account, java.lang.String authority, boolean create)
Retrieve information on the status of the given account.
account
- the accountauthority
- the authoritycreate
- whether to create if no such account is foundpublic void setCursor(BaseCursor cursor)
public void setCursor(android.net.Uri uri, BaseCursor cursorForUri)
public void setNextDatabaseIdForInserts(int nextId)
public java.util.List<ShadowContentResolver.Statement> getStatements()
Returns the list of ShadowContentResolver.InsertStatement
s, ShadowContentResolver.UpdateStatement
s, and ShadowContentResolver.DeleteStatement
s invoked on this ContentResolver
.
public java.util.List<ShadowContentResolver.InsertStatement> getInsertStatements()
Returns the list of ShadowContentResolver.InsertStatement
s for corresponding calls to ContentResolver.insert(Uri, ContentValues)
or ContentResolver.bulkInsert(Uri, ContentValues[])
.
public java.util.List<ShadowContentResolver.UpdateStatement> getUpdateStatements()
Returns the list of ShadowContentResolver.UpdateStatement
s for corresponding calls to ContentResolver.update(Uri, ContentValues, String, String[])
.
public java.util.List<android.net.Uri> getDeletedUris()
public java.util.List<ShadowContentResolver.DeleteStatement> getDeleteStatements()
Returns the list of ShadowContentResolver.DeleteStatement
s for corresponding calls to ContentResolver.delete(Uri, String, String[])
.
public java.util.List<ShadowContentResolver.NotifiedUri> getNotifiedUris()
public java.util.List<android.content.ContentProviderOperation> getContentProviderOperations(java.lang.String authority)
public void setContentProviderResult(android.content.ContentProviderResult[] contentProviderResults)
@Implementation protected void registerContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer)
@Implementation(minSdk=17) protected void registerContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer, int userHandle)
@Implementation protected void unregisterContentObserver(android.database.ContentObserver observer)
@Implementation protected static android.content.SyncAdapterType[] getSyncAdapterTypes()
public static void setSyncAdapterTypes(android.content.SyncAdapterType[] syncAdapterTypes)
Sets the SyncAdapterType array which will be returned by getSyncAdapterTypes()
.
public java.util.Collection<android.database.ContentObserver> getContentObservers(android.net.Uri uri)
Returns the content observers registered for updates under the given URI.
Will be empty if no observer is registered.
uri
- Given URI