CaptureRequestWrapper


interface CaptureRequestWrapper : CaptureRequestMetadata

Known direct subclasses
FakeCaptureRequest

A fake implementation of CaptureRequestWrapper designed for unit testing.


A wrapper interface representing the settings applied to a specific camera capture request.

This interface provides a unified way to inspect the configuration parameters sent to the camera device during a capture session. It supports querying:

  1. Native Camera2 capture request keys via CaptureRequest.Key (using get).

  2. Extension or custom metadata keys via Metadata.Key (using Metadata.get, inherited from Metadata).

Additionally, if access to the underlying native Android CaptureRequest is required, this interface can be unwrapped using unwrapAs (inherited from UnsafeWrapper).

Example Usage

Querying a native Camera2 CaptureRequest key:

val requestWrapper: CaptureRequestWrapper = ...
val exposureTime: Long? = requestWrapper[CaptureRequest.SENSOR_EXPOSURE_TIME]

Querying a custom metadata key:

val requestWrapper: CaptureRequestWrapper = ...
val customExtensionKey = Metadata.Key<Int>("androidx.camera.custom_extension")
val customValue: Int? = requestWrapper[customExtensionKey]

Unwrapping the underlying native CaptureRequest:

val requestWrapper: CaptureRequestWrapper = ...
val nativeRequest: CaptureRequest? = requestWrapper.unwrapAs<CaptureRequest>()

Note: This interface is not stable for inheritance. Implementations should not be created directly by clients. For testing, use the fakes in the androidx.camera.common.testing package (such as FakeCaptureRequest).

Summary

Public properties

List<CaptureRequest.Key<*>>

The list of all CaptureRequest.Keys that are set or supported by this capture request.

Inherited functions

From androidx.camera.common.CaptureRequestMetadata
operator T?
<T : Any> get(key: CaptureRequest.Key<T>)

Retrieves the value of the specified CaptureRequest.Key.

open T
<T : Any> getOrDefault(key: CaptureRequest.Key<T>, default: T)

Retrieves the value of the specified CaptureRequest.Key, or returns default if the key is not present or its value is null.

From androidx.camera.common.Metadata
operator T?
<T : Any> get(key: Metadata.Key<T>)

Retrieves the value associated with the specified Metadata.Key.

open T
<T : Any> getOrDefault(key: Metadata.Key<T>, default: T)

Retrieves the value associated with the specified Metadata.Key, or returns default if the key is not present.

From androidx.camera.common.UnsafeWrapper
T?
<T : Any> unwrapAs(type: Class<T>)

Attempts to unwrap this object into the specified underlying type.

Inherited properties

From androidx.camera.common.Metadata
Set<Metadata.Key<*>>

The set of all custom Metadata.Keys currently available in this container.

Public properties

keys

Added in 1.7.0-alpha03
val keysList<CaptureRequest.Key<*>>

The list of all CaptureRequest.Keys that are set or supported by this capture request.

See also
getKeys