# CameraDeviceSetupCompat

Artifact: [androidx.camera.featurecombinationquery:featurecombinationquery](https://developer.android.com/jetpack/androidx/releases/camera-featurecombinationquery) [View Source](https://cs.android.com/search?q=file:androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.java+class:androidx.camera.featurecombinationquery.CameraDeviceSetupCompat) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera-featurecombinationquery#1.5.0)

*** ** * ** ***

<br />

```
interface CameraDeviceSetupCompat
```

<br />

*** ** * ** ***

Interface for checking if a `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` is supported by the device.

This interface is a compatible version of the `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html` class.

Implementations of this interface must be able to check if a `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` is supported. They will check both the output streams and the session parameters, then return whether the combination works for the given camera. For example, a camera device may support HDR and 60FPS frame rate, but not both at the same time.

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html` |   |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` Result of a `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` query. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` | `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)(sessionConfig: https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html)` Checks if the `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` is supported. |
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` | `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupportedLegacy(androidx.camera.featurecombinationquery.SessionConfigurationLegacy)( sessionConfig: https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy )` Checks if the set of features in `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` is supported for the given camera. |

## Public functions

### isSessionConfigurationSupported

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

```
fun isSessionConfigurationSupported(sessionConfig: SessionConfiguration): CameraDeviceSetupCompat.SupportQueryResult
```

Checks if the `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` is supported.

**Note:** The Play Services implementation does not support querying `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html`s without an associated surface and will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` if an `OutputConfiguration` without an associated surface is passed. A `https://developer.android.com/reference/android/view/Surface.html` can be associated with an `OutputConfiguration` either during construction, or later with `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#addSurface(android.view.Surface)`. This is an unfortunate limitation of Android Framework APIs. For queries that are performance sensitive and need to happen before the final surface is ready, it is recommended to create temporary `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html` with a concrete surface from `https://developer.android.com/reference/android/media/ImageReader.html#newInstance(int, int, int, int)` that matches the desired final surface instead.

Following are examples of some common final surfaces, and how ImageReader can be used to query them:

- `SurfaceTexture.class`:

  ```kotlin
  ImageReader.newInstance(1920, 1080, PixelFormat.PRIVATE, 1,
                          HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE)
  ```
- `MediaRecorder.class`/`MediaCodec.class`:

  ```kotlin
  ImageReader.newInstance(1920, 1080, ImageFormat.PRIVATE, 1,
                          HardwareBuffer.USAGE_VIDEO_ENCODE)
  ```
- `SurfaceView.class`:

  ```kotlin
  ImageReader.newInstance(1920, 1080, ImageFormat.PRIVATE, 1,
                          HardwareBuffer.USAGE_COMPOSER_OVERLAY)
  ```

| Parameters |
|---|---|
| `sessionConfig: https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` | The `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` to check. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` | a `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` indicating if the `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` is supported. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraAccessException.html` | if the camera device is no longer connected or has encountered a fatal error. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if play-services implementation is included and an `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html` with a deferred Surface is passed. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` |   |

### isSessionConfigurationSupportedLegacy

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

```
fun isSessionConfigurationSupportedLegacy(
    sessionConfig: SessionConfigurationLegacy
): CameraDeviceSetupCompat.SupportQueryResult
```

Checks if the set of features in `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` is supported for the given camera.

This method and the legacy classes are provided to allow querying camera device capabilities without the need to call `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#openCamera(java.lang.String, android.hardware.camera2.CameraDevice.StateCallback, android.os.Handler)`. It must only be used for devices that do not support `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html` and will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html` when used for a `cameraId` for which `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#isCameraDeviceSetupSupported(java.lang.String)` returns true.

Even on older devices that do not support `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html`, if the `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` object can be obtained using `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#openCamera(java.lang.String, android.hardware.camera2.CameraDevice.StateCallback, android.os.Handler)`, then `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` should be used as the `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html` returned by Camera2 generally has more information pre-filled from the template which may change the result.

Note that this method does not, and can not query camera2's `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)`, so the returned `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult#getSource()` will never be `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult#SOURCE_ANDROID_FRAMEWORK()`. Additionally, there is a small possibility that the result of Camera2's `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` contradicts the result of this call. In such cases, a `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult#RESULT_UNSUPPORTED()` result can be considered authoritative, but `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult#RESULT_SUPPORTED()` may or may not be correct and is considered best effort.

**WARNING:** Use this method is discouraged for most developers. `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` should be used wherever possible. This method should only be used if performance is critical on older devices and you understand and protect against the caveats documented above.

| Parameters |
|---|---|
| `sessionConfig: https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` | The `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` to check. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` | a `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat.SupportQueryResult` indicating if the `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` is supported. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the camera device supports `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup.html` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if play-services implementation is included and an `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html` with a deferred Surface is passed. See note in `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/CameraDeviceSetupCompat#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionConfigurationLegacy` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/featurecombinationquery/SessionParametersLegacy` |   |