SetSchemaRequest.Builder


public final class SetSchemaRequest.Builder


Builder for SetSchemaRequest objects.

Summary

Public constructors

Creates a new SetSchemaRequest.Builder.

Creates a SetSchemaRequest.Builder from the given SetSchemaRequest.

Public methods

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
addDocumentClassVisibleToConfig(
    @NonNull Class<Object> documentClass,
    @NonNull SchemaVisibilityConfig schemaVisibilityConfig
)

Sets the documents from the provided schemaType can be read by the caller if they match the ALL visibility requirements set in SchemaVisibilityConfig.

@NonNull SetSchemaRequest.Builder
addDocumentClasses(@NonNull Class[] documentClasses)

Adds one or more androidx.appsearch.annotation.Document annotated classes to the schema.

@NonNull SetSchemaRequest.Builder

Adds a collection of androidx.appsearch.annotation.Document annotated classes to the schema.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
addRequiredPermissionsForDocumentClassVisibility(
    @NonNull Class<Object> documentClass,
    @NonNull Set<Integer> permissions
)

Adds a set of required Android android.Manifest.permission combination to the given schema type.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
addRequiredPermissionsForSchemaTypeVisibility(
    @NonNull String schemaType,
    @NonNull Set<Integer> permissions
)

Adds a set of required Android android.Manifest.permission combination to the given schema type.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
addSchemaTypeVisibleToConfig(
    @NonNull String schemaType,
    @NonNull SchemaVisibilityConfig schemaVisibilityConfig
)

Sets the documents from the provided schemaType can be read by the caller if they match the ALL visibility requirements set in SchemaVisibilityConfig.

@NonNull SetSchemaRequest.Builder
addSchemas(@NonNull AppSearchSchema[] schemas)

Adds one or more AppSearchSchema types to the schema.

@NonNull SetSchemaRequest.Builder

Adds a collection of AppSearchSchema objects to the schema.

@NonNull SetSchemaRequest

Builds a new SetSchemaRequest object.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
clearDocumentClassVisibleToConfigs(@NonNull Class<Object> documentClass)

Clears all visible to SchemaVisibilityConfig for the given schema type.

@NonNull SetSchemaRequest.Builder

Clears all Migrators.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
clearRequiredPermissionsForDocumentClassVisibility(
    @NonNull Class<Object> documentClass
)

Clears all required permissions combinations for the given schema type.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
clearRequiredPermissionsForSchemaTypeVisibility(
    @NonNull String schemaType
)

Clears all required permissions combinations for the given schema type.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
clearSchemaTypeVisibleToConfigs(@NonNull String schemaType)

Clears all visible to SchemaVisibilityConfig for the given schema type.

@NonNull SetSchemaRequest.Builder

Clears all AppSearchSchemas from the list of schemas.

@NonNull SetSchemaRequest.Builder
setDocumentClassDisplayedBySystem(
    @NonNull Class<Object> documentClass,
    boolean displayed
)

Sets whether or not documents from the provided androidx.appsearch.annotation.Document annotated class will be displayed and visible on any system UI surface.

@NonNull SetSchemaRequest.Builder
setDocumentClassVisibilityForPackage(
    @NonNull Class<Object> documentClass,
    boolean visible,
    @NonNull PackageIdentifier packageIdentifier
)

Sets whether or not documents from the provided androidx.appsearch.annotation.Document annotated class can be read by the specified package.

@NonNull SetSchemaRequest.Builder
setForceOverride(boolean forceOverride)

Sets whether or not to override the current schema in the AppSearchSession database.

@NonNull SetSchemaRequest.Builder
setMigrator(@NonNull String schemaType, @NonNull Migrator migrator)

Sets the Migrator associated with the given SchemaType.

@NonNull SetSchemaRequest.Builder

Sets a Map of Migrators.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_SET_PUBLICLY_VISIBLE)
setPubliclyVisibleDocumentClass(
    @NonNull Class<Object> documentClass,
    @Nullable PackageIdentifier packageIdentifier
)

Specify that the documents from the provided androidx.appsearch.annotation.Document annotated class should be publicly available, to packages which already have visibility to packageIdentifier.

