This tool validates Tuning Fork proto and settings files in an APK.
To create a jar file: ./gradlew createJar
To run validation: java -jar TuningforkApkValidationTool.jar \ --tuningforkPath $PATH_TO_FOLDER \ --protoCompiler $PATH_TO_PROTO_BINARY
As an example, to run the validation tool on the Tuning Fork sample insightsdemo with the Linux Proto Compiler:
java -jar build/libs/TuningforkApkValidationTool.jar \ --tuningforkPath ../../../../samples/tuningfork/insightsdemo/app/src/main/assets/tuningfork \ --protoCompiler ../../../../third_party/protobuf-3.0.0/install/linux-x86/bin/protoc
The APK must contain a assets/tuningfork/tuningfork_settings.bin file with serialized data for a Settings
proto message:
message Settings { message Histogram { optional int32 instrument_key = 1; optional float bucket_min = 2; optional float bucket_max = 3; optional int32 n_buckets = 4; } message AggregationStrategy { enum Submission { TIME_BASED = 1; TICK_BASED = 2; } optional Submission method = 1; optional int32 intervalms_or_count = 2; optional int32 max_instrumentation_keys = 3; repeated int32 annotation_enum_size = 4; } optional AggregationStrategy aggregation_strategy = 1; repeated Histogram histograms = 2; }
A Settings
message must have:
max_instrumentation_keys
must be between 1 and 256,annotation_enum_size
must match the Annotation
message (see below).Example of data before serialization:
aggregation_strategy: { method: TIME_BASED, intervalms_or_count: 600000, max_instrumentation_keys: 2, annotation_enum_size: [3, 4] } histograms: [ { instrument_key: 0, bucket_min: 28, bucket_max: 32, n_buckets: 70 }, { instrument_key: 1, bucket_min: 28, bucket_max: 32, n_buckets: 70 } ]
The Apk must contain an assets/tuningfork/dev_tuningfork.proto file with Annotation
and FidelityParams
proto message definitions.
Both messages (Annotation
and FidelityParams
) must follow these rules
Additional limitations for Annotation
messages only:
ENUM
typesAdditional limitation for FidelityParams
messsages only:
ENUM
, FLOAT
and INT32
typesValid .proto file:
syntax = "proto3"; package com.google.tuningfork; enum LoadingState { UNKNOWN = 0; LOADING = 1; NOT_LOADING = 2; } enum Level { UNKNOWN = 0; Level_1 = 1; Level_2 = 2; Level_3 = 3; } message Annotation { LoadingState loading_state = 1; Level level = 2; } enum QualitySettings { UNKNOWN = 0; FASTEST = 1; FAST = 2; SIMPLE = 3; GOOD = 4; BEAUTIFUL = 5; FANTASTIC = 6; } message FidelityParams { QualitySettings quality_settings = 1; int32 lod_level = 2; float distance = 3; }
annotation_enum_size in the Settings proto must match the ‘Annotation’ message.
For example, from the Annotation
message above:
LoadingState
enum is 3Level
enum is 4Annotation
message contains two fields - ‘loading_state’ and ‘level’annotation_enum_size
must be [3, 4]The APK must contain at least one file in assets/tuningfork folder with the pattern dev_tuningfork_fidelityparams_.{1,15}.bin.
Each file contains serialized parameters for the FidelityParams
proto message from the dev_tuningfork.proto file.