Tuning Fork extra utilities

Extra utility functions to use Tuning Fork.

Summary

Functions

TuningFork_findFidelityParamsInApk(JNIEnv *env, jobject context, const char *filename, CProtobufSerialization *fidelity_params)
Load fidelity params from assets/tuningfork/ Ownership of fp is passed to the caller: call CProtobufSerialization_Free to deallocate data stored in the struct.
TuningFork_saveOrDeleteFidelityParamsFile(JNIEnv *env, jobject context, const 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 CProtobufSerialization *default_params, ProtoCallback fidelity_params_callback)
Download fidelity parameters on a separate thread.

Functions

TuningFork_findFidelityParamsInApk

TFErrorCode TuningFork_findFidelityParamsInApk(
  JNIEnv *env,
  jobject context,
  const char *filename,
  CProtobufSerialization *fidelity_params
)

Load fidelity params from assets/tuningfork/ Ownership of fp is passed to the caller: call 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
TFERROR_OK if no error

TuningFork_saveOrDeleteFidelityParamsFile

TFErrorCode TuningFork_saveOrDeleteFidelityParamsFile(
  JNIEnv *env,
  jobject context,
  const 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
TFERROR_OK if no error

TuningFork_startFidelityParamDownloadThread

TFErrorCode TuningFork_startFidelityParamDownloadThread(
  const CProtobufSerialization *default_params,
  ProtoCallback 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 TFSettings 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
TFERROR_OK if no error