Builder
class Builder
kotlin.Any | |
↳ | android.app.appsearch.SetSchemaRequest.Builder |
Builder for SetSchemaRequest
objects.
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
SetSchemaRequest.Builder |
addRequiredPermissionsForSchemaTypeVisibility(schemaType: String, permissions: MutableSet<Int!>) Adds a set of required Android |
SetSchemaRequest.Builder |
addSchemaTypeVisibleToConfig(schemaType: String, schemaVisibilityConfig: SchemaVisibilityConfig) Sets the documents from the provided |
SetSchemaRequest.Builder |
addSchemas(vararg schemas: AppSearchSchema!) Adds one or more |
SetSchemaRequest.Builder |
addSchemas(schemas: MutableCollection<AppSearchSchema!>) Adds a collection of |
SetSchemaRequest |
build() Builds a new |
SetSchemaRequest.Builder |
clearRequiredPermissionsForSchemaTypeVisibility(schemaType: String) Clears all required permissions combinations for the given schema type. |
SetSchemaRequest.Builder |
clearSchemaTypeVisibleToConfigs(schemaType: String) Clears all visible to |
SetSchemaRequest.Builder |
setForceOverride(forceOverride: Boolean) Sets whether or not to override the current schema in the |
SetSchemaRequest.Builder |
setMigrator(schemaType: String, migrator: Migrator) Sets the |
SetSchemaRequest.Builder |
setMigrators(migrators: MutableMap<String!, Migrator!>) Sets a Map of |
SetSchemaRequest.Builder |
setPubliclyVisibleSchema(schema: String, packageIdentifier: PackageIdentifier?) Specify that the schema should be publicly available, to packages which already have visibility to |
SetSchemaRequest.Builder |
setSchemaTypeDisplayedBySystem(schemaType: String, displayed: Boolean) Sets whether or not documents from the provided |
SetSchemaRequest.Builder |
setSchemaTypeVisibilityForPackage(schemaType: String, visible: Boolean, packageIdentifier: PackageIdentifier) Sets whether or not documents from the provided |
SetSchemaRequest.Builder |
setVersion(version: Int) Sets the version number of the overall |
Public constructors
Public methods
addRequiredPermissionsForSchemaTypeVisibility
fun addRequiredPermissionsForSchemaTypeVisibility(
schemaType: String,
permissions: MutableSet<Int!>
): SetSchemaRequest.Builder
Adds a set of required Android android.Manifest.permission
combination to the given schema type.
If the querier holds ALL of the required permissions in this combination, they will have access to read GenericDocument
objects of the given schema type.
You can call this method to add multiple permission combinations, and the querier will have access if they holds ANY of the combinations.
The supported Permissions are READ_SMS
, READ_CALENDAR
, READ_CONTACTS
, READ_EXTERNAL_STORAGE
, READ_HOME_APP_SEARCH_DATA
and READ_ASSISTANT_APP_SEARCH_DATA
.
The relationship between permissions added in this method and package visibility setting setSchemaTypeVisibilityForPackage
is "OR". The caller could access the schema if they match ANY requirements. If you want to set "AND" requirements like a caller must hold required permissions AND it is a specified package, please use addSchemaTypeVisibleToConfig
.
Parameters | |
---|---|
schemaType |
String: The schema type to set visibility on. This value cannot be null . |
permissions |
MutableSet<Int!>: A set of required Android permissions the caller need to hold to access GenericDocument objects that under the given schema. Value is android.app.appsearch.SetSchemaRequest#READ_SMS , android.app.appsearch.SetSchemaRequest#READ_CALENDAR , android.app.appsearch.SetSchemaRequest#READ_CONTACTS , android.app.appsearch.SetSchemaRequest#READ_EXTERNAL_STORAGE , android.app.appsearch.SetSchemaRequest#READ_HOME_APP_SEARCH_DATA , android.app.appsearch.SetSchemaRequest#READ_ASSISTANT_APP_SEARCH_DATA , android.app.appsearch.SetSchemaRequest.ENTERPRISE_ACCESS, or android.app.appsearch.SetSchemaRequest.MANAGED_PROFILE_CONTACTS_ACCESS This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
– if input unsupported permission. |
addSchemaTypeVisibleToConfig
fun addSchemaTypeVisibleToConfig(
schemaType: String,
schemaVisibilityConfig: SchemaVisibilityConfig
): SetSchemaRequest.Builder
Sets the documents from the provided schemaType
can be read by the caller if they match the ALL visibility requirements set in SchemaVisibilityConfig
.
The requirements in a SchemaVisibilityConfig
is "AND" relationship. A caller must match ALL requirements to access the schema. For example, a caller must hold required permissions AND it is a specified package.
You can call this method repeatedly to add multiple SchemaVisibilityConfig
s, and the querier will have access if they match ANY of the SchemaVisibilityConfig
.
Parameters | |
---|---|
schemaType |
String: The schema type to set visibility on. This value cannot be null . |
schemaVisibilityConfig |
SchemaVisibilityConfig: The SchemaVisibilityConfig holds all requirements that a call must to match to access the schema. This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
addSchemas
fun addSchemas(vararg schemas: AppSearchSchema!): SetSchemaRequest.Builder
Adds one or more AppSearchSchema
types to the schema.
An AppSearchSchema
object represents one type of structured data.
Any documents of these types will be displayed on system UI surfaces by default.
Parameters | |
---|---|
schemas |
AppSearchSchema!: This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
addSchemas
fun addSchemas(schemas: MutableCollection<AppSearchSchema!>): SetSchemaRequest.Builder
Adds a collection of AppSearchSchema
objects to the schema.
An AppSearchSchema
object represents one type of structured data.
Parameters | |
---|---|
schemas |
MutableCollection<AppSearchSchema!>: This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
build
fun build(): SetSchemaRequest
Builds a new SetSchemaRequest
object.
Return | |
---|---|
SetSchemaRequest |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if schema types were referenced, but the corresponding AppSearchSchema type was never added. |
clearRequiredPermissionsForSchemaTypeVisibility
fun clearRequiredPermissionsForSchemaTypeVisibility(schemaType: String): SetSchemaRequest.Builder
Clears all required permissions combinations for the given schema type.
Parameters | |
---|---|
schemaType |
String: This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
clearSchemaTypeVisibleToConfigs
fun clearSchemaTypeVisibleToConfigs(schemaType: String): SetSchemaRequest.Builder
Clears all visible to SchemaVisibilityConfig
for the given schema type.
Parameters | |
---|---|
schemaType |
String: This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setForceOverride
fun setForceOverride(forceOverride: Boolean): SetSchemaRequest.Builder
Sets whether or not to override the current schema in the AppSearchSession
database.
Call this method whenever backward incompatible changes need to be made by setting forceOverride
to true
. As a result, during execution of the setSchema operation, all documents that are incompatible with the new schema will be deleted and the new schema will be saved and persisted.
By default, this is false
.
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setMigrator
fun setMigrator(
schemaType: String,
migrator: Migrator
): SetSchemaRequest.Builder
Sets the Migrator
associated with the given SchemaType.
The Migrator
migrates all GenericDocument
s under given schema type from the current version number stored in AppSearch to the final version set via setVersion
.
A Migrator
will be invoked if the current version number stored in AppSearch is different from the final version set via setVersion
and android.app.appsearch.Migrator#shouldMigrate
returns true
.
The target schema type of the output GenericDocument
of android.app.appsearch.Migrator#onUpgrade
or Migrator#onDowngrade
must exist in this SetSchemaRequest
.
Parameters | |
---|---|
schemaType |
String: The schema type to set migrator on. This value cannot be null . |
migrator |
Migrator: The migrator translates a document from its current version to the final version set via setVersion . This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setMigrators
fun setMigrators(migrators: MutableMap<String!, Migrator!>): SetSchemaRequest.Builder
Sets a Map of Migrator
s.
The key of the map is the schema type that the Migrator
value applies to.
The Migrator
migrates all GenericDocument
s under given schema type from the current version number stored in AppSearch to the final version set via setVersion
.
A Migrator
will be invoked if the current version number stored in AppSearch is different from the final version set via setVersion
and android.app.appsearch.Migrator#shouldMigrate
returns true
.
The target schema type of the output GenericDocument
of android.app.appsearch.Migrator#onUpgrade
or Migrator#onDowngrade
must exist in this SetSchemaRequest
.
Parameters | |
---|---|
migrators |
MutableMap<String!, Migrator!>: A Map of migrators that translate a document from its current version to the final version set via setVersion . The key of the map is the schema type that the Migrator value applies to. This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setPubliclyVisibleSchema
fun setPubliclyVisibleSchema(
schema: String,
packageIdentifier: PackageIdentifier?
): SetSchemaRequest.Builder
Specify that the schema should be publicly available, to packages which already have visibility to packageIdentifier
. This visibility is determined by the result of android.content.pm.PackageManager#canPackageQuery.
It is possible for the packageIdentifier parameter to be different from the package performing the indexing. This might happen in the case of an on-device indexer processing information about various packages. The visibility will be the same regardless of which package indexes the document, as the visibility is based on the packageIdentifier parameter.
If this is called repeatedly with the same schema, the PackageIdentifier
in the last call will be used as the "from" package for that schema.
Calling this with packageIdentifier set to null is valid, and will remove public visibility for the schema.
Parameters | |
---|---|
schema |
String: the schema to make publicly accessible. This value cannot be null . |
packageIdentifier |
PackageIdentifier?: if an app can see this package via PackageManager#canPackageQuery, it will be able to see the documents of type schema . This value may be null . |
setSchemaTypeDisplayedBySystem
fun setSchemaTypeDisplayedBySystem(
schemaType: String,
displayed: Boolean
): SetSchemaRequest.Builder
Sets whether or not documents from the provided schemaType
will be displayed and visible on any system UI surface.
This setting applies to the provided schemaType
only, and does not persist across AppSearchSession#setSchema
calls.
The default behavior, if this method is not called, is to allow types to be displayed on system UI surfaces.
Parameters | |
---|---|
schemaType |
String: The name of an AppSearchSchema within the same SetSchemaRequest , which will be configured. This value cannot be null . |
displayed |
Boolean: Whether documents of this type will be displayed on system UI surfaces. |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setSchemaTypeVisibilityForPackage
fun setSchemaTypeVisibilityForPackage(
schemaType: String,
visible: Boolean,
packageIdentifier: PackageIdentifier
): SetSchemaRequest.Builder
Sets whether or not documents from the provided schemaType
can be read by the specified package.
Each package is represented by a PackageIdentifier
, containing a package name and a byte array of type android.content.pm.PackageManager#CERT_INPUT_SHA256
.
To opt into one-way data sharing with another application, the developer will need to explicitly grant the other application’s package name and certificate Read access to its data.
For two-way data sharing, both applications need to explicitly grant Read access to one another.
By default, data sharing between applications is disabled.
The relationship between permissions added in this method and package visibility setting setSchemaTypeVisibilityForPackage
is "OR". The caller could access the schema if they match ANY requirements. If you want to set "AND" requirements like a caller must hold required permissions AND it is a specified package, please use addSchemaTypeVisibleToConfig
.
Parameters | |
---|---|
schemaType |
String: The schema type to set visibility on. This value cannot be null . |
visible |
Boolean: Whether the schemaType will be visible or not. |
packageIdentifier |
PackageIdentifier: Represents the package that will be granted visibility. This value cannot be null . |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
setVersion
fun setVersion(version: Int): SetSchemaRequest.Builder
Sets the version number of the overall AppSearchSchema
in the database.
The AppSearchSession
database can only ever hold documents for one version at a time.
Setting a version number that is different from the version number currently stored in AppSearch will result in AppSearch calling the Migrator
s provided to android.app.appsearch.AppSearchSession#setSchema
to migrate the documents already in AppSearch from the previous version to the one set in this request. The version number can be updated without any other changes to the set of schemas.
The version number can stay the same, increase, or decrease relative to the current version number that is already stored in the AppSearchSession
database.
The version of an empty database will always be 0. You cannot set version to the SetSchemaRequest
, if it doesn't contains any AppSearchSchema
.
Parameters | |
---|---|
version |
Int: A positive integer representing the version of the entire set of schemas represents the version of the whole schema in the AppSearchSession database, default version is 1. Value is 1 or greater |
Return | |
---|---|
SetSchemaRequest.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the version is negative. |