# FakeExoMediaDrm.Builder

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/FakeExoMediaDrm.java+class:androidx.media3.test.utils.FakeExoMediaDrm.Builder)

*** ** * ** ***


```
class FakeExoMediaDrm.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#Builder()()` Constructs an instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#build()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` instance with an initial reference count of 1. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#setEnforceValidKeyResponses(boolean)(enforceValidKeyResponses: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether key responses passed to `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#provideKeyResponse(byte[],byte[])` should be checked for validity (i.e. that they came from a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.LicenseServer`). |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#setMaxConcurrentSessions(int)(maxConcurrentSessions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum number of concurrent sessions the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` will support. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#setProvisionsRequired(int)(provisionsRequired: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets how many successful provisioning round trips are needed for the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to be provisioned. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#throwNoSuchMethodErrorForProvisioningAndResourceBusy(boolean)( throwNoSuchMethodErrorForProvisioningAndResourceBusy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Configures the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to throw `https://developer.android.com/reference/java/lang/NoSuchMethodError.html` instead of `https://developer.android.com/reference/android/media/NotProvisionedException.html` or `https://developer.android.com/reference/android/media/ResourceBusyException.html`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.Builder#throwNotProvisionedExceptionFromGetKeyRequest()()` Configures the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to throw any `https://developer.android.com/reference/android/media/NotProvisionedException.html` from `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)` instead of the default behaviour of throwing from `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#openSession()`. |

## Public constructors

### Builder

```
Builder()
```

Constructs an instance.

## Public functions

### build

```
fun build(): FakeExoMediaDrm!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` instance with an initial reference count of 1. The caller is responsible for calling `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#release()` when they no longer need the instance.

### setEnforceValidKeyResponses

```
@CanIgnoreReturnValue
fun setEnforceValidKeyResponses(enforceValidKeyResponses: Boolean): FakeExoMediaDrm.Builder!
```

Sets whether key responses passed to `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#provideKeyResponse(byte[],byte[])` should be checked for validity (i.e. that they came from a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm.LicenseServer`).

Defaults to true.

### setMaxConcurrentSessions

```
@CanIgnoreReturnValue
fun setMaxConcurrentSessions(maxConcurrentSessions: Int): FakeExoMediaDrm.Builder!
```

Sets the maximum number of concurrent sessions the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` will support.

If this is exceeded then subsequent calls to `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#openSession()` will throw `https://developer.android.com/reference/android/media/ResourceBusyException.html`.

Defaults to `https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE`.

### setProvisionsRequired

```
@CanIgnoreReturnValue
fun setProvisionsRequired(provisionsRequired: Int): FakeExoMediaDrm.Builder!
```

Sets how many successful provisioning round trips are needed for the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to be provisioned.

An unprovisioned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` will throw `https://developer.android.com/reference/android/media/NotProvisionedException.html` from methods that declare it until enough valid provisioning responses are passed to `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#provideProvisionResponse(byte[])`.

Defaults to 0 (i.e. device is already provisioned).

### throwNoSuchMethodErrorForProvisioningAndResourceBusy

```
@CanIgnoreReturnValue
fun throwNoSuchMethodErrorForProvisioningAndResourceBusy(
    throwNoSuchMethodErrorForProvisioningAndResourceBusy: Boolean
): FakeExoMediaDrm.Builder!
```

Configures the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to throw `https://developer.android.com/reference/java/lang/NoSuchMethodError.html` instead of `https://developer.android.com/reference/android/media/NotProvisionedException.html` or `https://developer.android.com/reference/android/media/ResourceBusyException.html`.

This simulates a framework bug (b/291440132) introduced in API 34 and resolved by http://r.android.com/2770659, allowing us to test workarounds for the bug.

The default is `false`.

### throwNotProvisionedExceptionFromGetKeyRequest

```
@CanIgnoreReturnValue
fun throwNotProvisionedExceptionFromGetKeyRequest(): FakeExoMediaDrm.Builder!
```

Configures the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` to throw any `https://developer.android.com/reference/android/media/NotProvisionedException.html` from `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)` instead of the default behaviour of throwing from `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm#openSession()`.