# CameraCharacteristicsWrappers

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CameraCharacteristicsWrapper.kt+class:androidx.camera.common.CameraCharacteristicsWrappers) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
object CameraCharacteristicsWrappers
```

<br />

*** ** * ** ***

Custom metadata keys for `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper`.

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.content.Context,androidx.camera.common.CameraId,kotlin.collections.Set)( context: https://developer.android.com/reference/android/content/Context.html, cameraId: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId, dynamicKeys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<*>> )` Loads `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` for the given `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.content.Context,androidx.camera.common.CameraId,kotlin.collections.Set)` using `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.hardware.camera2.CameraManager,androidx.camera.common.CameraId,kotlin.Boolean,kotlin.collections.Set)( cameraManager: https://developer.android.com/reference/android/hardware/camera2/CameraManager.html, cameraId: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId, isRestricted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, dynamicKeys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<*>> )` Loads `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` for the given `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.hardware.camera2.CameraManager,androidx.camera.common.CameraId,kotlin.Boolean,kotlin.collections.Set)` using `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#wrap(androidx.camera.common.CameraId,android.hardware.camera2.CameraCharacteristics,kotlin.Boolean,kotlin.collections.Set)( cameraId: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId, characteristics: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html, isRestricted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, dynamicKeys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<*>> )` Wraps a native `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` into a `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper`. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/ColorSpaceProfilesWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsMetadata.https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#(androidx.camera.common.CameraCharacteristicsMetadata).availableColorSpaceProfiles()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/common/ColorSpaceProfilesWrapper` supported by the camera device. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/DynamicRangeProfilesWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsMetadata.https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#(androidx.camera.common.CameraCharacteristicsMetadata).availableDynamicRangeProfiles()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/common/DynamicRangeProfilesWrapper` supported by the camera device. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/StreamConfigurationMapWrapper?` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsMetadata.https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#(androidx.camera.common.CameraCharacteristicsMetadata).streamConfigurationMap()` Extension property to query `https://developer.android.com/reference/kotlin/androidx/camera/common/StreamConfigurationMapWrapper` directly. |

## Public functions

### loadFrom

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun loadFrom(
    context: Context,
    cameraId: CameraId,
    dynamicKeys: Set<CameraCharacteristics.Key<*>> = emptySet()
): CameraCharacteristicsWrapper
```

Loads `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` for the given `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.content.Context,androidx.camera.common.CameraId,kotlin.collections.Set)` using `https://developer.android.com/reference/android/content/Context.html`.

This method will perform an instantaneous check to determine if the camera permission is granted, setting `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper#isRestricted()` accordingly.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrapper
import androidx.camera.common.CameraCharacteristicsWrappers
import androidx.camera.common.CameraId

val cameraId = CameraId(cameraIdString)

// Load CameraCharacteristicsWrapper directly using Context.
// This checks camera permissions and marks isRestricted accordingly.
val characteristicsFromContext: CameraCharacteristicsWrapper =
    CameraCharacteristicsWrappers.loadFrom(context, cameraId)

// Or load directly using CameraManager:
val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val characteristicsFromManager: CameraCharacteristicsWrapper =
    CameraCharacteristicsWrappers.loadFrom(cameraManager, cameraId)
```

### loadFrom

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun loadFrom(
    cameraManager: CameraManager,
    cameraId: CameraId,
    isRestricted: Boolean = false,
    dynamicKeys: Set<CameraCharacteristics.Key<*>> = emptySet()
): CameraCharacteristicsWrapper
```

Loads `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper` for the given `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrappers#loadFrom(android.hardware.camera2.CameraManager,androidx.camera.common.CameraId,kotlin.Boolean,kotlin.collections.Set)` using `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html`.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrapper
import androidx.camera.common.CameraCharacteristicsWrappers
import androidx.camera.common.CameraId

val cameraId = CameraId(cameraIdString)

// Load CameraCharacteristicsWrapper directly using Context.
// This checks camera permissions and marks isRestricted accordingly.
val characteristicsFromContext: CameraCharacteristicsWrapper =
    CameraCharacteristicsWrappers.loadFrom(context, cameraId)

