override fun enterBackground()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/redux/middleware/handler/CallingMiddlewareActionHandler.kt [124:147]


    override fun enterBackground(store: Store<ReduxState>) {
        store.dispatch(LifecycleAction.EnterBackgroundSucceeded())
        val state = store.getCurrentState()

        if (state.localParticipantState.cameraState.operation != CameraOperationalStatus.OFF &&
            state.localParticipantState.cameraState.operation != CameraOperationalStatus.PAUSED
        ) {
            if (state.callState.callingStatus != CallingStatus.NONE &&
                state.callState.callingStatus != CallingStatus.LOCAL_HOLD
            ) {
                callingService.turnCameraOff().whenComplete { _, error ->
                    if (error != null) {
                        store.dispatch(
                            LocalParticipantAction.CameraPauseFailed(
                                CallCompositeError(ErrorCode.TURN_CAMERA_OFF_FAILED, error)
                            )
                        )
                    } else {
                        store.dispatch(LocalParticipantAction.CameraPauseSucceeded())
                    }
                }
            }
        }
    }