SetSchemaRequest
class SetSchemaRequest
kotlin.Any | |
↳ | android.app.appsearch.SetSchemaRequest |
Encapsulates a request to update the schema of an AppSearchSession
database.
The schema is composed of a collection of AppSearchSchema
objects, each of which defines a unique type of data.
The first call to SetSchemaRequest will set the provided schema and store it within the AppSearchSession
database.
Subsequent calls will compare the provided schema to the previously saved schema, to determine how to treat existing documents.
The following types of schema modifications are always safe and are made without deleting any existing documents:
- Addition of new
AppSearchSchema
types - Addition of new properties to an existing
AppSearchSchema
type - Changing the cardinality of a property to be less restrictive
The following types of schema changes are not backwards compatible:
- Removal of an existing
AppSearchSchema
type - Removal of a property from an existing
AppSearchSchema
type - Changing the data type of an existing property
- Changing the cardinality of a property to be more restrictive
Providing a schema with incompatible changes, will throw an , with a message describing the incompatibility. As a result, the previously set schema will remain unchanged.
Backward incompatible changes can be made by :
- setting
SetSchemaRequest.Builder#setForceOverride
method totrue
. This deletes all documents that are incompatible with the new schema. The new schema is then saved and persisted to disk. - Add a
Migrator
for each incompatible type and make no deletion. The migrator will migrate documents from its old schema version to the new version. Migrated types will be set into bothSetSchemaResponse#getIncompatibleTypes()
andandroid.app.appsearch.SetSchemaResponse#getMigratedTypes()
. See the migration section below.
Summary
Nested classes | |
---|---|
Builder for |
Public methods | |
---|---|
MutableMap<String!, Migrator!> |
Returns the map of |
MutableMap<String!, PackageIdentifier!> |
Returns a mapping of publicly visible schemas to the |
MutableMap<String!, MutableSet<MutableSet<Int!>!>!> |
Returns a mapping of schema types to the Map of |
MutableSet<AppSearchSchema!> |
Returns the |
MutableSet<String!> |
Returns all the schema types that are opted out of being displayed and visible on any system UI surface. |
MutableMap<String!, MutableSet<SchemaVisibilityConfig!>!> |
Returns a mapping of schema types to the set of |
MutableMap<String!, MutableSet<PackageIdentifier!>!> |
Returns a mapping of schema types to the set of packages that have access to that schema type. |
Int |
Returns the database overall schema version. |
Boolean |
Returns whether this request will force the schema to be overridden. |
Constants
READ_ASSISTANT_APP_SEARCH_DATA
static val READ_ASSISTANT_APP_SEARCH_DATA: Int
The android.Manifest.permission#READ_ASSISTANT_APP_SEARCH_DATA
AppSearch supported in SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 6
READ_CALENDAR
static val READ_CALENDAR: Int
The android.Manifest.permission#READ_CALENDAR
AppSearch supported in android.app.appsearch.SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 2
READ_CONTACTS
static val READ_CONTACTS: Int
The android.Manifest.permission#READ_CONTACTS
AppSearch supported in android.app.appsearch.SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 3
READ_EXTERNAL_STORAGE
static val READ_EXTERNAL_STORAGE: Int
The android.Manifest.permission#READ_EXTERNAL_STORAGE
AppSearch supported in android.app.appsearch.SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 4
READ_HOME_APP_SEARCH_DATA
static val READ_HOME_APP_SEARCH_DATA: Int
The android.Manifest.permission#READ_HOME_APP_SEARCH_DATA
AppSearch supported in SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 5
READ_SMS
static val READ_SMS: Int
The android.Manifest.permission#READ_SMS
AppSearch supported in android.app.appsearch.SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility
Value: 1
Public methods
getMigrators
fun getMigrators(): MutableMap<String!, Migrator!>
Returns the map of Migrator
, the key will be the schema type of the Migrator
associated with.
Return | |
---|---|
MutableMap<String!, Migrator!> |
This value cannot be null . |
getPubliclyVisibleSchemas
fun getPubliclyVisibleSchemas(): MutableMap<String!, PackageIdentifier!>
Returns a mapping of publicly visible schemas to the PackageIdentifier
specifying the package the schemas are from.
Return | |
---|---|
MutableMap<String!, PackageIdentifier!> |
This value cannot be null . |
getRequiredPermissionsForSchemaTypeVisibility
fun getRequiredPermissionsForSchemaTypeVisibility(): MutableMap<String!, MutableSet<MutableSet<Int!>!>!>
Returns a mapping of schema types to the Map of android.Manifest.permission
combinations that querier must hold to access that schema type.
The querier could read the GenericDocument
objects under the schemaType
if they holds ALL required permissions of ANY of the individual value sets.
For example, if the Map contains {{permissionA, PermissionB}, {PermissionC, PermissionD}, {PermissionE}}
.
- A querier holds both PermissionA and PermissionB has access.
- A querier holds both PermissionC and PermissionD has access.
- A querier holds only PermissionE has access.
- A querier holds both PermissionA and PermissionE has access.
- A querier holds only PermissionA doesn't have access.
- A querier holds both PermissionA and PermissionC doesn't have access.
It’s inefficient to call this method repeatedly.
Return | |
---|---|
MutableMap<String!, MutableSet<MutableSet<Int!>!>!> |
The map contains schema type and all combinations of required permission for querier to access it. The supported Permission are SetSchemaRequest#READ_SMS , android.app.appsearch.SetSchemaRequest#READ_CALENDAR , SetSchemaRequest#READ_CONTACTS , android.app.appsearch.SetSchemaRequest#READ_EXTERNAL_STORAGE , android.app.appsearch.SetSchemaRequest#READ_HOME_APP_SEARCH_DATA and android.app.appsearch.SetSchemaRequest#READ_ASSISTANT_APP_SEARCH_DATA . This value cannot be null . |
getSchemas
fun getSchemas(): MutableSet<AppSearchSchema!>
Returns the AppSearchSchema
types that are part of this request.
Return | |
---|---|
MutableSet<AppSearchSchema!> |
This value cannot be null . |
getSchemasNotDisplayedBySystem
fun getSchemasNotDisplayedBySystem(): MutableSet<String!>
Returns all the schema types that are opted out of being displayed and visible on any system UI surface.
Return | |
---|---|
MutableSet<String!> |
This value cannot be null . |
getSchemasVisibleToConfigs
fun getSchemasVisibleToConfigs(): MutableMap<String!, MutableSet<SchemaVisibilityConfig!>!>
Returns a mapping of schema types to the set of SchemaVisibilityConfig
that have access to that schema type.
It’s inefficient to call this method repeatedly.
Return | |
---|---|
MutableMap<String!, MutableSet<SchemaVisibilityConfig!>!> |
This value cannot be null . |
getSchemasVisibleToPackages
fun getSchemasVisibleToPackages(): MutableMap<String!, MutableSet<PackageIdentifier!>!>
Returns a mapping of schema types to the set of packages that have access to that schema type.
It’s inefficient to call this method repeatedly.
Return | |
---|---|
MutableMap<String!, MutableSet<PackageIdentifier!>!> |
This value cannot be null . |
getVersion
fun getVersion(): Int
Returns the database overall schema version.
Return | |
---|---|
Int |
Value is 1 or greater |
isForceOverride
fun isForceOverride(): Boolean
Returns whether this request will force the schema to be overridden.