# UwbClientSessionScope

Artifact: [androidx.core.uwb:uwb](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/UwbClientSessionScope.kt+class:androidx.core.uwb.UwbClientSessionScope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

*** ** * ** ***


```
public interface UwbClientSessionScope
```

<br />

Known direct subclasses [UwbControleeSessionScope](https://developer.android.com/reference/androidx/core/uwb/UwbControleeSessionScope), [UwbControllerSessionScope](https://developer.android.com/reference/androidx/core/uwb/UwbControllerSessionScope)

|---|---|
| `https://developer.android.com/reference/androidx/core/uwb/UwbControleeSessionScope` | Interface for controlee client session that is established between nearby UWB devices. |
| `https://developer.android.com/reference/androidx/core/uwb/UwbControllerSessionScope` | Interface for controller client session that is established between nearby UWB devices. |

*** ** * ** ***

Interface for client session that is established between nearby UWB devices.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/UwbAddress` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#getLocalAddress()()` A local address can only be used for a single ranging session. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingCapabilities` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#getRangingCapabilities()()` Returns the `https://developer.android.com/reference/androidx/core/uwb/RangingCapabilities` which the device supports. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingParameters parameters)` Returns a flow of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`. |
| `default @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/SensorFusionResult>` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.SensorFusionParameters)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/SensorFusionParameters parameters)` Prepare a sensor fusion session, which performs software angle of arrival estimation and adjusts range for local device motion at a high resolution. |
| `abstract void` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#reconfigureRangeDataNtf(kotlin.Int,kotlin.Int,kotlin.Int)( int configType, int proximityNear, int proximityFar )` Dynamically reconfigures range data notification config to an active ranging session. |

| ### Extension functions |
|---|---|
| `default final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScopeRx.https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#(androidx.core.uwb.UwbClientSessionScope).rangingResultsFlowable(androidx.core.uwb.RangingParameters)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingParameters parameters )` Returns a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`. |
| `default final @https://developer.android.com/reference/androidx/annotation/NonNull http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScopeRx.https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#(androidx.core.uwb.UwbClientSessionScope).rangingResultsObservable(androidx.core.uwb.RangingParameters)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/uwb/RangingParameters parameters )` Returns an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` stream of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`. |

## Public methods

### getLocalAddress

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
abstract @NonNull UwbAddress getLocalAddress()
```

A local address can only be used for a single ranging session. After a ranging session is ended, a new address will be allocated.

Ranging session duration may also be limited to prevent addresses from being used for too long. In this case, your ranging session would be suspended and clients would need to exchange the new address with their peer before starting again.

### getRangingCapabilities

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
abstract @NonNull RangingCapabilities getRangingCapabilities()
```

Returns the `https://developer.android.com/reference/androidx/core/uwb/RangingCapabilities` which the device supports.

### prepareSession

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
abstract @NonNull Flow<@NonNull RangingResult> prepareSession(@NonNull RangingParameters parameters)
```

Returns a flow of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`. Consuming the flow will initiate the UWB ranging and only one flow can be initiated. To consume the flow from multiple consumers, convert the flow to a SharedFlow.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a new flow was consumed again after the UWB ranging is already initiated. |
| `https://developer.android.com/reference/androidx/core/uwb/exceptions/UwbSystemCallbackException` | if the backend UWB system has resulted in an error. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if ranging does not have the `android.permission.UWB_RANGING` permission. Apps must have requested and been granted this permission before calling this method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session without setting complex channel and peer address. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session with invalid config id or ranging update type. |

### prepareSession

Added in [1.1.0-alpha03](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.1.0-alpha03)

```
default @NonNull Flow<@NonNull SensorFusionResult> prepareSession(@NonNull SensorFusionParameters parameters)
```

Prepare a sensor fusion session, which performs software angle of arrival estimation and adjusts range for local device motion at a high resolution.

Sensor fusion relies on ARCore to estimate local device odometry. Before calling this method, you must follow ARCore documentation to [enable AR in your app](https://developers.google.com/ar/develop/java/enable-arcore).

This method has 2 possible failure modes:

- "Hard failures" that indicate lack of accountability from the caller. When one of these occurs, the returned flow will produce a `https://developer.android.com/reference/androidx/core/uwb/RangingResult.RangingResultFailure` and stop.

- "Soft failures" that arise from conditions that the caller may not have direct control over. When one of these occurs, the returned flow will produce a `https://developer.android.com/reference/androidx/core/uwb/SensorFusionResult.SensorFusionFallback` and the session will fall back to standard UWB ranging. That is, all subsequent results will be instances of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a new flow was consumed again after the UWB ranging is already initiated. |
| `https://developer.android.com/reference/androidx/core/uwb/exceptions/UwbSystemCallbackException` | if the backend UWB system has resulted in an error. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the app does not have both the `android.permission.UWB_RANGING` and `https://developer.android.com/reference/android/Manifest.permission.html#CAMERA` permissions. Apps must have requested and been granted these permissions before calling this method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session without setting complex channel and peer address. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session with invalid config id or ranging update type. |

### reconfigureRangeDataNtf

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
abstract void reconfigureRangeDataNtf(
    int configType,
    int proximityNear,
    int proximityFar
)
```

Dynamically reconfigures range data notification config to an active ranging session.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the ranging is inactive. Otherwise, this method will return successfully, then clients are expected to handle `https://developer.android.com/reference/androidx/core/uwb/RangingResult.RangingResultFailure` with the controlee as parameter of the callback. |

## Extension functions

### UwbClientSessionScopeRx.rangingResultsFlowable

Artifact: [androidx.core.uwb:uwb-rxjava3](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/rxjava3/UwbClientSessionScopeRx.kt+function:rangingResultsFlowable)

```
default final @NonNull Flowable<@NonNull RangingResult> UwbClientSessionScopeRx.rangingResultsFlowable(
    @NonNull UwbClientSessionScope receiver,
    @NonNull RangingParameters parameters
)
```

Returns a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)` |   |

### UwbClientSessionScopeRx.rangingResultsObservable

Artifact: [androidx.core.uwb:uwb-rxjava3](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/rxjava3/UwbClientSessionScopeRx.kt+function:rangingResultsObservable)

```
default final @NonNull Observable<@NonNull RangingResult> UwbClientSessionScopeRx.rangingResultsObservable(
    @NonNull UwbClientSessionScope receiver,
    @NonNull RangingParameters parameters
)
```

Returns an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` stream of `https://developer.android.com/reference/androidx/core/uwb/RangingResult`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)` |   |