@NonNull SetSchemaRequest.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_SET_PUBLICLY_VISIBLE)
setPubliclyVisibleSchema(
    @NonNull String schema,
    @Nullable PackageIdentifier packageIdentifier
)

Specify that the schema should be publicly available, to packages which already have visibility to packageIdentifier.

@NonNull SetSchemaRequest.Builder
setSchemaTypeDisplayedBySystem(
    @NonNull String schemaType,
    boolean displayed
)

Sets whether or not documents from the provided schemaType will be displayed and visible on any system UI surface.

@NonNull SetSchemaRequest.Builder
setSchemaTypeVisibilityForPackage(
    @NonNull String schemaType,
    boolean visible,
    @NonNull PackageIdentifier packageIdentifier
)

Sets whether or not documents from the provided schemaType can be read by the specified package.

@NonNull SetSchemaRequest.Builder
setVersion(@IntRange(from = 1) int version)

Sets the version number of the overall AppSearchSchema in the database.

Public constructors

Builder

Added in 1.1.0-alpha06
public Builder()

Creates a new SetSchemaRequest.Builder.

Builder

Added in 1.1.0-alpha06
public Builder(@NonNull SetSchemaRequest request)

Creates a SetSchemaRequest.Builder from the given SetSchemaRequest.

Public methods

addDocumentClassVisibleToConfig

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
public @NonNull SetSchemaRequest.Builder addDocumentClassVisibleToConfig(
    @NonNull Class<Object> documentClass,
    @NonNull SchemaVisibilityConfig schemaVisibilityConfig
)

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 SchemaVisibilityConfigs, and the querier will have access if they match ANY of the SchemaVisibilityConfig.

Parameters
@NonNull Class<Object> documentClass

A class annotated with androidx.appsearch.annotation.Document, the visibility of which will be configured

@NonNull SchemaVisibilityConfig schemaVisibilityConfig

The SchemaVisibilityConfig holds all requirements that a call must to match to access the schema.

addDocumentClasses

public @NonNull SetSchemaRequest.Builder addDocumentClasses(@NonNull Class[] documentClasses)

Adds one or more androidx.appsearch.annotation.Document annotated classes to the schema.

Merged list available from getSchemas.

Parameters
@NonNull Class[] documentClasses

classes annotated with androidx.appsearch.annotation.Document.

Throws
androidx.appsearch.exceptions.AppSearchException

if androidx.appsearch.compiler.AppSearchCompiler has not generated a schema for the given document classes.

addDocumentClasses

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder addDocumentClasses(@NonNull Collection<Class<Object>> documentClasses)

Adds a collection of androidx.appsearch.annotation.Document annotated classes to the schema.

This will also add all androidx.appsearch.annotation.Document classes referenced by the schema via document properties.

Merged list available from getSchemas.

Parameters
@NonNull Collection<Class<Object>> documentClasses

classes annotated with androidx.appsearch.annotation.Document.

Throws
androidx.appsearch.exceptions.AppSearchException

if androidx.appsearch.compiler.AppSearchCompiler has not generated a schema for the given document classes.

addRequiredPermissionsForDocumentClassVisibility

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
public @NonNull SetSchemaRequest.Builder addRequiredPermissionsForDocumentClassVisibility(
    @NonNull Class<Object> documentClass,
    @NonNull Set<Integer> permissions
)

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 visible packages added in this method and permission visibility setting addRequiredPermissionsForSchemaTypeVisibility 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.

Merged map available from getRequiredPermissionsForSchemaTypeVisibility.

Parameters
@NonNull Class<Object> documentClass

The androidx.appsearch.annotation.Document class to set visibility on.

@NonNull Set<Integer> permissions

A set of required Android permissions the caller need to hold to access GenericDocument objects that under the given schema.

addRequiredPermissionsForSchemaTypeVisibility

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
public @NonNull SetSchemaRequest.Builder addRequiredPermissionsForSchemaTypeVisibility(
    @NonNull String schemaType,
    @NonNull Set<Integer> permissions
)

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
@NonNull String schemaType

The schema type to set visibility on.

@NonNull Set<Integer> permissions

A set of required Android permissions the caller need to hold to access GenericDocument objects that under the given schema.

