BuiltInCorpusFilters


@ExperimentalAppSearchApi
public class BuiltInCorpusFilters


Methods to add filters to SearchSpec.Builders to search over on-device corpora for builtin types Person and MobileApplication.

Summary

Public methods

static @NonNull SearchSpec.Builder
@RequiresPermission(value = Manifest.permission.QUERY_ALL_PACKAGES, conditional = true)
searchMobileApplicationCorpus(@NonNull SearchSpec.Builder builder)

Adds a filter for the MobileApplication corpus to the given .

static @NonNull SearchSpec.Builder
@RequiresPermission(value = Manifest.permission.READ_CONTACTS)
searchPersonCorpus(@NonNull SearchSpec.Builder builder)

Adds a filter for the Person corpus to the given SearchSpec.Builder.

Public methods

searchMobileApplicationCorpus

Added in 1.1.0-beta01
@RequiresPermission(value = Manifest.permission.QUERY_ALL_PACKAGES, conditional = true)
public static @NonNull SearchSpec.Builder searchMobileApplicationCorpus(@NonNull SearchSpec.Builder builder)

Adds a filter for the MobileApplication corpus to the given .

The MobileApplication corpus is a corpus of all apps on the device. Each document contains information about the app such as label, package id, and icon uri. This corpus is useful for displaying a list of apps available on device, such as from a search app.

The corpus is set up such that if an app has visibility to a package via canPackageQuery, the app can retrieve the document corresponding to the package. If an app has the QUERY_ALL_PACKAGES permission, they can also retrieve all MobileApplication documents. Because of this visibility setup, each MobileApplication document has its own schema. The namespace is provided here as all MobileApplication documents share a common namespace.

The "android" package is the package that indexes the MobileApplication corpus.

Parameters
@NonNull SearchSpec.Builder builder

The SearchSpec.Builder to add the filter to.

searchPersonCorpus

Added in 1.1.0-beta01
@RequiresPermission(value = Manifest.permission.READ_CONTACTS)
public static @NonNull SearchSpec.Builder searchPersonCorpus(@NonNull SearchSpec.Builder builder)

Adds a filter for the Person corpus to the given SearchSpec.Builder.

The Person corpus is a corpus of all the contacts available on the device. Each document contains information about the contact such as given name, family name, notes, relations, and contact points. This corpus is useful for apps that need a list of contacts available on device, such as a contacts app or a dialer app.

The READ_CONTACTS permission is required to query this corpus. Without this permission, no documents will be returned on search. The schema type is provided here as all Person documents a schema type, so they can be queried by filtering on the schema type as shown in the following code. Person documents do also share a namespace as well, however to restrict a search to the Person corpus, it is sufficient to filter on the schema.

The "android" package is the package that indexes the Person corpus.

Parameters
@NonNull SearchSpec.Builder builder

The SearchSpec.Builder to add the filter to.