GetSchemaResponse.Builder

public final class GetSchemaResponse.Builder


Builder for GetSchemaResponse objects.

Summary

Public constructors

Create a Builder object}

Public methods

@NonNull GetSchemaResponse.Builder

Adds one AppSearchSchema to the schema list.

@NonNull GetSchemaResponse.Builder

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

@NonNull GetSchemaResponse

Builds a GetSchemaResponse object.

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

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

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

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

@NonNull GetSchemaResponse.Builder
setVersion(@IntRange(from = 0) int version)

Sets the database overall schema version.

Public constructors

Builder

Added in 1.1.0-alpha04
public Builder()

Create a Builder object}

Public methods

addSchema

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse.Builder addSchema(@NonNull AppSearchSchema schema)

Adds one AppSearchSchema to the schema list.

addSchemaTypeNotDisplayedBySystem

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse.Builder addSchemaTypeNotDisplayedBySystem(@NonNull String schemaType)

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

Parameters
@NonNull String schemaType

The name of an AppSearchSchema within the same GetSchemaResponse, which won't be displayed by system.

build

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse build()

Builds a GetSchemaResponse object.

setRequiredPermissionsForSchemaTypeVisibility

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse.Builder setRequiredPermissionsForSchemaTypeVisibility(
    @NonNull String schemaType,
    @NonNull Set<Set<Integer>> visibleToPermissions
)

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

The schema type to set visibility on.

@NonNull Set<Set<Integer>> visibleToPermissions

The Android permissions that will be required to access the given schema.

setSchemaTypeVisibleToPackages

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse.Builder setSchemaTypeVisibleToPackages(
    @NonNull String schemaType,
    @NonNull 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 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
@NonNull String schemaType

The schema type to set visibility on.

@NonNull Set<PackageIdentifier> packageIdentifiers

Represents the package that has access to the given schema type.

setVersion

Added in 1.1.0-alpha04
public @NonNull GetSchemaResponse.Builder setVersion(@IntRange(from = 0) int version)

Sets the database overall schema version.

Default version is 0