Tuning Fork extra utilities

Extra utility functions to use Tuning Fork.

Summary

Functions

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.
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.
TuningFork_startFidelityParamDownloadThread(const TuningFork_CProtobufSerialization *default_params, TuningFork_FidelityParamsCallback fidelity_params_callback)
Download fidelity parameters on a separate thread.

Functions

TuningFork_findFidelityParamsInApk

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.

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

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

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 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