syntax = "proto2";

package android.os.statsd.art;

import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/atom_field_options.proto";
import "frameworks/proto_logging/stats/enums/art/art_enums.proto";
import "frameworks/proto_logging/stats/enums/art/common_enums.proto";

option java_package = "com.android.os.art";
option java_multiple_files = true;

extend Atom {
    // Pushed atoms
    optional ArtDatumReported art_datum_reported = 332 [(module) = "art"];
    // Deprecated in favour of the ArtDeviceStatus pulled atom
    optional ArtDeviceDatumReported art_device_datum_reported = 550 [(module) = "art", deprecated = true];
    optional ArtDatumDeltaReported art_datum_delta_reported = 565 [(module) = "art"];
    optional ArtDex2OatReported art_dex2oat_reported = 929 [(module) = "art"];

    // Pulled atoms
    optional ArtDeviceStatus art_device_status = 10205 [(module) = "art"];
}

message ArtDatumReported {
    // The session ID is used to correlate this report with others from the same ART instance.
    optional int64 session_id = 1;

    // The UID of the app that ART is running on behalf of.
    optional int32 uid = 2 [(is_uid) = true];

    // What compiler filter the APK or DEX file was compiled with.
    optional ArtCompileFilter compile_filter = 3;

    // Why the package was compiled the way it was.
    optional ArtCompilationReason compilation_reason = 4;

    // The number of milliseconds since the ART runtime instance was started.
    optional int64 timestamp_millis = 5;

    // What kind of thread (UI or background) this metric corresponds to.
    optional ArtThreadType thread_type = 6 [deprecated = true];

    // Which counter this is that is being reported.
    optional ArtDatumId kind = 7;

    // The value of the counter.
    optional int64 value = 8;

    // The type of dex metadata
    optional ArtDexMetadataType dex_metadata_type = 9 [deprecated = true];

    // The type of the APK file.
    optional ArtApkType apk_type = 10 [deprecated = true];

    // The ISA of the device.
    optional ArtIsa isa = 11;

    // The Garbage Collector used in the Android Runtime.
    optional ArtGcCollectorType gc = 12;

    // The support for userfaultfd and minor fault mode.
    optional ArtUffdSupport uffd_support = 13 [deprecated = true];
}

// ArtDatumDeltaReported is the same as ArtDatumReported, except for the kind field
// (ArtDatumDeltaId here, ArtDatumId for ArtDatumReported)
message ArtDatumDeltaReported {
    // The session ID is used to correlate this report with others from the same ART instance.
    optional int64 session_id = 1;

    // The UID of the app that ART is running on behalf of.
    optional int32 uid = 2 [(is_uid) = true];

    // What compiler filter the APK or DEX file was compiled with.
    optional ArtCompileFilter compile_filter = 3;

    // Why the package was compiled the way it was.
    optional ArtCompilationReason compilation_reason = 4;

    // The number of milliseconds since the ART runtime instance was started.
    optional int64 timestamp_millis = 5;

    // What kind of thread (UI or background) this metric corresponds to.
    optional ArtThreadType thread_type = 6 [deprecated = true];

    // Which counter this is that is being reported.
    optional ArtDatumDeltaId kind = 7;

    // The value of the counter.
    optional int64 value = 8;

    // The type of dex metadata
    optional ArtDexMetadataType dex_metadata_type = 9 [deprecated = true];

    // The type of the APK file.
    optional ArtApkType apk_type = 10 [deprecated = true];

    // The ISA of the device.
    optional ArtIsa isa = 11;

    // The Garbage Collector used in the Android Runtime.
    optional ArtGcCollectorType gc = 12;

    // The support for userfaultfd and minor fault mode.
    optional ArtUffdSupport uffd_support = 13 [deprecated = true];
}

message ArtDex2OatReported {
    // The UID of the app that ART is running on behalf of.
    optional int32 uid = 1 [(is_uid) = true];

    // The target compiler filter, passed as the `--compiler-filer` option to dex2oat.
    optional ArtCompileFilter compiler_filter = 2;

    // The compilation reason, passed as the `--compilation-reason` option to dex2oat.
    optional ArtCompilationReason compilation_reason = 3;

    // The type of DM file.
    optional ArtDexMetadataType dex_metadata_type = 4;

    // The type of the APK file.
    optional ArtApkType apk_type = 5;

    // The ISA (instruction set architecture) of the device.
    optional ArtIsa isa = 6;

    // Status for the dex2oat run.
    optional ExecResultStatus result_status = 7;

    // Exit code for the dex2oat run if status is EXEC_RESULT_STATUS_EXITED, else -1.
    optional int32 result_exit_code = 8;

    // Signal for the dex2oat run if status is EXEC_RESULT_STATUS_SIGNALED, else 0.
    optional int32 result_signal = 9;

    // Total size of dex2oat artifacts, in kilobytes.
    optional int32 artifacts_size_kb = 10;

    // Total compilation time, in milliseconds.
    optional int32 compilation_time_millis = 11;
}

/**
 * Logs ART metrics that are device-specific (as opposed to app-specific ones logged by
 * ArtDatumReported).
 *
 * Logged from:
 *   art/runtime/metrics/statsd.cc
 */
 message ArtDeviceDatumReported {
    optional BootImageStatus boot_image_status = 1;
}

/**
 * Reports ART metrics that are device-specific (as opposed to app-specific ones logged by
 * ArtDatumReported).
 */
message ArtDeviceStatus {
    optional BootImageStatus boot_image_status = 1;
}
