GetSchemaResponse.Builder

public static final class GetSchemaResponse.Builder
extends Object

java.lang.Object
   ↳ android.app.appsearch.GetSchemaResponse.Builder


Builder for GetSchemaResponse objects.

Summary

Public constructors

Builder()

Create a Builder object}

Public methods

GetSchemaResponse.Builder addSchema(AppSearchSchema schema)

Adds one AppSearchSchema to the schema list.

GetSchemaResponse.Builder addSchemaTypeNotDisplayedBySystem(String schemaType)

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

GetSchemaResponse build()

Builds a GetSchemaResponse object.

GetSchemaResponse.Builder setRequiredPermissionsForSchemaTypeVisibility(String schemaType, Set<Set<Integer>> visibleToPermissions)

Sets a set of required Manifest.permission combinations to the given schema type.

GetSchemaResponse.Builder setSchemaTypeVisibleToPackages(String schemaType, Set<PackageIdentifier> packageIdentifiers)

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

GetSchemaResponse.Builder setVersion(int version)

Sets the database overall schema version.

Inherited methods

Public constructors

Builder

Added in API level 31
public Builder ()

Create a Builder object}

Public methods

addSchema

Added in API level 31
public GetSchemaResponse.Builder addSchema (AppSearchSchema schema)

Adds one AppSearchSchema to the schema list.

Parameters
schema AppSearchSchema: This value cannot be null.

Returns
GetSchemaResponse.Builder This value cannot be null.

addSchemaTypeNotDisplayedBySystem

Added in API level 33
public GetSchemaResponse.Builder addSchemaTypeNotDisplayedBySystem (String schemaType)

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

Parameters
schemaType String: The name of an AppSearchSchema within the same GetSchemaResponse, which won't be displayed by system. This value cannot be null.

Returns
GetSchemaResponse.Builder This value cannot be null.

build

Added in API level 31
public GetSchemaResponse build ()

Builds a GetSchemaResponse object.

Returns
GetSchemaResponse This value cannot be null.

setRequiredPermissionsForSchemaTypeVisibility

Added in API level 33
public GetSchemaResponse.Builder setRequiredPermissionsForSchemaTypeVisibility (String schemaType, 
                Set<Set<Integer>> visibleToPermissions)

Sets a set of required Manifest.permission combinations to the given schema type.

The querier could read the GenericDocument objects under the schemaType if they hold 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.

Parameters
schemaType String: The schema type to set visibility on. This value cannot be null.

visibleToPermissions Set: The Android permissions that will be required to access the given schema. Value is SetSchemaRequest.READ_SMS, SetSchemaRequest.READ_CALENDAR, SetSchemaRequest.READ_CONTACTS, SetSchemaRequest.READ_EXTERNAL_STORAGE, SetSchemaRequest.READ_HOME_APP_SEARCH_DATA, SetSchemaRequest.READ_ASSISTANT_APP_SEARCH_DATA, android.app.appsearch.SetSchemaRequest.ENTERPRISE_ACCESS, or android.app.appsearch.SetSchemaRequest.ENTERPRISE_CONTACTS_DEVICE_POLICY This value cannot be null.

Returns
GetSchemaResponse.Builder This value cannot be null.

setSchemaTypeVisibleToPackages

Added in API level 33
public GetSchemaResponse.Builder setSchemaTypeVisibleToPackages (String schemaType, 
                Set<PackageIdentifier> packageIdentifiers)

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 PackageManager.CERT_INPUT_SHA256.

To opt into one-way data sharing with another application, the developer will need to explicitly grant the other application\u2019s 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.

Parameters
schemaType String: The schema type to set visibility on. This value cannot be null.

packageIdentifiers Set: Represents the package that has access to the given schema type. This value cannot be null.

Returns
GetSchemaResponse.Builder This value cannot be null.

setVersion

Added in API level 31
public GetSchemaResponse.Builder setVersion (int version)

Sets the database overall schema version.

Default version is 0

Parameters
version int: Value is 0 or greater

Returns
GetSchemaResponse.Builder This value cannot be null.