Throws
java.lang.IllegalArgumentException

– if input unsupported permission.

addSchemaTypeVisibleToConfig

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
public @NonNull SetSchemaRequest.Builder addSchemaTypeVisibleToConfig(
    @NonNull String schemaType,
    @NonNull SchemaVisibilityConfig schemaVisibilityConfig
)

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 SchemaVisibilityConfigs, and the querier will have access if they match ANY of the SchemaVisibilityConfig.

Parameters
@NonNull String schemaType

The schema type to set visibility on.

@NonNull SchemaVisibilityConfig schemaVisibilityConfig

The SchemaVisibilityConfig holds all requirements that a call must to match to access the schema.

addSchemas

public @NonNull SetSchemaRequest.Builder addSchemas(@NonNull AppSearchSchema[] schemas)

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.

addSchemas

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder addSchemas(@NonNull Collection<AppSearchSchema> schemas)

Adds a collection of AppSearchSchema objects to the schema.

An AppSearchSchema object represents one type of structured data.

build

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest build()

Builds a new SetSchemaRequest object.

Throws
java.lang.IllegalArgumentException

if schema types were referenced, but the corresponding AppSearchSchema type was never added.

clearDocumentClassVisibleToConfigs

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
public @NonNull SetSchemaRequest.Builder clearDocumentClassVisibleToConfigs(@NonNull Class<Object> documentClass)

Clears all visible to SchemaVisibilityConfig for the given schema type.

clearMigrators

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder clearMigrators()

Clears all Migrators.

clearRequiredPermissionsForDocumentClassVisibility

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
public @NonNull SetSchemaRequest.Builder clearRequiredPermissionsForDocumentClassVisibility(
    @NonNull Class<Object> documentClass
)

Clears all required permissions combinations for the given schema type.

clearRequiredPermissionsForSchemaTypeVisibility

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.ADD_PERMISSIONS_AND_GET_VISIBILITY)
public @NonNull SetSchemaRequest.Builder clearRequiredPermissionsForSchemaTypeVisibility(
    @NonNull String schemaType
)

Clears all required permissions combinations for the given schema type.

clearSchemaTypeVisibleToConfigs

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_ADD_SCHEMA_TYPE_VISIBLE_TO_CONFIG)
public @NonNull SetSchemaRequest.Builder clearSchemaTypeVisibleToConfigs(@NonNull String schemaType)

Clears all visible to SchemaVisibilityConfig for the given schema type.

clearSchemas

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder clearSchemas()

Clears all AppSearchSchemas from the list of schemas.

setDocumentClassDisplayedBySystem

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setDocumentClassDisplayedBySystem(
    @NonNull Class<Object> documentClass,
    boolean displayed
)

Sets whether or not documents from the provided androidx.appsearch.annotation.Document annotated class will be displayed and visible on any system UI surface.

This setting applies to the provided androidx.appsearch.annotation.Document annotated class only, and does not persist across setSchemaAsync calls.

The default behavior, if this method is not called, is to allow types to be displayed on system UI surfaces.

Merged list available from getSchemasNotDisplayedBySystem.

Parameters
@NonNull Class<Object> documentClass

A class annotated with androidx.appsearch.annotation.Document, the visibility of which will be configured

boolean displayed

Whether documents of this type will be displayed on system UI surfaces.

Throws
androidx.appsearch.exceptions.AppSearchException

if androidx.appsearch.compiler.AppSearchCompiler has not generated a schema for the given document class.

setDocumentClassVisibilityForPackage

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setDocumentClassVisibilityForPackage(
    @NonNull Class<Object> documentClass,
    boolean visible,
    @NonNull PackageIdentifier packageIdentifier
)

Sets whether or not documents from the provided androidx.appsearch.annotation.Document annotated class can be read by the specified package.

Each package is represented by a PackageIdentifier, containing a package name and a byte array of type 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, app data sharing between applications is disabled.

The relationship between visible packages added in this method and permission visibility setting addRequiredPermissionsForSchemaTypeVisibility 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.

Merged list available from getSchemasVisibleToPackages.

Parameters
@NonNull Class<Object> documentClass

