RetryPolicy.ExecutionState


@ExperimentalRetryPolicy
interface RetryPolicy.ExecutionState


Provides insights into the current execution state of the camera initialization process.

The ExecutionState empowers app developers to make informed decisions about retry strategies and fine-tune timeout settings. It also facilitates comprehensive app-level logging for tracking initialization success/failure rates and overall camera performance.

Key use cases:

  • Determining whether to retry initialization based on specific error conditions.
  • Logging detailed execution information for debugging and analysis.
  • Monitoring retry success/failure rates to identify potential issues.

Summary

Constants

const Int

Indicates that the CameraProvider failed to initialize due to an unavailable camera.

const Int

Indicates that initialization of CameraX failed due to invalid customization options within the provided CameraXConfig.

const Int

Indicates that the initialization encountered an unknown error.

Public functions

Throwable?

Gets the cause that occurred during the task execution, if any.

Long

Gets the total execution time of the initialization task in milliseconds.

Int

Indicates the total number of attempts made to initialize the camera, including the current attempt.

Int

Retrieves the status of the most recently completed initialization attempt.

Constants

STATUS_CAMERA_UNAVAILABLE

Added in 1.4.0-alpha05
const val STATUS_CAMERA_UNAVAILABLE = 2: Int

Indicates that the CameraProvider failed to initialize due to an unavailable camera. This error suggests a temporary issue with the device's cameras, and retrying may resolve the issue.

STATUS_CONFIGURATION_FAIL

Added in 1.4.0-alpha05
const val STATUS_CONFIGURATION_FAIL = 1: Int

Indicates that initialization of CameraX failed due to invalid customization options within the provided CameraXConfig. This error typically indicates a problem with the configuration settings and may require developer attention to resolve.

Possible Causes:

  • Incorrect or incompatible settings within the CameraXConfig.
  • Conflicting options that prevent successful initialization.
  • Missing or invalid values for essential configuration parameters.

To troubleshoot: Please see getCause().getMessage() for details, and review configuration of the CameraXConfig to identify potential errors or inconsistencies in the customization options.

STATUS_UNKNOWN_ERROR

Added in 1.4.0-alpha05
const val STATUS_UNKNOWN_ERROR = 0: Int

Indicates that the initialization encountered an unknown error. This error may be transient, and retrying may resolve the issue.

Public functions

getCause

Added in 1.4.0-alpha05
fun getCause(): Throwable?

Gets the cause that occurred during the task execution, if any.

Returns
Throwable?

The cause that occurred during the task execution, or null if there was no error.

getExecutedTimeInMillis

Added in 1.4.0-alpha05
fun getExecutedTimeInMillis(): Long

Gets the total execution time of the initialization task in milliseconds.

Returns
Long

The total execution time of the initialization task in milliseconds.

getNumOfAttempts

Added in 1.4.0-alpha05
fun getNumOfAttempts(): Int

Indicates the total number of attempts made to initialize the camera, including the current attempt. The count starts from 1.

Returns
Int

The total number of attempts made to initialize the camera.

getStatus

Added in 1.4.0-alpha05
fun getStatus(): Int

Retrieves the status of the most recently completed initialization attempt.

Returns
Int

The status code representing the outcome of the initialization.