# Tuning Fork extra utilities

Extra utility functions to use Tuning Fork.

## Summary

| ### Functions ||
|---|---|
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork-extra#group__tuningfork__extra_1ga3bffad5089e124dbb7daba3fb7163802(JNIEnv *env, jobject context, const char *filename, https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuning-fork-c-protobuf-serialization#struct_tuning_fork___c_protobuf_serialization *fidelity_params)` | `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#group__tuningfork_1ga37de0aa93ae4d18dacdf21778a559527` Load fidelity params from assets/tuningfork/ Ownership of `fp` is passed to the caller: call TuningFork_CProtobufSerialization_free to deallocate data stored in the struct. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork-extra#group__tuningfork__extra_1ga6508fb3576cd2dca18293b17366cebd7(JNIEnv *env, jobject context, const https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuning-fork-c-protobuf-serialization#struct_tuning_fork___c_protobuf_serialization *fidelity_params)` | `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#group__tuningfork_1ga37de0aa93ae4d18dacdf21778a559527` The TuningFork_init function will save fidelity params to a file for use when a download connection is not available. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork-extra#group__tuningfork__extra_1gae7734c246d06606f7977d9281bd9b9f0(const https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuning-fork-c-protobuf-serialization#struct_tuning_fork___c_protobuf_serialization *default_params, https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#group__tuningfork_1ga1a8f1743f180343c029abb264f9ad20b fidelity_params_callback)` | `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#group__tuningfork_1ga37de0aa93ae4d18dacdf21778a559527` Download fidelity parameters on a separate thread. |

## Functions

### TuningFork_findFidelityParamsInApk

```gdscript
TuningFork_ErrorCode TuningFork_findFidelityParamsInApk(
  JNIEnv *env,
  jobject context,
  const char *filename,
  TuningFork_CProtobufSerialization *fidelity_params
)
```
Load fidelity params from assets/tuningfork/ Ownership of `fp` is passed to the caller: call TuningFork_CProtobufSerialization_free to deallocate data stored in the struct.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `env` | JNIEnv | | `context` | Application context | | `filename` | The filename to load | | `fidelity_params` | Protocol buffer serialization of fidelity parameters found. | |
| **Returns** | TUNINGFORK_ERROR_OK if no error |

### TuningFork_saveOrDeleteFidelityParamsFile

```gdscript
TuningFork_ErrorCode TuningFork_saveOrDeleteFidelityParamsFile(
  JNIEnv *env,
  jobject context,
  const TuningFork_CProtobufSerialization *fidelity_params
)
```
The TuningFork_init function will save fidelity params to a file for use when a download connection is not available.

With this function, you can replace or delete the saved file.

| Details ||
|---|---|
| Parameters | |---|---| | `env` | JNIEnv | | `context` | Application context. | | `fidelity_params` | The parameters to save. The save file will be deleted if fidelity_params is NULL. | |
| **Returns** | TUNINGFORK_ERROR_OK if no error |

### TuningFork_startFidelityParamDownloadThread

```gdscript
TuningFork_ErrorCode TuningFork_startFidelityParamDownloadThread(
  const TuningFork_CProtobufSerialization *default_params,
  TuningFork_FidelityParamsCallback fidelity_params_callback
)
```
Download fidelity parameters on a separate thread.

A download thread is activated to retrieve fidelity params and retries are performed until a download is successful or a timeout occurs. Downloaded params are stored locally and used in preference of default params when the app is started in future. Requests will timeout according to the initial_request_timeout_ms and ultimate_request_timeout_ms fields in the [TuningFork_Settings](https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuning-fork-settings#struct_tuning_fork___settings) struct with which Tuning Fork was initialized.

| Details ||
|---|---|
| Parameters | |---|---| | `default_params` | A protobuf serialization containing the fidelity params that will be used if there is no download connection and there are no saved parameters. | | `fidelity_params_callback` | is called with any downloaded params or with default / saved params. | |
| **Returns** | TUNINGFORK_ERROR_OK if no error |