public final class

GetSchemaResponse.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.appsearch.app.GetSchemaResponse.Builder

Overview

Builder for GetSchemaResponse objects.

Summary

Constructors
publicBuilder()

Create a GetSchemaResponse.Builder object}

Methods
public GetSchemaResponse.BuilderaddSchema(AppSearchSchema schema)

Adds one AppSearchSchema to the schema list.

public GetSchemaResponse.BuilderaddSchemaTypeNotDisplayedBySystem(java.lang.String schemaType)

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

public GetSchemaResponsebuild()

Builds a GetSchemaResponse object.

public GetSchemaResponse.BuildersetPubliclyVisibleSchema(java.lang.String schemaType, PackageIdentifier packageIdentifier)

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

public GetSchemaResponse.BuildersetRequiredPermissionsForSchemaTypeVisibility(java.lang.String schemaType, java.util.Set<java.util.Set> visibleToPermissionSets)

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

public GetSchemaResponse.BuildersetSchemaTypeVisibleToConfigs(java.lang.String schemaType, java.util.Set<SchemaVisibilityConfig> visibleToConfigs)

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

public GetSchemaResponse.BuildersetSchemaTypeVisibleToPackages(java.lang.String schemaType, java.util.Set<PackageIdentifier> packageIdentifiers)

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

public GetSchemaResponse.BuildersetVersion(int version)

Sets the database overall schema version.

public GetSchemaResponse.BuildersetVisibilitySettingSupported(boolean visibilitySettingSupported)

Method to set visibility setting.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Create a GetSchemaResponse.Builder object}

Methods

public GetSchemaResponse.Builder setVersion(int version)

Sets the database overall schema version.

Default version is 0

Adds one AppSearchSchema to the schema list.

public GetSchemaResponse.Builder addSchemaTypeNotDisplayedBySystem(java.lang.String schemaType)

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

Parameters:

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

public GetSchemaResponse.Builder setSchemaTypeVisibleToPackages(java.lang.String schemaType, java.util.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 android.content.pm.PackageManager.

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: The schema type to set visibility on.
packageIdentifiers: Represents the package that has access to the given schema type.

public GetSchemaResponse.Builder setRequiredPermissionsForSchemaTypeVisibility(java.lang.String schemaType, java.util.Set<java.util.Set> visibleToPermissionSets)

Sets a set of required 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 {% verbatim %}{{permissionA, PermissionB}, {PermissionC, PermissionD}, {PermissionE}}{% endverbatim %}.

  • 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: The schema type to set visibility on.
visibleToPermissionSets: The Sets of Android permissions that will be required to access the given schema.

See also:

public GetSchemaResponse.Builder setPubliclyVisibleSchema(java.lang.String schemaType, PackageIdentifier packageIdentifier)

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

Parameters:

schemaType: the schema to make publicly accessible.
packageIdentifier: the package from which the document schema is from.

See also: SetSchemaRequest.Builder.setPubliclyVisibleSchema(String, PackageIdentifier)

public GetSchemaResponse.Builder setSchemaTypeVisibleToConfigs(java.lang.String schemaType, java.util.Set<SchemaVisibilityConfig> visibleToConfigs)

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 {% verbatim %}{{PackageA and Permission1}, {PackageB and Permission2}}{% endverbatim %}.

  • 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: The schema type to set visibility on.
visibleToConfigs: The SchemaVisibilityConfigs hold all requirements that a call must to match to access the schema.

public GetSchemaResponse.Builder setVisibilitySettingSupported(boolean visibilitySettingSupported)

Method to set visibility setting. If this is called with false, GetSchemaResponse.getRequiredPermissionsForSchemaTypeVisibility(), GetSchemaResponse.getSchemaTypesNotDisplayedBySystem()}, and GetSchemaResponse.getSchemaTypesVisibleToPackages() calls will throw an java.lang.UnsupportedOperationException. If called with true, visibility information for all schemas will be cleared.

Parameters:

visibilitySettingSupported: whether supported Features.ADD_PERMISSIONS_AND_GET_VISIBILITY by this backend/Android API level.

public GetSchemaResponse build()

Builds a GetSchemaResponse object.