# BinderStressCreator

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/BinderStressCreator.java+class:androidx.media3.test.utils.BinderStressCreator)

*** ** * ** ***


```
@UnstableApi
class BinderStressCreator : AutoCloseable
```

<br />

*** ** * ** ***

A utility for creating artificial stress on the system process binder.

While the class is active, any attempt to call a binder method to the system process will be much slower.

This class should be used in a try-with-resources block.

Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator#verifyNoSystemBinderCalls(com.google.common.base.Supplier<T>,java.util.function.Consumer<T>)` to verify no system binder calls happen in a test.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator#BinderStressCreator(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html!)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator#close()()` |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T> https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator#verifyNoSystemBinderCalls(com.google.common.base.Supplier<T>,java.util.function.Consumer<T>)( systemUnderTest: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<T!>!, cleanUp: https://developer.android.com/reference/java/util/function/Consumer.html<T!>! )` Verifies that the provided system-under-test does not exercise any system binder calls by comparing the run time with and without additional stress caused by `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator`. |

## Public constructors

### BinderStressCreator

```
BinderStressCreator(context: Context!)
```

## Public functions

### close

```
fun close(): Unit
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html` |   |

### verifyNoSystemBinderCalls

```
java-static fun <T> verifyNoSystemBinderCalls(
    systemUnderTest: Supplier<T!>!,
    cleanUp: Consumer<T!>!
): Unit
```

Verifies that the provided system-under-test does not exercise any system binder calls by comparing the run time with and without additional stress caused by `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/BinderStressCreator`.

| Parameters |
|---|---|
| `systemUnderTest: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<T!>!` | The system-under-test that can return a test object for later clean-up. |
| `cleanUp: https://developer.android.com/reference/java/util/function/Consumer.html<T!>!` | The clean-up stage for the system-under-test. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html` |   |