# SchemaVisibilityConfig.Builder

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/appsearch/SchemaVisibilityConfig.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                               ||
| ↳ | [android.app.appsearch.SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) |

The builder class of[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig).

## Summary

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | [addAllowedPackage](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#addAllowedPackage(android.app.appsearch.PackageIdentifier))`(`packageIdentifier:` `[PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)`)` Add[PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)of packages which has access to this schema.                                                                                                                                                                                                                                                           |
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | [addRequiredPermissions](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#addRequiredPermissions(kotlin.collections.MutableSet))`(`visibleToPermissions:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!>`)` Adds a set of required Android[android.Manifest.permission](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#)combination a package needs to hold to access the schema this[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)represents. |
| [SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)                  | [build](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#build())`()` Build a[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | [clearAllowedPackages](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#clearAllowedPackages())`()` Clears the list of packages which have access to this schema.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | [clearRequiredPermissions](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#clearRequiredPermissions())`()` Clears all required permissions combinations set to this[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig).                                                                                                                                                                                                                                                                                                                                                                                                  |
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | [setPubliclyVisibleTargetPackage](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#setPubliclyVisibleTargetPackage(android.app.appsearch.PackageIdentifier))`(`packageIdentifier:` `[PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/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[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
Builder()
```

Creates a[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#)for a[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig).

## Public methods

### addAllowedPackage

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun addAllowedPackage(packageIdentifier: PackageIdentifier): SchemaVisibilityConfig.Builder
```

Add[PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)of packages which has access to this schema.

|                                                                          Parameters                                                                          ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `packageIdentifier` | [PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier):This value cannot be`null`. |

|                                                                               Return                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | This value cannot be`null`. |

### addRequiredPermissions

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun addRequiredPermissions(visibleToPermissions: MutableSet<Int!>): SchemaVisibilityConfig.Builder
```

Adds a set of required Android[android.Manifest.permission](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#)combination a package needs to hold to access the schema this[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)represents.

If the querier holds ALL of the required permissions in this combination, they will have access to read[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/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[getRequiredPermissions()](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig#getRequiredPermissions()).

|                                                                                                                Parameters                                                                                                                ||
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `visibleToPermissions` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!\>:This value cannot be`null`. |

|                                                                               Return                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | This value cannot be`null`. |

**See Also**

- [android.app.appsearch.SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility(kotlin.String,%20kotlin.collections.MutableSet))  

### build

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun build(): SchemaVisibilityConfig
```

Build a[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)

|                                                                       Return                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig) | This value cannot be`null`. |

### clearAllowedPackages

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun clearAllowedPackages(): SchemaVisibilityConfig.Builder
```

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

|                                                                               Return                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | This value cannot be`null`. |

### clearRequiredPermissions

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun clearRequiredPermissions(): SchemaVisibilityConfig.Builder
```

Clears all required permissions combinations set to this[SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig).

|                                                                               Return                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SchemaVisibilityConfig.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig.Builder#) | This value cannot be`null`. |

### setPubliclyVisibleTargetPackage

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
fun setPubliclyVisibleTargetPackage(packageIdentifier: PackageIdentifier?): SchemaVisibilityConfig.Builder
```

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 android.content.pm.PackageManager#canPackageQuery.

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                                                                                                                                                                                                                              ||
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `packageIdentifier` | [PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)?:the[PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)of the package that will be used as the target package in a call to android.content.pm.PackageManager#canPackageQuery to determine which packages can access this publicly visible schema. This value may be`null`. |