The androidx.appsearch.annotation.Document class to set visibility on.

boolean visible

Whether the documentClass will be visible or not.

@NonNull PackageIdentifier packageIdentifier

Represents the package that will be granted visibility.

Throws
androidx.appsearch.exceptions.AppSearchException

if androidx.appsearch.compiler.AppSearchCompiler has not generated a schema for the given document class.

setForceOverride

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setForceOverride(boolean forceOverride)

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.

setMigrator

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setMigrator(@NonNull String schemaType, @NonNull Migrator migrator)

Sets the Migrator associated with the given SchemaType.

The Migrator migrates all GenericDocuments 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 shouldMigrate returns true.

The target schema type of the output GenericDocument of onUpgrade or onDowngrade must exist in this SetSchemaRequest.

Parameters
@NonNull String schemaType

The schema type to set migrator on.

@NonNull Migrator migrator

The migrator translates a document from its current version to the final version set via setVersion.

setMigrators

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setMigrators(@NonNull Map<StringMigrator> migrators)

Sets a Map of Migrators.

The key of the map is the schema type that the Migrator value applies to.

The Migrator migrates all GenericDocuments 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 shouldMigrate returns true.

The target schema type of the output GenericDocument of onUpgrade or onDowngrade must exist in this SetSchemaRequest.

Parameters
@NonNull Map<StringMigrator> migrators

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.

setPubliclyVisibleDocumentClass

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_SET_PUBLICLY_VISIBLE)
public @NonNull SetSchemaRequest.Builder setPubliclyVisibleDocumentClass(
    @NonNull Class<Object> documentClass,
    @Nullable PackageIdentifier packageIdentifier
)

Specify that the documents from the provided androidx.appsearch.annotation.Document annotated class should be publicly available, to packages which already have visibility to packageIdentifier. This visibility is determined by the result of 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 androidx.appsearch.annotation.Document annotated class, the PackageIdentifier in the last call will be used as the "from" package for that class (or schema).

Calling this with packageIdentifier set to null is valid, and will remove public visibility for the class (or schema).

Parameters
@NonNull Class<Object> documentClass

the androidx.appsearch.annotation.Document annotated class to make publicly accessible.

@Nullable PackageIdentifier packageIdentifier

if an app can see this package via PackageManager#canPackageQuery, it will be able to see the documents of type documentClass.

setPubliclyVisibleSchema

Added in 1.1.0-alpha06
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SET_SCHEMA_REQUEST_SET_PUBLICLY_VISIBLE)
public @NonNull SetSchemaRequest.Builder setPubliclyVisibleSchema(
    @NonNull String schema,
    @Nullable PackageIdentifier packageIdentifier
)

Specify that the schema should be publicly available, to packages which already have visibility to packageIdentifier. This visibility is determined by the result of 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
@NonNull String schema

the schema to make publicly accessible.

@Nullable PackageIdentifier packageIdentifier

if an app can see this package via PackageManager#canPackageQuery, it will be able to see the documents of type schema.

setSchemaTypeDisplayedBySystem

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setSchemaTypeDisplayedBySystem(
    @NonNull String schemaType,
    boolean displayed
)

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 setSchemaAsync calls.

The default behavior, if this method is not called, is to allow types to be displayed on system UI surfaces.

Parameters
@NonNull String schemaType

The name of an AppSearchSchema within the same SetSchemaRequest, which will be configured.

boolean displayed

Whether documents of this type will be displayed on system UI surfaces.

setSchemaTypeVisibilityForPackage

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setSchemaTypeVisibilityForPackage(
    @NonNull String schemaType,
    boolean visible,
    @NonNull PackageIdentifier packageIdentifier
)

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 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
@NonNull String schemaType

The schema type to set visibility on.

boolean visible

Whether the schemaType will be visible or not.

@NonNull PackageIdentifier packageIdentifier

Represents the package that will be granted visibility.

setVersion

Added in 1.1.0-alpha06
public @NonNull SetSchemaRequest.Builder setVersion(@IntRange(from = 1) int version)

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 Migrators provided to setSchemaAsync 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
@IntRange(from = 1) int version

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.

Throws
java.lang.IllegalArgumentException

if the version is negative.