Added in API level 31

Builder


class Builder
kotlin.Any
   ↳ android.app.appsearch.GetSchemaResponse.Builder

Builder for GetSchemaResponse objects.

Summary

Public constructors

Create a Builder object}

Public methods
GetSchemaResponse.Builder

Adds one AppSearchSchema to the schema list.

GetSchemaResponse.Builder

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

GetSchemaResponse

Builds a GetSchemaResponse object.

GetSchemaResponse.Builder
setPubliclyVisibleSchema(schemaType: String, packageIdentifier: PackageIdentifier)

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

GetSchemaResponse.Builder

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

GetSchemaResponse.Builder

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

GetSchemaResponse.Builder

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

GetSchemaResponse.Builder
setVersion(version: Int)

Sets the database overall schema version.

Public constructors

Builder

Added in API level 31
Builder()

Create a Builder object}

Public methods

addSchema

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

Adds one AppSearchSchema to the schema list.

Parameters
schema AppSearchSchema: This value cannot be null.
Return
GetSchemaResponse.Builder This value cannot be null.

addSchemaTypeNotDisplayedBySystem

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

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.
Return
GetSchemaResponse.Builder This value cannot be null.

build

Added in API level 31
fun build(): GetSchemaResponse

Builds a GetSchemaResponse object.

Return
GetSchemaResponse This value cannot be null.

setPubliclyVisibleSchema

Added in API level 35
fun setPubliclyVisibleSchema(
    schemaType: String,
    packageIdentifier: PackageIdentifier
): GetSchemaResponse.Builder

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

Parameters
schemaType String: the schema to make publicly accessible. This value cannot be null.
packageIdentifier PackageIdentifier: the package from which the document schema is from. This value cannot be null.
Return
GetSchemaResponse.Builder This value cannot be null.

setRequiredPermissionsForSchemaTypeVisibility

Added in API level 33
fun setRequiredPermissionsForSchemaTypeVisibility(
    schemaType: String,
    visibleToPermissionSets: MutableSet<MutableSet<Int!>!>
): GetSchemaResponse.Builder

Sets a set of required android.Manifest.permission combinations to the given 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.
Parameters
schemaType String: The schema type to set visibility on. This value cannot be null.
visibleToPermissionSets MutableSet<MutableSet<Int!>!>: The Sets of Android permissions that will be required to access 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
GetSchemaResponse.Builder This value cannot be null.

setSchemaTypeVisibleToConfigs

Added in API level 35
fun setSchemaTypeVisibleToConfigs(
    schemaType: String,
    visibleToConfigs: MutableSet<SchemaVisibilityConfig!>
): GetSchemaResponse.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.

The querier could have access if they match ALL requirements in ANY of the given SchemaVisibilityConfigs

For example, if the Set contains {{PackageA and Permission1}, {PackageB and Permission2}}.

  • A querier from packageA could read if they holds Permission1.
  • A querier from packageA could NOT read if they only holds Permission2 instead of Permission1.
  • A querier from packageB could read if they holds Permission2.
  • A querier from packageC could never read.
  • A querier holds both PermissionA and PermissionE has access.
Parameters
schemaType String: The schema type to set visibility on. This value cannot be null.
visibleToConfigs MutableSet<SchemaVisibilityConfig!>: The SchemaVisibilityConfigs hold all requirements that a call must to match to access the schema. This value cannot be null.
Return
GetSchemaResponse.Builder This value cannot be null.

setSchemaTypeVisibleToPackages

Added in API level 33
fun setSchemaTypeVisibleToPackages(
    schemaType: String,
    packageIdentifiers: MutableSet<PackageIdentifier!>
): GetSchemaResponse.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.

Parameters
schemaType String: The schema type to set visibility on. This value cannot be null.
packageIdentifiers MutableSet<PackageIdentifier!>: Represents the package that has access to the given schema type. This value cannot be null.
Return
GetSchemaResponse.Builder This value cannot be null.

setVersion

Added in API level 31
fun setVersion(version: Int): GetSchemaResponse.Builder

Sets the database overall schema version.

Default version is 0

Parameters
version Int: Value is 0 or greater
Return
GetSchemaResponse.Builder This value cannot be null.