Allow sending of bulk Uri change notifications.

MediaProvider makes heavy use of Uri change notifications, which
currently need to be delivered one at a time through the Binder
interface.  To optimize this, allow callers to provide a collection
of multiple Uris to notify with a single Binder call.

Bug: 134170767
Test: atest cts/tests/tests/content/src/android/content/cts/ContentResolverTest.java
Change-Id: Ifef778e88bb772b5580f70929c6f2e9c166d1c0e
This commit is contained in:
Jeff Sharkey
2019-11-13 13:03:10 -07:00
parent 8a505cde0a
commit 1307f428af
5 changed files with 125 additions and 32 deletions

View File

@@ -16,6 +16,8 @@
package android.test.mock;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
@@ -130,17 +132,47 @@ public class MockContentResolver extends ContentResolver {
}
/**
* Overrides {@link android.content.ContentResolver#notifyChange(Uri, ContentObserver, boolean)
* ContentResolver.notifChange(Uri, ContentObserver, boolean)}. All parameters are ignored.
* The method hides providers linked to MockContentResolver from other observers in the system.
*
* @param uri (Ignored) The uri of the content provider.
* @param observer (Ignored) The observer that originated the change.
* @param syncToNetwork (Ignored) If true, attempt to sync the change to the network.
* Overrides the behavior from the parent class to completely ignore any
* content notifications sent to this object. This effectively hides clients
* from observers elsewhere in the system.
*/
@Override
public void notifyChange(Uri uri,
ContentObserver observer,
public void notifyChange(@NonNull Uri uri, @Nullable ContentObserver observer) {
}
/**
* Overrides the behavior from the parent class to completely ignore any
* content notifications sent to this object. This effectively hides clients
* from observers elsewhere in the system.
*
* @deprecated callers should consider migrating to
* {@link #notifyChange(Uri, ContentObserver, int)}, as it
* offers support for many more options than just
* {@link #NOTIFY_SYNC_TO_NETWORK}.
*/
@Override
@Deprecated
public void notifyChange(@NonNull Uri uri, @Nullable ContentObserver observer,
boolean syncToNetwork) {
}
/**
* Overrides the behavior from the parent class to completely ignore any
* content notifications sent to this object. This effectively hides clients
* from observers elsewhere in the system.
*/
@Override
public void notifyChange(@NonNull Uri uri, @Nullable ContentObserver observer,
@NotifyFlags int flags) {
}
/**
* Overrides the behavior from the parent class to completely ignore any
* content notifications sent to this object. This effectively hides clients
* from observers elsewhere in the system.
*/
@Override
public void notifyChange(@NonNull Iterable<Uri> uris, @Nullable ContentObserver observer,
@NotifyFlags int flags) {
}
}