# FakePermissionController

Artifact: [androidx.health.connect:connect-testing](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/testing/FakePermissionController.kt+class:androidx.health.connect.client.testing.FakePermissionController) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

*** ** * ** ***


```
class FakePermissionController : PermissionController
```

<br />

*** ** * ** ***

A fake `https://developer.android.com/reference/kotlin/androidx/health/connect/client/PermissionController` that enables full control of permissions in tests for a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/HealthConnectClient`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#FakePermissionController(kotlin.Boolean)(grantAll: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |

| ### Public functions |
|---|---|
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()()` Returns a fake set of permissions. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#grantPermission(kotlin.String)(permission: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Adds a permission to the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#grantPermissions(kotlin.collections.Set)(permission: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>)` Adds permissions to the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#replaceGrantedPermissions(kotlin.collections.Set)(permissions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>)` Replaces the set of permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()` with a new set. |
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#revokeAllPermissions()()` Clears the set of permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#revokePermission(kotlin.String)(permission: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Removes a permission from the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionControllerOverrides` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#overrides()` Used to override or intercept responses to emulate scenarios that `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController` doesn't support directly, such as throwing an exception or applying custom logic to the responses. |

## Public constructors

### FakePermissionController

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
FakePermissionController(grantAll: Boolean = true)
```

| Parameters |
|---|---|
| `grantAll: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | grants all permissions on creation |

## Public functions

### getGrantedPermissions

```
open suspend fun getGrantedPermissions(): Set<String>
```

Returns a fake set of permissions.

### grantPermission

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
fun grantPermission(permission: String): Unit
```

Adds a permission to the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`.

### grantPermissions

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
fun grantPermissions(permission: Set<String>): Unit
```

Adds permissions to the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`.

### replaceGrantedPermissions

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
fun replaceGrantedPermissions(permissions: Set<String>): Unit
```

Replaces the set of permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()` with a new set.

### revokeAllPermissions

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
open suspend fun revokeAllPermissions(): Unit
```

Clears the set of permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`.

### revokePermission

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
fun revokePermission(permission: String): Unit
```

Removes a permission from the set of granted permissions returned by `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController#getGrantedPermissions()`.

## Public properties

### overrides

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
val overrides: FakePermissionControllerOverrides
```

Used to override or intercept responses to emulate scenarios that `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakePermissionController` doesn't support directly, such as throwing an exception or applying custom logic to the responses.