// Or load directly using CameraManager:
val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val characteristicsFromManager: CameraCharacteristicsWrapper =
    CameraCharacteristicsWrappers.loadFrom(cameraManager, cameraId)
```

### wrap

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun wrap(
    cameraId: CameraId,
    characteristics: CameraCharacteristics,
    isRestricted: Boolean = false,
    dynamicKeys: Set<CameraCharacteristics.Key<*>> = emptySet()
): CameraCharacteristicsWrapper
```

Wraps a native `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` into a `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraCharacteristicsWrapper`.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrapper
import androidx.camera.common.CameraCharacteristicsWrappers
import androidx.camera.common.CameraId

val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val characteristics = cameraManager.getCameraCharacteristics(cameraIdString)
val cameraId = CameraId(cameraIdString)

// Wrap the native CameraCharacteristics instance into a CameraCharacteristicsWrapper.
val cameraCharacteristics: CameraCharacteristicsWrapper =
    CameraCharacteristicsWrappers.wrap(cameraId, characteristics)
```

## Public properties

### CameraCharacteristicsMetadata.availableColorSpaceProfiles

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CameraCharacteristicsWrapper.kt+symbol:availableColorSpaceProfiles) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
val CameraCharacteristicsMetadata.availableColorSpaceProfiles: ColorSpaceProfilesWrapper
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/common/ColorSpaceProfilesWrapper` supported by the camera device.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrappers.availableColorSpaceProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.availableDynamicRangeProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.streamConfigurationMap

// Access standard CameraCharacteristics keys using the get/bracket operator:
val sensorOrientation = cameraCharacteristics[CameraCharacteristics.SENSOR_ORIENTATION]
val lensFacing = cameraCharacteristics[CameraCharacteristics.LENS_FACING]

// Access extended/custom properties using the extension properties.
// Note: Querying these properties will query custom/compatibility metadata keys first
// (such as STREAM_CONFIGURATION_MAP, AVAILABLE_COLOR_SPACE_PROFILES,
// AVAILABLE_DYNAMIC_RANGE_PROFILES) and fallback to creating internal wrappers from the
// native platform characteristics. In unit tests, test fakes supply the custom wrapped
// versions via these metadata keys.
val streamConfigurationMap = cameraCharacteristics.streamConfigurationMap
val colorSpaceProfiles = cameraCharacteristics.availableColorSpaceProfiles
val dynamicRangeProfiles = cameraCharacteristics.availableDynamicRangeProfiles
```

### CameraCharacteristicsMetadata.availableDynamicRangeProfiles

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CameraCharacteristicsWrapper.kt+symbol:availableDynamicRangeProfiles) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
val CameraCharacteristicsMetadata.availableDynamicRangeProfiles: DynamicRangeProfilesWrapper
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/common/DynamicRangeProfilesWrapper` supported by the camera device.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrappers.availableColorSpaceProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.availableDynamicRangeProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.streamConfigurationMap

// Access standard CameraCharacteristics keys using the get/bracket operator:
val sensorOrientation = cameraCharacteristics[CameraCharacteristics.SENSOR_ORIENTATION]
val lensFacing = cameraCharacteristics[CameraCharacteristics.LENS_FACING]

// Access extended/custom properties using the extension properties.
// Note: Querying these properties will query custom/compatibility metadata keys first
// (such as STREAM_CONFIGURATION_MAP, AVAILABLE_COLOR_SPACE_PROFILES,
// AVAILABLE_DYNAMIC_RANGE_PROFILES) and fallback to creating internal wrappers from the
// native platform characteristics. In unit tests, test fakes supply the custom wrapped
// versions via these metadata keys.
val streamConfigurationMap = cameraCharacteristics.streamConfigurationMap
val colorSpaceProfiles = cameraCharacteristics.availableColorSpaceProfiles
val dynamicRangeProfiles = cameraCharacteristics.availableDynamicRangeProfiles
```

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES` |   |

