# SchemaVisibilityConfig.Builder

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/SchemaVisibilityConfig.java+class:androidx.appsearch.app.SchemaVisibilityConfig.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***

<br />

```
public final class SchemaVisibilityConfig.Builder
```

<br />

*** ** * ** ***

The builder class of `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#Builder()()` Creates a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` for a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#addAllowedPackage(androidx.appsearch.app.PackageIdentifier)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier packageIdentifier)` Add `https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier` of packages which has access to this schema. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#addRequiredPermissions(java.util.Set<java.lang.Integer>)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/Integer.html> visibleToPermissions)` Adds a set of required Android `https://developer.android.com/reference/android/Manifest.permission.html` combination a package needs to hold to access the schema this `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig` represents. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#build()()` Build a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#clearAllowedPackages()()` Clears the list of packages which have access to this schema. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#clearRequiredPermissions()()` Clears all required permissions combinations set to this `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder#setPubliclyVisibleTargetPackage(androidx.appsearch.app.PackageIdentifier)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier packageIdentifier )` Specify that this schema should be publicly available, to the same packages that have visibility to the package passed as a parameter. |

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public Builder()
```

Creates a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig.Builder` for a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`.

## Public methods

### addAllowedPackage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig.Builder addAllowedPackage(@NonNull PackageIdentifier packageIdentifier)
```

Add `https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier` of packages which has access to this schema.

### addRequiredPermissions

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig.Builder addRequiredPermissions(@NonNull Set<Integer> visibleToPermissions)
```

Adds a set of required Android `https://developer.android.com/reference/android/Manifest.permission.html` combination a package needs to hold to access the schema this `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig` represents.

If the querier holds ALL of the required permissions in this combination, they will have access to read `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` objects of the given schema type.

You can call this method repeatedly to add multiple permission combinations, and the querier will have access if they holds ANY of the combinations.

Merged Set available from `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig#getRequiredPermissions()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility(java.lang.String,java.util.Set<java.lang.Integer>)` | for supported Permissions. |

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig build()
```

Build a `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`

### clearAllowedPackages

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig.Builder clearAllowedPackages()
```

Clears the list of packages which have access to this schema.

### clearRequiredPermissions

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig.Builder clearRequiredPermissions()
```

Clears all required permissions combinations set to this `https://developer.android.com/reference/androidx/appsearch/app/SchemaVisibilityConfig`.

### setPubliclyVisibleTargetPackage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull SchemaVisibilityConfig.Builder setPubliclyVisibleTargetPackage(
    @Nullable PackageIdentifier packageIdentifier
)
```

Specify that this schema should be publicly available, to the same packages that have visibility to the package passed as a parameter. This visibility is determined by the result of `https://developer.android.com/reference/android/content/pm/PackageManager.html#canPackageQuery(java.lang.String, java.lang.String)`.

It is possible for the packageIdentifier parameter to be different from the package performing the indexing. This might happen in the case of an on-device indexer processing information about various packages. The visibility will be the same regardless of which package indexes the document, as the visibility is based on the packageIdentifier parameter.

Calling this with packageIdentifier set to null is valid, and will remove public visibility for the schema.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier packageIdentifier` | the `https://developer.android.com/reference/androidx/appsearch/app/PackageIdentifier` of the package that will be used as the target package in a call to `https://developer.android.com/reference/android/content/pm/PackageManager.html#canPackageQuery(java.lang.String, java.lang.String)` to determine which packages can access this publicly visible schema. |