GlobalSearchSession
public interface GlobalSearchSession extends ReadOnlyGlobalSearchSession, Closeable
Provides a connection to all AppSearch databases the querying application has been granted access to.
In addition to the querying methods available in ReadOnlyGlobalSearchSession, this interface may support write operations such as reportSystemUsageAsync.
All implementations of this interface must be thread safe.
| See also | |
|---|---|
AppSearchSession |
Summary
Public methods |
|
|---|---|
abstract void |
close()Closes the |
default @NonNull ListenableFuture<OpenBlobForReadResponse> |
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_BLOB_HANDLE)Opens a batch of AppSearch Blobs for reading. |
abstract void |
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)Adds an |
abstract @NonNull ListenableFuture<Void> |
Reports that a particular document has been used from a system surface. |
abstract void |
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)Removes previously registered |
Inherited methods |
||||||||
|---|---|---|---|---|---|---|---|---|
|
Public methods
openBlobForReadAsync
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_BLOB_HANDLE)
default @NonNull ListenableFuture<OpenBlobForReadResponse> openBlobForReadAsync(@NonNull Set<AppSearchBlobHandle> handles)
Opens a batch of AppSearch Blobs for reading.
See openBlobForReadAsync for a general description when a blob is open for read.
The returned OpenBlobForReadResponse must be closed after use to avoid resource leaks. Failing to close it will result in system file descriptor exhaustion.
| Parameters | |
|---|---|
@NonNull Set<AppSearchBlobHandle> handles |
The |
| Returns | |
|---|---|
@NonNull ListenableFuture<OpenBlobForReadResponse> |
a response containing the readable file descriptors. |
| See also | |
|---|---|
setPropertyBlobHandle |
registerObserverCallback
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)
abstract void registerObserverCallback(
@NonNull String targetPackageName,
@NonNull ObserverSpec spec,
@NonNull Executor executor,
@NonNull ObserverCallback observer
)
Adds an ObserverCallback to monitor changes within the databases owned by targetPackageName if they match the given androidx.appsearch.observer.ObserverSpec.
The observer callback is only triggered for data that changes after it is registered. No notification about existing data is sent as a result of registering an observer. To find out about existing data, you must use the search API.
If the data owned by targetPackageName is not visible to you, the registration call will succeed but no notifications will be dispatched. Notifications could start flowing later if targetPackageName changes its schema visibility settings.
If no package matching targetPackageName exists on the system, the registration call will succeed but no notifications will be dispatched. Notifications could start flowing later if targetPackageName is installed and starts indexing data.
This feature may not be available in all implementations. Check GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK before calling this method.
| Parameters | |
|---|---|
@NonNull String targetPackageName |
Package whose changes to monitor |
@NonNull ObserverSpec spec |
Specification of what types of changes to listen for |
@NonNull Executor executor |
Executor on which to call the |
@NonNull ObserverCallback observer |
Callback to trigger when a schema or document changes |
| Throws | |
|---|---|
androidx.appsearch.exceptions.AppSearchException |
if an error occurs trying to register the observer |
java.lang.UnsupportedOperationException |
if this feature is not available on this AppSearch implementation. |
reportSystemUsageAsync
abstract @NonNull ListenableFuture<Void> reportSystemUsageAsync(@NonNull ReportSystemUsageRequest request)
Reports that a particular document has been used from a system surface.
See reportUsageAsync for a general description of document usage, as well as an API that can be used by the app itself.
Usage reported via this method is accounted separately from usage reported via reportUsageAsync and may be accessed using the constants RANKING_STRATEGY_SYSTEM_USAGE_COUNT and RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP.
| Returns | |
|---|---|
@NonNull ListenableFuture<Void> |
The pending result of performing this operation which resolves to |
unregisterObserverCallback
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK)
abstract void unregisterObserverCallback(
@NonNull String targetPackageName,
@NonNull ObserverCallback observer
)
Removes previously registered ObserverCallback instances from the system.
All instances of ObserverCallback which are registered to observe targetPackageName and compare equal to the provided callback using the provided argument's equals will be removed.
If no matching observers have been registered, this method has no effect. If multiple matching observers have been registered, all will be removed.
This feature may not be available in all implementations. Check GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK before calling this method.
| Parameters | |
|---|---|
@NonNull String targetPackageName |
Package which the observers to be removed are listening to. |
@NonNull ObserverCallback observer |
Callback to unregister. |
| Throws | |
|---|---|
androidx.appsearch.exceptions.AppSearchException |
if an error occurs trying to remove the observer, such as a failure to communicate with the system service in the platform backend. Note that no error will be thrown if the provided observer doesn't match any registered observer. |
java.lang.UnsupportedOperationException |
if this feature is not available on this AppSearch implementation. |