### CameraCharacteristicsMetadata.streamConfigurationMap

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CameraCharacteristicsWrapper.kt+symbol:streamConfigurationMap) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
val CameraCharacteristicsMetadata.streamConfigurationMap: StreamConfigurationMapWrapper?
```

Extension property to query `https://developer.android.com/reference/kotlin/androidx/camera/common/StreamConfigurationMapWrapper` directly.

This is the preferred way to access the `https://developer.android.com/reference/kotlin/androidx/camera/common/StreamConfigurationMapWrapper` in Kotlin. It will fallback to creating a wrapper from the standard `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SCALER_STREAM_CONFIGURATION_MAP` if the compatibility key is not populated.

```kotlin
import androidx.camera.common.CameraCharacteristicsWrappers.availableColorSpaceProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.availableDynamicRangeProfiles
import androidx.camera.common.CameraCharacteristicsWrappers.streamConfigurationMap

// Access standard CameraCharacteristics keys using the get/bracket operator:
val sensorOrientation = cameraCharacteristics[CameraCharacteristics.SENSOR_ORIENTATION]
val lensFacing = cameraCharacteristics[CameraCharacteristics.LENS_FACING]

// Access extended/custom properties using the extension properties.
// Note: Querying these properties will query custom/compatibility metadata keys first
// (such as STREAM_CONFIGURATION_MAP, AVAILABLE_COLOR_SPACE_PROFILES,
// AVAILABLE_DYNAMIC_RANGE_PROFILES) and fallback to creating internal wrappers from the
// native platform characteristics. In unit tests, test fakes supply the custom wrapped
// versions via these metadata keys.
val streamConfigurationMap = cameraCharacteristics.streamConfigurationMap
val colorSpaceProfiles = cameraCharacteristics.availableColorSpaceProfiles
val dynamicRangeProfiles = cameraCharacteristics.availableDynamicRangeProfiles
```

```kotlin
import androidx.camera.common.CameraCharacteristicsWrapper
import androidx.camera.common.CameraCharacteristicsWrappers.streamConfigurationMap
import androidx.camera.common.CameraId
import androidx.camera.common.testing.FakeCameraCharacteristics
import androidx.camera.common.testing.FakeStreamConfigurationMap
import androidx.camera.common.testing.FakeStreamConfigurationMap.OutputKey
import androidx.camera.common.testing.FakeStreamConfigurationMap.OutputValues

// Create a fake stream configuration map with custom resolutions and formats.
val fakeStreamConfigurationMap =
    FakeStreamConfigurationMap(
        outputsTable =
            linkedMapOf(
                OutputKey(ImageFormat.YUV_420_888, Size(1920, 1080)) to OutputValues(),
                OutputKey(ImageFormat.JPEG, Size(1920, 1080)) to
                    OutputValues(
                        stallDuration = 200_000_000L // 200ms stall duration
                    ),
            )
    )

// Supply the fake stream configuration map via STREAM_CONFIGURATION_MAP metadata key.
val fakeCharacteristics: CameraCharacteristicsWrapper =
    FakeCameraCharacteristics(
        cameraId = CameraId("0"),
        cameraCharacteristics =
            mapOf(
                CameraCharacteristics.LENS_FACING to CameraCharacteristics.LENS_FACING_BACK,
                CameraCharacteristics.SENSOR_ORIENTATION to 90,
            ),
        cameraMetadata =
            mapOf(
                CameraCharacteristicsWrapper.Keys.STREAM_CONFIGURATION_MAP to
                    fakeStreamConfigurationMap
            ),
    )

// The extension property accesses the wrapped version (STREAM_CONFIGURATION_MAP) first,
// returning the FakeStreamConfigurationMap in unit tests without needing real camera hardware.
val streamConfigMap = checkNotNull(fakeCharacteristics.streamConfigurationMap)
val supportedFormats = streamConfigMap.getOutputFormats()
val yuvSizes = streamConfigMap.getOutputSizes(ImageFormat.YUV_420_888)
```