SetSchemaRequest


public final class SetSchemaRequest
extends Object

java.lang.Object
   ↳ 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 AppSearchException, with a message describing the incompatibility. As a result, the previously set schema will remain unchanged.

Backward incompatible changes can be made by :

Summary

Nested classes

class SetSchemaRequest.Builder

Builder for SetSchemaRequest objects. 

Constants

int READ_ASSISTANT_APP_SEARCH_DATA

The Manifest.permission.READ_ASSISTANT_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility

int READ_CALENDAR

The Manifest.permission.READ_CALENDAR AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

int READ_CONTACTS

The Manifest.permission.READ_CONTACTS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

int READ_EXTERNAL_STORAGE

The Manifest.permission.READ_EXTERNAL_STORAGE AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

int READ_HOME_APP_SEARCH_DATA

The Manifest.permission.READ_HOME_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility

int READ_SMS

The Manifest.permission.READ_SMS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Public methods

boolean equals(Object other)

Indicates whether some other object is "equal to" this one.

Map<StringMigrator> getMigrators()

Returns the map of Migrator, the key will be the schema type of the Migrator associated with.

Map<StringPackageIdentifier> getPubliclyVisibleSchemas()

Returns a mapping of publicly visible schemas to the PackageIdentifier specifying the package the schemas are from.

Map<StringSet<Set<Integer>>> getRequiredPermissionsForSchemaTypeVisibility()

Returns a mapping of schema types to the Map of Manifest.permission combinations that querier must hold to access that schema type.

Set<AppSearchSchema> getSchemas()

Returns the AppSearchSchema types that are part of this request.

Set<String> getSchemasNotDisplayedBySystem()

Returns all the schema types that are opted out of being displayed and visible on any system UI surface.

Map<StringSet<SchemaVisibilityConfig>> getSchemasVisibleToConfigs()

Returns a mapping of schema types to the set of SchemaVisibilityConfig that have access to that schema type.

Map<StringSet<PackageIdentifier>> getSchemasVisibleToPackages()

Returns a mapping of schema types to the set of packages that have access to that schema type.

int getVersion()

Returns the database overall schema version.

int hashCode()

Returns a hash code value for the object.

boolean isForceOverride()

Returns whether this request will force the schema to be overridden.

Inherited methods

Constants

READ_ASSISTANT_APP_SEARCH_DATA

Added in API level 33
Also in T Extensions 3
public static final int READ_ASSISTANT_APP_SEARCH_DATA

The Manifest.permission.READ_ASSISTANT_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility

Constant Value: 6 (0x00000006)

READ_CALENDAR

Added in API level 33
Also in T Extensions 3
public static final int READ_CALENDAR

The Manifest.permission.READ_CALENDAR AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Constant Value: 2 (0x00000002)

READ_CONTACTS

Added in API level 33
Also in T Extensions 3
public static final int READ_CONTACTS

The Manifest.permission.READ_CONTACTS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Constant Value: 3 (0x00000003)

READ_EXTERNAL_STORAGE

Added in API level 33
Also in T Extensions 3
public static final int READ_EXTERNAL_STORAGE

The Manifest.permission.READ_EXTERNAL_STORAGE AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Constant Value: 4 (0x00000004)

READ_HOME_APP_SEARCH_DATA

Added in API level 33
Also in T Extensions 3
public static final int READ_HOME_APP_SEARCH_DATA

The Manifest.permission.READ_HOME_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility

Constant Value: 5 (0x00000005)

READ_SMS

Added in API level 33
Also in T Extensions 3
public static final int READ_SMS

The Manifest.permission.READ_SMS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Constant Value: 1 (0x00000001)

Public methods

equals

Added in API level 31
public boolean equals (Object other)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other Object: This value may be null.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getMigrators

Added in API level 31
public Map<StringMigrator> getMigrators ()

Returns the map of Migrator, the key will be the schema type of the Migrator associated with.

Returns
Map<StringMigrator> This value cannot be null.

getPubliclyVisibleSchemas

Added in API level 35
Also in T Extensions 13
public Map<StringPackageIdentifier> getPubliclyVisibleSchemas ()

Returns a mapping of publicly visible schemas to the PackageIdentifier specifying the package the schemas are from.

Returns
Map<StringPackageIdentifier> This value cannot be null.

getRequiredPermissionsForSchemaTypeVisibility

Added in API level 33
Also in T Extensions 3
public Map<StringSet<Set<Integer>>> getRequiredPermissionsForSchemaTypeVisibility ()

Returns a mapping of schema types to the Map of 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\u2019s inefficient to call this method repeatedly.

Returns
Map<StringSet<Set<Integer>>> The map contains schema type and all combinations of required permission for querier to access it. The supported Permission are SetSchemaRequest.READ_SMS, READ_CALENDAR, SetSchemaRequest.READ_CONTACTS, READ_EXTERNAL_STORAGE, READ_HOME_APP_SEARCH_DATA and READ_ASSISTANT_APP_SEARCH_DATA. This value cannot be null.

getSchemas

Added in API level 31
public Set<AppSearchSchema> getSchemas ()

Returns the AppSearchSchema types that are part of this request.

Returns
Set<AppSearchSchema> This value cannot be null.

getSchemasNotDisplayedBySystem

Added in API level 31
public Set<String> getSchemasNotDisplayedBySystem ()

Returns all the schema types that are opted out of being displayed and visible on any system UI surface.

Returns
Set<String> This value cannot be null.

getSchemasVisibleToConfigs

Added in API level 35
Also in T Extensions 13
public Map<StringSet<SchemaVisibilityConfig>> getSchemasVisibleToConfigs ()

Returns a mapping of schema types to the set of SchemaVisibilityConfig that have access to that schema type.

It\u2019s inefficient to call this method repeatedly.

Returns
Map<StringSet<SchemaVisibilityConfig>> This value cannot be null.

getSchemasVisibleToPackages

Added in API level 31
public Map<StringSet<PackageIdentifier>> getSchemasVisibleToPackages ()

Returns a mapping of schema types to the set of packages that have access to that schema type.

It\u2019s inefficient to call this method repeatedly.

Returns
Map<StringSet<PackageIdentifier>> This value cannot be null.

getVersion

Added in API level 31
public int getVersion ()

Returns the database overall schema version.

Returns
int Value is 1 or greater

hashCode

Added in API level 31
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

isForceOverride

Added in API level 31
public boolean isForceOverride ()

Returns whether this request will force the schema to be overridden.

Returns
boolean