// AUTOGENERATED - DO NOT EDIT
// ---------------------------
// This file has been generated by
// AOSP://external/perfetto/tools/gen_merged_protos
// merging the perfetto config protos.
// This fused proto is intended to be copied in:
//  - Android tree, for statsd.
//  - Google internal repos.

syntax = "proto2";

package perfetto.protos;

option go_package = "github.com/google/perfetto/perfetto_proto";

// Begin of protos/perfetto/metrics/android/ad_services_metric.proto

// Next: 8
message AdServicesUiMetric {
  optional double common_service_initialization_latency = 1;
  optional double common_service_permission_check_latency = 2;
  optional double common_service_ux_engine_flow_latency = 3;
  optional double main_activity_creation_latency = 4;
  optional double consent_manager_initialization_latency = 5;
  optional double consent_manager_read_latency = 6;
  optional double consent_manager_write_latency = 7;
}

// Next: 2
message AdServicesAdIdMetric {
  optional double latency = 1;
}

// Next: 2
message AdServicesAppSetIdMetric {
  optional double latency = 1;
}

// Next: 5
message OnDevicePersonalizationMetric {
  optional double managing_service_initialization_latency = 1;
  optional double service_delegate_execute_flow_latency = 2;
  optional double service_delegate_request_surface_package_latency = 3;
  optional double service_delegate_register_web_trigger_latency = 4;
}

// Next: 5
message AdServicesMetric {
  repeated AdServicesUiMetric ui_metric = 1;
  repeated AdServicesAdIdMetric ad_id_metric = 2;
  repeated AdServicesAppSetIdMetric app_set_id_metric = 3;
  repeated OnDevicePersonalizationMetric odp_metric = 4;
}
// End of protos/perfetto/metrics/android/ad_services_metric.proto

// Begin of protos/perfetto/metrics/android/android_anomaly_metric.proto

// Detects outlier scenarios in different Android Systems in a trace. For now,
// this just detects high binder transaction rates. In the future, there could
// be others like garbage_collection, CPU, broadcasts, etc.
message AndroidAnomalyMetric {
  enum Unit {
    UNIT_UNSPECIFIED = 0;
    COUNT_PER_SECOND = 1;
  }

  // For anomalies related to a particular process.
  message ProcessAnomaly {
    optional string process_name = 1;
    optional uint32 pid = 2;
    optional Unit unit = 3;
    optional uint32 value = 4;
  }

  // Binder subsystem outliers with the following aggegations:
  // 1. Max incoming binder transaction count from each process over a one
  // second sliding window.
  // 2. Max outgoing binder transaction count from each process over a one
  // second sliding window.
  message Binder {
    repeated ProcessAnomaly max_incoming_process_count_per_second = 1;
    repeated ProcessAnomaly max_outgoing_process_count_per_second = 2;
  }

  optional Binder binder = 1;
}

// End of protos/perfetto/metrics/android/android_anomaly_metric.proto

// Begin of protos/perfetto/metrics/android/android_blocking_call.proto

// Blocking call on the main thread.
message AndroidBlockingCall {
  // Name of the blocking call
  optional string name = 1;
  // Number of times it happened within the CUJ
  optional int64 cnt = 2;
  // Total duration within the CUJ
  optional int64 total_dur_ms = 3;
  // Maximal duration within the CUJ
  optional int64 max_dur_ms = 4;
  // Minimal duration within the CUJ
  optional int64 min_dur_ms = 5;
  // Total duration within the CUJ in nanoseconds
  optional int64 total_dur_ns = 6;
  // Maximal duration within the CUJ in nanoseconds
  optional int64 max_dur_ns = 7;
  // Minimal duration within the CUJ in nanoseconds
  optional int64 min_dur_ns = 8;
  // Avg duration within the CUJ
  optional int64 avg_dur_ms = 9;
  // Avg duration within the CUJ in nanoseconds
  optional int64 avg_dur_ns = 10;
}

// End of protos/perfetto/metrics/android/android_blocking_call.proto

// Begin of protos/perfetto/metrics/android/process_metadata.proto

message AndroidProcessMetadata {
  // Process name. Usually, cmdline or <package_name>(:<custom_name>)?.
  optional string name = 1;

  // App uid under which this process runs.
  optional int64 uid = 2;

  // Android user-id running this process (applicable to multi-user android)
  optional int64 android_user_id = 10;

  // Type of Android user running this process (applicable to multi-user
  // android)
  optional string android_user_type = 12;

  // Package metadata from Android package list.
  message Package {
    optional string package_name = 1;
    optional int64 apk_version_code = 2;
    optional bool debuggable = 3;
  }

  // Package that this process belongs to.
  //
  // If this process shares its uid (see `packages_for_uid` field), the package
  // is determined based on the process name and package name. If there is no
  // match this field is empty.
  optional Package package = 7;

  // Pid of the process name.
  optional int64 pid = 9;

  // Whether the process is considered kernel or not
  optional bool is_kernel_task = 11;

  reserved 3, 4, 5, 6, 8;
}

// End of protos/perfetto/metrics/android/process_metadata.proto

// Begin of protos/perfetto/metrics/android/android_blocking_calls_cuj_metric.proto

// Blocking calls inside Android CUJs. Shows count and total duration for each.
message AndroidBlockingCallsCujMetric {
  repeated Cuj cuj = 1;

  // Next id: 7
  message Cuj {
    // ID of the CUJ that is unique within the trace.
    optional int32 id = 1;

    // Name of the CUJ, extracted from the CUJ jank or latency trace marker.
    // For example SHADE_EXPAND_COLLAPSE from J<SHADE_EXPAND_COLLAPSE>.
    optional string name = 2;

    // Details about the process (uid, version, etc)
    optional AndroidProcessMetadata process = 3;

    // ts of the CUJ trace marker slice, in ns.
    optional int64 ts = 4;

    // dur of the CUJ trace marker slice, in ns.
    optional int64 dur = 5;

    // List of blocking calls on the process main thread.
    repeated AndroidBlockingCall blocking_calls = 6;
  }
}

// End of protos/perfetto/metrics/android/android_blocking_calls_cuj_metric.proto

// Begin of protos/perfetto/metrics/android/android_blocking_call_per_frame.proto

// Blocking call per frame on the main thread.
message AndroidBlockingCallPerFrame {
  // Name of the blocking call
  optional string name = 1;
  // Maximal duration within a frame.
  optional int64 max_dur_per_frame_ms = 2;
  // Maximal duration within a frame in nanoseconds
  optional int64 max_dur_per_frame_ns = 3;
  // Mean duration within the CUJ
  optional int64 mean_dur_per_frame_ms = 4;
  // Mean duration within the CUJ in nanoseconds
  optional int64 mean_dur_per_frame_ns = 5;
  // Max count in a frame
  optional int64 max_cnt_per_frame = 6;
  // Mean count in a frame
  optional double mean_cnt_per_frame = 7;
}

// End of protos/perfetto/metrics/android/android_blocking_call_per_frame.proto

// Begin of protos/perfetto/metrics/android/android_blocking_calls_cuj_per_frame_metric.proto

// Blocking calls per frame inside Android jank CUJs. Shows count and duration
// for each.
message AndroidCujBlockingCallsPerFrameMetric {
  repeated Cuj cuj = 1;

  message Cuj {
    // Name of the CUJ, extracted from the CUJ jank trace marker.
    // For example SHADE_EXPAND_COLLAPSE from J<SHADE_EXPAND_COLLAPSE>.
    optional string name = 1;

    optional AndroidProcessMetadata process = 2;

    // List of blocking calls on the process UI thread.
    // Aggregation is done by CUJ name.
    repeated AndroidBlockingCallPerFrame blocking_calls = 3;
  }
}

// End of protos/perfetto/metrics/android/android_blocking_calls_cuj_per_frame_metric.proto

// Begin of protos/perfetto/metrics/android/android_blocking_calls_unagg.proto

// All blocking calls for a trace. Shows count and total duration for each.
message AndroidBlockingCallsUnagg {
  repeated ProcessWithBlockingCalls process_with_blocking_calls = 1;

  message ProcessWithBlockingCalls {
    // Details about the process (uid, version, etc)
    optional AndroidProcessMetadata process = 1;

    // List of blocking calls on the process main thread.
    repeated AndroidBlockingCall blocking_calls = 2;
  }
}

// End of protos/perfetto/metrics/android/android_blocking_calls_unagg.proto

// Begin of protos/perfetto/metrics/android/android_boot.proto

// This metric computes how much time processes spend in UNINTERRUPTIBLE_SLEEP
// state
message ProcessStateDurations {
  optional int64 total_dur = 2;
  optional int64 uninterruptible_sleep_dur = 3;
}

message AndroidBootMetric {
  optional ProcessStateDurations system_server_durations = 1;
  optional ProcessStateDurations systemui_durations = 2;
  optional ProcessStateDurations launcher_durations = 3;
  optional ProcessStateDurations gms_durations = 4;
  // Launcher related boot metrics
  message LauncherBreakdown {
    //  reports cold start time of NexusLauncher
    optional int64 cold_start_dur = 1;
  }
  optional LauncherBreakdown launcher_breakdown = 5;

  message ProcessStartAggregation {
    optional int64 total_start_sum = 1;
    optional int64 num_of_processes = 2;
    optional double average_start_time = 3;
  }
  message GarbageCollectionAggregation {
    optional int64 total_gc_count = 1;
    optional int64 num_of_processes_with_gc = 2;
    optional int64 num_of_threads_with_gc = 3;
    optional double avg_gc_duration = 4;
    optional double avg_running_gc_duration = 5;
    optional int64 full_gc_count = 6;
    optional int64 collector_transition_gc_count = 7;
    optional int64 young_gc_count = 8;
    optional int64 native_alloc_gc_count = 9;
    optional int64 explicit_gc_count = 10;
    optional int64 alloc_gc_count = 11;
    optional double mb_per_ms_of_gc = 12;
  }
  message OomAdjusterTransitionCounts {
    // name of the item aggregated by. example: process_name,
    // oom_adjuster_reason.
    optional string name = 1;
    // name of previous oom bucket.
    optional string src_bucket = 2;
    // name of oom bucket.
    optional string dest_bucket = 3;
    // count of transitions
    optional int64 count = 4;
  }
  message OomAdjBucketDurationAggregation {
    // name of the item aggregated by. example: process_name,
    // oom_adjuster_reason
    optional string name = 1;
    // name of oom bucket.
    optional string bucket = 2;
    // Duration of the time in the bucket
    optional int64 total_dur = 3;
  }
  message OomAdjDurationAggregation {
    optional int64 min_oom_adj_dur = 1;
    optional int64 max_oom_adj_dur = 2;
    optional double avg_oom_adj_dur = 3;
    optional int64 oom_adj_event_count = 4;
    optional string oom_adj_reason = 5;
  }
  message BroadcastCountAggregation {
    optional string name = 1;
    optional int64 count = 2;
  }
  // Stats for Broadcasts aggregated with duration.
  message BroadcastDurationAggregation {
    optional string name = 1;
    optional double avg_duration = 2;
    optional int64 max_duration = 3;
    optional int64 sum_duration = 4;
  }
  optional ProcessStartAggregation full_trace_process_start_aggregation = 6;
  optional ProcessStartAggregation post_boot_process_start_aggregation = 7;
  optional GarbageCollectionAggregation full_trace_gc_aggregation = 8;
  optional GarbageCollectionAggregation post_boot_gc_aggregation = 9;
  repeated OomAdjusterTransitionCounts
      post_boot_oom_adjuster_transition_counts_global = 10;
  repeated OomAdjusterTransitionCounts
      post_boot_oom_adjuster_transition_counts_by_process = 11;
  repeated OomAdjusterTransitionCounts
      post_boot_oom_adjuster_transition_counts_by_oom_adj_reason = 12;
  repeated OomAdjBucketDurationAggregation
      post_boot_oom_adj_bucket_duration_agg_global = 13;
  repeated OomAdjBucketDurationAggregation
      post_boot_oom_adj_bucket_duration_agg_by_process = 14;
  repeated OomAdjDurationAggregation post_boot_oom_adj_duration_agg = 15;
  repeated BroadcastCountAggregation
      post_boot_broadcast_process_count_by_intent = 16;
  repeated BroadcastCountAggregation post_boot_broadcast_count_by_process = 17;
  repeated BroadcastDurationAggregation
      post_boot_brodcast_duration_agg_by_intent = 18;
  repeated BroadcastDurationAggregation
      post_boot_brodcast_duration_agg_by_process = 19;
}

// End of protos/perfetto/metrics/android/android_boot.proto

// Begin of protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto

message AndroidGarbageCollectionUnaggMetric {
  message GarbageCollectionEvent {
    // Name of thread running garbage collection.
    optional string thread_name = 1;
    // Name of process running garbage collection.
    optional string process_name = 2;
    // Type of garbage collection.
    optional string gc_type = 3;
    // Whether gargage collection is mark compact or copying.
    optional int64 is_mark_compact = 4;
    // MB reclaimed after garbage collection.
    optional double reclaimed_mb = 5;
    // Minimum heap size in MB during garbage collection.
    optional double min_heap_mb = 6;
    // Maximum heap size in MB during garbage collection.
    optional double max_heap_mb = 7;
    // Memory reclaimed per ms of running time.
    optional double mb_per_ms_of_running_gc = 8;
    // Memory reclaimed per ms of wall time.
    optional double mb_per_ms_of_wall_gc = 9;
    // Garbage collection wall duration.
    optional int64 gc_dur = 10;
    // Garbage collection duration spent executing on CPU.
    optional int64 gc_running_dur = 11;
    // Garbage collection duration spent waiting for CPU.
    optional int64 gc_runnable_dur = 12;
    // Garbage collection duration spent waiting in the Linux kernel on IO.
    optional int64 gc_unint_io_dur = 13;
    // Garbage collection duration spent waiting in the Linux kernel without IO.
    optional int64 gc_unint_non_io_dur = 14;
    // Garbage collection duration spent waiting in interruptible sleep.
    optional int64 gc_int_dur = 15;
    // ts of the event in trace.
    optional int64 gc_ts = 16;
    // pid of the event in trace.
    optional int64 pid = 17;
    // tid of the event in trace.
    optional int64 tid = 18;
    // monotonic duration of event.
    optional int64 gc_monotonic_dur = 19;
    // Details about the process (uid, version, etc)
    optional AndroidProcessMetadata process = 20;
    // The number of GCs in this event. Namely 1.
    optional int64 gc_count = 21;
  }
  repeated GarbageCollectionEvent gc_events = 1;
}

// End of protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto

// Begin of protos/perfetto/metrics/android/app_process_starts_metric.proto

message AndroidAppProcessStartsMetric {
  // Next id : 4
  message ProcessStart {
    optional string process_name = 1;
    optional string intent = 2;
    optional string reason = 3;
    optional int64 proc_start_dur = 4;
    optional int64 bind_app_dur = 5;
    optional int64 intent_dur = 6;
    optional int64 total_dur = 7;
  }
  // Provides java process startup information for
  // all processes starting after Boot completed broadcast in a trace.
  repeated ProcessStart all_apps = 1;
  // Provides java process startup information for all
  // processes started from a broadcast after Boot Complete broadcasts.
  repeated ProcessStart started_by_broadcast = 2;
  // Provides java process startup information for all
  // processes started from a service after Boot Complete broadcasts.
  repeated ProcessStart started_by_service = 3;
}

// End of protos/perfetto/metrics/android/app_process_starts_metric.proto

// Begin of protos/perfetto/metrics/android/android_boot_unagg.proto

message AndroidBootUnagg {
  // Looks at all apps started after boot complete broadcast.
  optional AndroidAppProcessStartsMetric android_app_process_start_metric = 1;
  // Looks at all GC that occurs after boot complete broadcast.
  optional AndroidGarbageCollectionUnaggMetric android_post_boot_gc_metric = 2;
}

// End of protos/perfetto/metrics/android/android_boot_unagg.proto

// Begin of protos/perfetto/metrics/android/android_broadcasts_metric.proto

// Provides aggregated information about broadcasts
message AndroidBroadcastsMetric {
  // Next id: 5
  // Stats for Broadcasts aggregated with count.
  message BroadcastCountAggregation {
    optional string name = 1;
    optional int64 count = 2;
  }
  // Stats for Broadcasts aggregated with duration.
  message BroadcastDurationAggregation {
    optional string name = 1;
    optional double avg_duration = 2;
    optional int64 max_duration = 3;
    optional int64 sum_duration = 4;
  }
  repeated BroadcastCountAggregation process_count_by_intent = 1;
  repeated BroadcastCountAggregation broadcast_count_by_process = 2;
  repeated BroadcastDurationAggregation brodcast_duration_agg_by_intent = 3;
  repeated BroadcastDurationAggregation brodcast_duration_agg_by_process = 4;
}

// End of protos/perfetto/metrics/android/android_broadcasts_metric.proto

// Begin of protos/perfetto/metrics/android/android_frame_timeline_metric.proto

message AndroidFrameTimelineMetric {
  message JankTypeMetric {
    // The jank type
    optional string type = 1;

    // The count of frames with this jank type
    optional int64 total_count = 2;

    // The count of frames with this jank type and present type =
    // PRESENT_UNSPECIFIED
    optional int64 present_unspecified_count = 3;

    // The count of frames with this jank type and present type =
    // PRESENT_ON_TIME
    optional int64 present_on_time_count = 4;

    // The count of frames with this jank type and present type = PRESENT_LATE
    optional int64 present_late_count = 5;

    // The count of frames with this jank type and present type = PRESENT_EARLY
    optional int64 present_early_count = 6;

    // The count of frames with this jank type and present type =
    // PRESENT_DROPPED
    optional int64 present_dropped_count = 7;

    // The count of frames with this jank type and present type =
    // PRESENT_UNKNOWN
    optional int64 present_unknown_count = 8;
  }

  message ProcessBreakdown {
    optional AndroidProcessMetadata process = 3;

    optional int64 total_frames = 4;
    optional int64 missed_frames = 5;
    optional int64 missed_app_frames = 6;
    optional int64 missed_sf_frames = 7;
    optional double weighted_missed_frames = 22;
    optional double weighted_missed_app_frames = 20;
    optional double weighted_missed_sf_frames = 21;

    optional int64 frame_dur_max = 8;
    optional int64 frame_dur_avg = 9;
    optional int64 frame_dur_p50 = 10;
    optional int64 frame_dur_p90 = 11;
    optional int64 frame_dur_p95 = 12;
    optional int64 frame_dur_p99 = 13;
    optional double frame_dur_ms_p50 = 14;
    optional double frame_dur_ms_p90 = 15;
    optional double frame_dur_ms_p95 = 16;
    optional double frame_dur_ms_p99 = 17;
    optional int64 dropped_frames = 18;

    // Metrics for each jank type in this process
    repeated JankTypeMetric jank_types = 19;

    reserved 1, 2;
  }

  optional int64 total_frames = 4;
  optional int64 missed_app_frames = 5;
  optional int64 dropped_frames = 6;

  repeated ProcessBreakdown process = 2;

  // Metrics for each jank type globally
  repeated JankTypeMetric jank_types = 7;

  reserved 1;
}

// End of protos/perfetto/metrics/android/android_frame_timeline_metric.proto

// Begin of protos/perfetto/metrics/android/android_garbage_collection_stats.proto

message AndroidGarbageCollectionStats {
  message ProcessStats {
    // The process the stats are associated with.
    optional AndroidProcessMetadata process = 1;
    // Megabyte-seconds of heap size across the device, used in the calculation
    // of heap_size_mb.
    optional double heap_size_mbs = 2;
    // Total size of heap allocations across the device on average, in MB.
    optional double heap_size_mb = 3;
    // Total number of bytes allocated over the course of the trace.
    optional double heap_allocated_mb = 4;
    // Overall rate of heap allocations in MB per second. This gives a sense of
    // how much allocation activity is going on during the trace.
    optional double heap_allocation_rate = 5;
    // Megabyte-seconds of live heap for processes that had GC events.
    optional double heap_live_mbs = 6;
    // Megabyte-seconds of total heap for processes that had GC events.
    optional double heap_total_mbs = 7;
    // Overall heap utilization. This gives a sense of how aggressive GC is
    // during this trace.
    optional double heap_utilization = 8;
    // CPU time spent running GC. Used in the calculation of gc_running_rate.
    optional int64 gc_running_dur = 9;
    // CPU time spent running GC, as a fraction of the duration of the trace.
    // This gives a sense of the battery cost of GC.
    optional double gc_running_rate = 10;
    // A measure of how efficient GC is with respect to cpu, independent of how
    // aggressively GC is tuned. Larger values indicate more efficient GC, so
    // larger is better.
    optional double gc_running_efficiency = 11;
    // Time GC is running during app startup. Used in the calculation of
    // gc_during_android_startup_rate.
    optional int64 gc_during_android_startup_dur = 12;
    // Time GC is running during app startup, as a fraction of startup time in
    // the trace. This gives a sense of how much potential interference there
    // is between GC and application startup.
    optional double gc_during_android_startup_rate = 13;
    // A measure of how efficient GC is with regards to gc during application
    // startup, independent of how aggressively GC is tuned. Larger values
    // indicate more efficient GC, so larger is better.
    optional double gc_during_android_startup_efficiency = 14;
  }

  // The start of the window of time that the stats cover in the trace.
  optional int64 ts = 1;
  // The duration of the window of time that the stats cover in the trace.
  optional int64 dur = 2;
  // Megabyte-seconds of heap size across the device, used in the calculation
  // of heap_size_mb.
  optional double heap_size_mbs = 3;
  // Total size of heap allocations across the device on average, in MB.
  optional double heap_size_mb = 4;
  // Total number of bytes allocated over the course of the trace.
  optional double heap_allocated_mb = 5;
  // Overall rate of heap allocations in MB per second. This gives a sense of
  // how much allocation activity is going on during the trace.
  optional double heap_allocation_rate = 6;
  // Megabyte-seconds of live heap for processes that had GC events.
  optional double heap_live_mbs = 7;
  // Megabyte-seconds of total heap for processes that had GC events.
  optional double heap_total_mbs = 8;
  // Overall heap utilization. This gives a sense of how aggressive GC is
  // during this trace.
  optional double heap_utilization = 9;
  // CPU time spent running GC. Used in the calculation of gc_running_rate.
  optional int64 gc_running_dur = 10;
  // CPU time spent running GC, as a fraction of the duration of the trace.
  // This gives a sense of the battery cost of GC.
  optional double gc_running_rate = 11;
  // A measure of how efficient GC is with respect to cpu, independent of how
  // aggressively GC is tuned. Larger values indicate more efficient GC, so
  // larger is better.
  optional double gc_running_efficiency = 12;
  // Time GC is running during app startup. Used in the calculation of
  // gc_during_android_startup_rate.
  optional int64 gc_during_android_startup_dur = 13;
  // Total startup time in the trace, used to normalize the
  // gc_during_android_startup_rate.
  optional int64 total_android_startup_dur = 14;
  // Time GC is running during app startup, as a fraction of startup time in
  // the trace. This gives a sense of how much potential interference there
  // is between GC and application startup.
  optional double gc_during_android_startup_rate = 15;
  // A measure of how efficient GC is with regards to gc during application
  // startup, independent of how aggressively GC is tuned. Larger values
  // indicate more efficient GC, so larger is better.
  optional double gc_during_android_startup_efficiency = 16;
  // Per-process stats.
  repeated ProcessStats processes = 17;
}

// End of protos/perfetto/metrics/android/android_garbage_collection_stats.proto

// Begin of protos/perfetto/metrics/android/android_oom_adjuster_metric.proto

message AndroidOomAdjusterMetric {
  message OomAdjusterTransitionCounts {
    // name of the item aggregated by. example: process_name,
    // oom_adjuster_reason.
    optional string name = 1;
    // name of previous oom bucket.
    optional string src_bucket = 2;
    // name of oom bucket.
    optional string dest_bucket = 3;
    // count of transitions
    optional int64 count = 4;
  }
  message OomAdjBucketDurationAggregation {
    // name of the item aggregated by. example: process_name,
    // oom_adjuster_reason
    optional string name = 1;
    // name of oom bucket.
    optional string bucket = 2;
    // Duration of the time in the bucket
    optional int64 total_dur = 3;
  }
  message OomAdjDurationAggregation {
    optional int64 min_oom_adj_dur = 1;
    optional int64 max_oom_adj_dur = 2;
    optional double avg_oom_adj_dur = 3;
    optional int64 oom_adj_event_count = 4;
    optional string oom_adj_reason = 5;
  }
  repeated OomAdjusterTransitionCounts oom_adjuster_transition_counts_global =
      1;
  repeated OomAdjusterTransitionCounts
      oom_adjuster_transition_counts_by_process = 2;
  repeated OomAdjusterTransitionCounts
      oom_adjuster_transition_counts_by_oom_adj_reason = 3;
  repeated OomAdjBucketDurationAggregation oom_adj_bucket_duration_agg_global =
      4;
  repeated OomAdjBucketDurationAggregation
      oom_adj_bucket_duration_agg_by_process = 5;
  repeated OomAdjDurationAggregation oom_adj_duration_agg = 6;
}
// End of protos/perfetto/metrics/android/android_oom_adjuster_metric.proto

// Begin of protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto

// Blocking calls inside System UI Notifications. Shows count and total duration
// for each.
message AndroidSysUINotificationsBlockingCallsMetric {
  repeated AndroidBlockingCall blocking_calls = 1;
}

// End of protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto

// Begin of protos/perfetto/metrics/android/anr_metric.proto

message AndroidAnrMetric {
  repeated Anr anr = 1;

  // Next id: 12
  message Anr {
    // UUID that identifies the ANR.
    optional string error_id = 1;

    // Name of the process that ANRed.
    optional string process_name = 2;

    // PID of the ANRing process.
    optional int32 pid = 3;

    // ANR subject line.
    optional string subject = 4;

    // Timestamp of the ANR in the trace.
    optional int64 ts = 5;
  }
}
// End of protos/perfetto/metrics/android/anr_metric.proto

// Begin of protos/perfetto/metrics/android/auto_metric.proto

// Metrics for Multiuser events, such as switching users.
message AndroidAutoMultiuserMetric {
  message EventData {
    // Id of the user the system has been switched to
    optional int32 user_id = 1;

    // The end event name for which the duration_ms is measured
    optional string start_event = 2;

    // The end event name for which the duration_ms is measured
    optional string end_event = 3;

    // Duration of the event (in milliseconds).
    optional int64 duration_ms = 4;

    // Previous user resource usage info during user switch
    message UserData {
      // Id of the user the system has been switched from
      optional int32 user_id = 1;

      optional int64 total_cpu_time_ms = 2;

      optional int64 total_memory_usage_kb = 3;
    }

    optional UserData previous_user_info = 5;
  }

  // Metrics for a user switch.
  repeated EventData user_switch = 1;
}

// End of protos/perfetto/metrics/android/auto_metric.proto

// Begin of protos/perfetto/metrics/android/batt_metric.proto

message AndroidBatteryMetric {
  message BatteryCounters {
    // Timestamp measured from boot time [ns].
    optional int64 timestamp_ns = 1;
    // Fields 2-5 are the same as in BatteryCounters proto in TracePacket.
    optional double charge_counter_uah = 2;
    optional float capacity_percent = 3;
    optional double current_ua = 4;
    optional double current_avg_ua = 5;
    optional double voltage_uv = 6;
  }

  message BatteryAggregates {
    // Field numbers for these 3 == the int values from Android
    optional int64 total_screen_off_ns = 1;
    optional int64 total_screen_on_ns = 2;
    optional int64 total_screen_doze_ns = 3;
    // Total time a wakelock was held
    optional int64 total_wakelock_ns = 4;
    // Amount of time the device was suspended. Depends on the ftrace source
    // "power/suspend_resume".
    optional int64 sleep_ns = 5;
    optional int64 sleep_screen_off_ns = 6;
    optional int64 sleep_screen_on_ns = 7;
    optional int64 sleep_screen_doze_ns = 8;
    // Average power over the duration of the trace.
    optional double avg_power_mw = 9;
    // Average power from charge difference at the start and end of the trace.
    optional double avg_power_from_charge_diff_mw = 10;
  }

  // Period of time during the trace that the device went to sleep completely.
  message SuspendPeriod {
    optional int64 timestamp_ns = 1;
    optional int64 duration_ns = 2;
  }

  // Battery counters info for each ts of the trace. This should only be
  // extracted for short traces.
  repeated BatteryCounters battery_counters = 1;

  optional BatteryAggregates battery_aggregates = 2;

  repeated SuspendPeriod suspend_period = 3;
}

// End of protos/perfetto/metrics/android/batt_metric.proto

// Begin of protos/perfetto/metrics/android/binder_metric.proto

// This metric provides the following:
// 1. Per-process Binder statistics for traces with binder_driver enabled.
//    Specifically, transactions are categorized and counted
// 2. Unaggregated binder txn durations with per-txn aggregated thread state and
// blocked function
//    durations
message AndroidBinderMetric {
  message PerProcessBreakdown {
    optional string process_name = 1;
    optional uint32 pid = 2;
    optional string slice_name = 3;
    optional uint32 count = 4;
  }

  // Next field id: 31
  message UnaggregatedTxnBreakdown {
    // General
    optional string aidl_name = 1;
    optional int64 aidl_ts = 22;
    optional int64 aidl_dur = 23;
    optional bool is_sync = 21;
    // Client
    // Removed: was binder_txn_id
    reserved 2;
    optional string client_process = 3;
    optional string client_thread = 4;
    optional bool is_main_thread = 5;
    optional int64 client_ts = 6;
    optional int64 client_dur = 7;
    optional int64 client_monotonic_dur = 28;
    optional int64 client_oom_score = 19;
    optional int64 client_package_version_code = 24;
    optional bool is_client_package_debuggable = 25;
    // Server
    // Removed: was binder_reply_id
    reserved 8;
    optional string server_process = 9;
    optional string server_thread = 10;
    optional int64 server_ts = 11;
    optional int64 server_dur = 12;
    optional int64 server_monotonic_dur = 29;
    optional int64 server_oom_score = 20;
    optional int64 server_package_version_code = 26;
    optional bool is_server_package_debuggable = 27;
    // Aggregations
    repeated ThreadStateBreakdown thread_states = 13;
    repeated BlockedFunctionBreakdown blocked_functions = 14;
    repeated LogicalReasonBreakdown logical_reasons = 31;

    optional uint32 client_tid = 15;
    optional uint32 server_tid = 16;

    optional uint32 client_pid = 17;
    optional uint32 server_pid = 18;
  }

  message ThreadStateBreakdown {
    optional string thread_state_type = 1;
    optional string thread_state = 2;
    optional int64 thread_state_dur = 3;
    optional int64 thread_state_count = 4;
  }

  message BlockedFunctionBreakdown {
    optional string thread_state_type = 1;
    optional string blocked_function = 2;
    optional int64 blocked_function_dur = 3;
    optional int64 blocked_function_count = 4;
  }

  message LogicalReasonBreakdown {
    optional string thread_state_type = 1;
    optional string reason = 2;
    optional int64 reason_dur = 3;
  }

  repeated PerProcessBreakdown process_breakdown = 1;
  repeated UnaggregatedTxnBreakdown unaggregated_txn_breakdown = 2;
}

// End of protos/perfetto/metrics/android/binder_metric.proto

// Begin of protos/perfetto/metrics/android/camera_metric.proto

message AndroidCameraMetric {
  message Counter {
    optional double min = 1;
    optional double max = 2;
    optional double avg = 3;
  }

  // Counter for the sum of DMA and RSS across GCA, cameraserver
  // and HAL. This provides a single number for the memory
  // pressure using the camera is putting on the rest of the
  // system.
  //
  // Note: this number assumes that all DMA pressure is coming
  // from the camera as this is usually a pretty good
  // approximation. Being more accurate here would increase the
  // complexity of the metric significantly.
  //
  // Note: if there are multiple GCA/cameraserver/HAL processes
  // in the trace, this metric will simply take the latest
  // one in the trace and ignore the others.
  optional Counter gc_rss_and_dma = 1;
}

// End of protos/perfetto/metrics/android/camera_metric.proto

// Begin of protos/perfetto/metrics/android/camera_unagg_metric.proto

message AndroidCameraUnaggregatedMetric {
  message Value {
    optional int64 ts = 1;
    optional double gca_rss_val = 2;
    optional double hal_rss_val = 3;
    optional double cameraserver_rss_val = 4;
    optional double dma_val = 5;
    optional double value = 6;
  }

  // Timeseries for the sum of DMA and RSS across GCA, cameraserver
  // and HAL. This provides a single number for the memory
  // pressure using the camera is putting on the rest of the
  // system.
  //
  // Note: this number assumes that all DMA pressure is coming
  // from the camera as this is usually a pretty good
  // approximation. Being more accurate here would increase the
  // complexity of the metric significantly.
  //
  // Note: if there are multiple GCA/cameraserver/HAL processes
  // in the trace, this metric will simply take the latest
  // one in the trace and ignore the others.
  repeated Value gc_rss_and_dma = 1;
}

// End of protos/perfetto/metrics/android/camera_unagg_metric.proto

// Begin of protos/perfetto/metrics/android/cpu_metric.proto

message AndroidCpuMetric {
  // Next id: 6
  message Metrics {
    // CPU megacycles (i.e. cycles divided by 1e6).
    optional int64 mcycles = 1;

    // Total time the thread was running for this breakdown in
    // nanoseconds.
    optional int64 runtime_ns = 2;

    // Min/max/average CPU frequency weighted by the time the CPU was
    // running at each frequency in this breakdown.
    optional int64 min_freq_khz = 3;
    optional int64 max_freq_khz = 4;
    optional int64 avg_freq_khz = 5;
  }

  // Next id: 7
  message CoreData {
    optional uint32 id = 1;
    optional Metrics metrics = 6;

    reserved 2 to 5;
  }

  // Next id: 3
  message CoreTypeData {
    optional string type = 1;
    optional Metrics metrics = 2;
  }

  // Next id: 7
  message Thread {
    optional string name = 1;
    optional Metrics metrics = 4;

    // Breakdowns of above metrics.
    repeated CoreData core = 2;
    repeated CoreTypeData core_type = 5;

    reserved 3;
  }

  // Next id: 8
  message Process {
    optional string name = 1;
    optional AndroidProcessMetadata process = 8;
    optional Metrics metrics = 4;

    // Breakdowns of above metrics.
    repeated Thread threads = 6;
    repeated CoreData core = 7;
    repeated CoreTypeData core_type = 5;

    reserved 3;
  }

  repeated Process process_info = 1;
}

// End of protos/perfetto/metrics/android/cpu_metric.proto

// Begin of protos/perfetto/metrics/android/codec_metrics.proto

// These metrices collects various function and thread
// usage within androd's codec framework. This can give an
// idea about performance and cpu usage when using codec
// framework
message AndroidCodecMetrics {
  // profile details in messages
  message Detail {
    // was thread_name
    reserved 1;
    // total time
    optional int64 total_cpu_ns = 2;
    // CPU time ( time 'Running' on cpu)
    optional int64 running_cpu_ns = 3;
    // avg running time for the trace duration
    optional int64 avg_running_cpu_ns = 9;
    // Total CPU cycles
    optional int64 total_cpu_cycles = 4;
    // avg CPU cycles per call
    optional int64 avg_cpu_cycles = 8;
    // avg time for this slice type
    optional int64 avg_time_ns = 5;
    optional int32 count = 6;
    message Latency {
      optional int64 max_us = 1;
      optional int64 min_us = 2;
      optional int64 avg_us = 3;
      optional int64 agg_us = 4;
      optional uint32 count = 5;
    }
    optional Latency self = 7;
  }

  // These are traces and could indicate framework queue latency
  // buffer-packing, buffer-preprocess, buffer post-process
  // latency etc. These metrics are monitored to track quality.
  // Same message can come from different
  // processes.
  message CodecFunction {
    // codec string
    optional string codec_string = 1;
    message Process {
      optional string name = 1;
      message Thread {
        optional string name = 1;
        optional Detail detail = 2;
      }
      optional Thread thread = 2;
    }
    optional Process process = 2;
  }

  // This message can indicate overall cpu
  // utilization of codec framework threads.
  message CpuUsage {
    // name of process using codec framework
    optional string process_name = 1;
    message ThreadInfo {
      // name of the codec thread
      optional string name = 1;
      message Details {
        // total cpu usage of the codec thread
        optional int64 thread_cpu_ns = 1;
        // can be number of codec framework thread
        optional uint32 num_threads = 2;
        // core type data info used by codec thread
        repeated AndroidCpuMetric.CoreTypeData core_data = 3;
      }
      optional Details info = 2;
    }
    optional ThreadInfo thread = 2;
    // was thread_cpu_us
    reserved 3;
  }

  // Rail details
  message Rail {
    // name of rail
    optional string name = 1;
    // energy and power details of this rail
    message Info {
      // energy from this rail for codec use
      optional double energy = 1;
      // power consumption in this rail for codec use
      optional double power_mw = 2;
    }
    optional Info info = 2;
  }

  // have the energy usage for the codec running time
  message Energy {
    // total energy taken by the system during this time
    optional double total_energy = 1;
    // total time for this energy is calculated
    optional int64 duration = 2;
    //  for this session
    optional double power_mw = 3;
    // enery breakdown by subsystem
    repeated Rail rail = 4;
  }

  repeated CpuUsage cpu_usage = 1;
  repeated CodecFunction codec_function = 2;
  optional Energy energy = 3;
}

// End of protos/perfetto/metrics/android/codec_metrics.proto

// Begin of protos/perfetto/metrics/android/display_metrics.proto

message AndroidDisplayMetrics {
  // Stat that reports the number of duplicate frames submitted
  // to the display for rendering. That is frames that have the same
  // pixels values but where still submitted. It is tracked based on
  // comparing the MISR of the current frame vs previous frame.
  optional uint32 total_duplicate_frames = 1;

  // Stat reports whether there is any duplicate_frames tracked
  optional uint32 duplicate_frames_logged = 2;

  // Stat that reports the number of dpu underrrun occurs count.
  // Deprecated as of 04/2025
  optional uint32 total_dpu_underrun_count = 3 [deprecated = true];

  message RefreshRateStat {
    // The refresh rate value (the number of frames per second)
    optional uint32 refresh_rate_fps = 1;

    // Calculate the number of refresh rate switches to this fps
    optional uint32 count = 2;

    // Calculate the total duration of refresh rate stays at this fps
    optional double total_dur_ms = 3;

    // Calculate the average duration of refresh rate stays at this fps
    optional double avg_dur_ms = 4;
  }

  // Calculate the total number of refresh rate changes
  optional uint32 refresh_rate_switches = 4;

  // The statistics for each refresh rate value
  repeated RefreshRateStat refresh_rate_stats = 5;

  // Stats to measure the runtime of updating the power state in
  // DisplayPowerController
  message UpdatePowerState {
    optional uint32 avg_runtime_micro_secs = 2;

    // Removed: avg_runtime_ms
    reserved 1;
  }

  optional UpdatePowerState update_power_state = 6;

  message DpuUnderrunDetail {
    // display_id
    optional string name = 1;

    // The number of dpu underrun occurs.
    optional uint32 dpu_underrun_count = 2;
  }

  message DpuState {
    // Stat that reports the number of dpu underrrun occurs count.
    optional uint32 total_dpu_underrun_count = 1;

    // Dpu underun count for differnt display_id.
    repeated DpuUnderrunDetail dpu_underrun_detail = 2;
  }

  optional DpuState dpu_state = 7;

  message DdicUnderrunDetail {
    // panel index
    optional string name = 1;

    // The number of dpu underrun occurs.
    optional uint32 ddic_underrun_count = 2;
  }

  message PanelState {
    // Stat that reports the number of dpu underrrun occurs count.
    optional uint32 total_ddic_underrun_count = 1;

    repeated DdicUnderrunDetail ddic_underrun_detail = 2;
  }

  optional PanelState panel_state = 8;
}

// End of protos/perfetto/metrics/android/display_metrics.proto

// Begin of protos/perfetto/metrics/android/dma_heap_metric.proto

// dma-buf heap memory stats on Android.
message AndroidDmaHeapMetric {
  message ProcessStats {
    // process that either directly or indirectly allocated the buffers
    optional string process_name = 1;
    // Bytes allocated but not freed during this trace
    optional int32 delta_bytes = 2;
  }

  optional double avg_size_bytes = 1;
  optional double min_size_bytes = 2;
  optional double max_size_bytes = 3;

  // Total allocation size.
  // Essentially the sum of positive allocs.
  optional double total_alloc_size_bytes = 4;

  // Total delta size (bytes allocated but not freed during the trace)
  optional int32 total_delta_bytes = 5;
  repeated ProcessStats process_stats = 6;
}

// End of protos/perfetto/metrics/android/dma_heap_metric.proto

// Begin of protos/perfetto/metrics/android/dvfs_metric.proto

message AndroidDvfsMetric {
  message BandStat {
    // Operating frequency
    optional int32 freq_value = 1;

    // Percentage of duration in this operating frequency compared to all
    // frequencies
    optional double percentage = 2;

    // Total duration in ns when the state was in this operating frequency
    optional int64 duration_ns = 3;
  }

  message FrequencyResidency {
    // Frequency representative name
    optional string freq_name = 1;
    // Each band statistics meta
    repeated BandStat band_stat = 2;
  }

  // Frequency residency metrics from clock_set_rate ftrace event.
  repeated FrequencyResidency freq_residencies = 1;
}

// End of protos/perfetto/metrics/android/dvfs_metric.proto

// Begin of protos/perfetto/metrics/android/fastrpc_metric.proto

// fastrpc memory stats on Android.
message AndroidFastrpcMetric {
  message Subsystem {
    optional string name = 1;
    optional double avg_size_bytes = 2;
    optional double min_size_bytes = 3;
    optional double max_size_bytes = 4;

    // Total allocation size.
    // Essentially the sum of positive allocs.
    optional double total_alloc_size_bytes = 5;
  }

  repeated Subsystem subsystem = 1;
}

// End of protos/perfetto/metrics/android/fastrpc_metric.proto

// Begin of protos/perfetto/metrics/android/g2d_metric.proto

message G2dMetrics {
  message G2dInstance {
    // G2d name.
    optional string name = 1;

    optional uint32 frame_count = 5;
    optional uint32 error_count = 6;

    optional double max_dur_ms = 7;
    optional double min_dur_ms = 8;
    optional double avg_dur_ms = 9;

    // Removed: was int64 versions of max_dur_ns, min_dur_ns and avg_dur_ns.
    reserved 2 to 4;
  }
  message G2dMetric {
    // G2D Metric for each G2D Instance.
    repeated G2dInstance instances = 1;

    // the number of frames processed by G2D
    optional uint32 frame_count = 5;
    // the number of error events
    optional uint32 error_count = 6;

    // max/min/avg G2d frame durations for all instances.
    optional double max_dur_ms = 7;
    optional double min_dur_ms = 8;
    optional double avg_dur_ms = 9;

    // Removed: was int64 versions of max_dur_ns, min_dur_ns and avg_dur_ns.
    reserved 2 to 4;
  }

  optional G2dMetric g2d_hw = 1;
  optional G2dMetric g2d_sw = 2;
}

// End of protos/perfetto/metrics/android/g2d_metric.proto

// Begin of protos/perfetto/metrics/android/gpu_metric.proto

message AndroidGpuMetric {
  message Process {
    // Process name.
    optional string name = 1;

    // max/min/avg GPU memory used by this process.
    optional int64 mem_max = 2;
    optional int64 mem_min = 3;
    optional int64 mem_avg = 4;
  }

  // GPU metric for processes using GPU.
  repeated Process processes = 1;

  // max/min/avg GPU memory used by the entire system.
  optional int64 mem_max = 2;
  optional int64 mem_min = 3;
  optional int64 mem_avg = 4;

  message FrequencyMetric {
    // Identifier for GPU in a multi-gpu device.
    optional uint32 gpu_id = 1;

    // max/min/avg GPU frequency for this gpu_id
    // the calculation of avg is weighted by the duration of each frequency
    optional int64 freq_max = 2;
    optional int64 freq_min = 3;
    optional double freq_avg = 4;

    message MetricsPerFrequency {
      // Used frequency
      optional int64 freq = 1;

      // Total duration in ms when the state of GPU was in this frequency
      optional double dur_ms = 2;

      // Percentage of duration in this frequency compared to all frequencies
      // in this gpu_id
      optional double percentage = 3;
    }

    // Metrics for each used GPU frequency
    repeated MetricsPerFrequency used_freqs = 5;
  }

  // GPU frequency metric for each gpu_id
  repeated FrequencyMetric freq_metrics = 5;
}

// End of protos/perfetto/metrics/android/gpu_metric.proto

// Begin of protos/perfetto/metrics/android/hwcomposer.proto

message AndroidHwcomposerMetrics {
  // Counts the number of composition total layers in the trace. (non-weighted
  // average)
  optional double composition_total_layers = 1;

  // Counts the number of composition dpu layers in the trace. (non-weighted
  // average)
  optional double composition_dpu_layers = 2;

  // Counts the number of composition gpu layers in the trace. (non-weighted
  // average)
  optional double composition_gpu_layers = 3;

  // Counts the number of composition dpu cached layers in the trace.
  // (non-weighted average)
  optional double composition_dpu_cached_layers = 4;

  // Counts the number of composition surfaceflinger cached layers in the trace.
  // (non-weighted average)
  optional double composition_sf_cached_layers = 5;

  // Counts the number of composition rounded corner decoration layers in the
  // trace. (non-weighted average)
  optional double composition_rcd_layers = 15;

  // Counts how many times validateDisplay is skipped.
  optional int32 skipped_validation_count = 6;

  // Counts how many times validateDisplay cannot be skipped.
  optional int32 unskipped_validation_count = 7;

  // Counts how many times validateDisplay is already separated from
  // presentDisplay since the beginning.
  optional int32 separated_validation_count = 8;

  // Counts how many unhandled validation cases which might be caused by errors.
  optional int32 unknown_validation_count = 9;

  // the average of overall hwcomposer execution time.
  optional double avg_all_execution_time_ms = 10;

  // the average of hwcomposer execution time for skipped validation cases.
  optional double avg_skipped_execution_time_ms = 11;

  // the average of hwcomposer execution time for unskipped validation cases.
  optional double avg_unskipped_execution_time_ms = 12;

  // the average of hwcomposer execution time for separated validation cases.
  optional double avg_separated_execution_time_ms = 13;

  message DpuVoteMetrics {
    // the thread ID that handles this track
    optional uint32 tid = 1;

    // the weighted average of DPU Vote Clock
    optional double avg_dpu_vote_clock = 2;

    // the weighted average of DPU Vote Avg Bandwidth
    optional double avg_dpu_vote_avg_bw = 3;

    // the weighted average of DPU Vote Peak Bandwidth
    optional double avg_dpu_vote_peak_bw = 4;

    // the weighted average of DPU Vote RT (Real Time) Bandwidth
    optional double avg_dpu_vote_rt_bw = 5;
  }

  // DPU Vote Metrics for each thread track
  repeated DpuVoteMetrics dpu_vote_metrics = 14;

  message MetricsPerDisplay {
    // Display ID in HWC
    optional string display_id = 1;

    // Counts the number of composition total layers in the trace. (non-weighted
    // average)
    optional double composition_total_layers = 2;

    // Counts the number of composition dpu layers in the trace. (non-weighted
    // average)
    optional double composition_dpu_layers = 3;

    // Counts the number of composition gpu layers in the trace. (non-weighted
    // average)
    optional double composition_gpu_layers = 4;

    // Counts the number of composition dpu cached layers in the trace.
    // (non-weighted average)
    optional double composition_dpu_cached_layers = 5;

    // Counts the number of composition surfaceflinger cached layers in the
    // trace. (non-weighted average)
    optional double composition_sf_cached_layers = 6;

    // Counts the number of composition rounded corner decoration layers in the
    // trace. (non-weighted average)
    optional double composition_rcd_layers = 7;

    // Counts how many times validateDisplay is skipped.
    optional int32 skipped_validation_count = 8;

    // Counts how many times validateDisplay cannot be skipped.
    optional int32 unskipped_validation_count = 9;

    // Counts how many times validateDisplay is already separated from
    // presentDisplay since the beginning.
    optional int32 separated_validation_count = 10;

    // Counts how many unhandled validation cases which might be caused by
    // errors.
    optional int32 unknown_validation_count = 11;

    // the average of overall hwcomposer execution time.
    optional double avg_all_execution_time_ms = 12;

    // the average of hwcomposer execution time for skipped validation cases.
    optional double avg_skipped_execution_time_ms = 13;

    // the average of hwcomposer execution time for unskipped validation cases.
    optional double avg_unskipped_execution_time_ms = 14;

    // the average of hwcomposer execution time for separated validation cases.
    optional double avg_separated_execution_time_ms = 15;
  }

  repeated MetricsPerDisplay metrics_per_display = 16;
}

// End of protos/perfetto/metrics/android/hwcomposer.proto

// Begin of protos/perfetto/metrics/android/hwui_metric.proto

// Android HWUI graphics performance and graphics memory usage metrics.
message ProcessRenderInfo {
  // Name of the package launched
  optional string process_name = 1;

  // CPU time spent on RenderThread in milliseconds.
  optional int64 rt_cpu_time_ms = 2;

  // Number of frames drawn on RenderThread, followed by max/min/avg CPU time to
  // draw a frame in nanoseconds.
  optional uint32 draw_frame_count = 3;
  optional int64 draw_frame_max = 4;
  optional int64 draw_frame_min = 5;
  optional double draw_frame_avg = 6;

  // Number of GPU commands flushes and max/min/avg time per flush in
  // nanoseconds.
  optional uint32 flush_count = 7;
  optional int64 flush_max = 8;
  optional int64 flush_min = 9;
  optional double flush_avg = 10;

  // Number of View tree preparation counts and max/min/avg time to traverse the
  // tree in nanoseconds.
  optional uint32 prepare_tree_count = 11;
  optional int64 prepare_tree_max = 12;
  optional int64 prepare_tree_min = 13;
  optional double prepare_tree_avg = 14;

  // Number of times the GPU rendered a frame and max/min/avg time for GPU to
  // finish rendering in in nanoseconds.
  optional uint32 gpu_completion_count = 15;
  optional int64 gpu_completion_max = 16;
  optional int64 gpu_completion_min = 17;
  optional double gpu_completion_avg = 18;

  // Number of times a frame was recorded/serialized in a display list on the UI
  // thread with max/min/avg time in nanoseconds.
  optional uint32 ui_record_count = 19;
  optional int64 ui_record_max = 20;
  optional int64 ui_record_min = 21;
  optional double ui_record_avg = 22;

  // number of unique shader programs that were used to render frames, followed
  // by total and average times to prepare a shader in nanoseconds.
  optional uint32 shader_compile_count = 23;
  optional int64 shader_compile_time = 24;
  optional double shader_compile_avg = 25;
  // number of shader programs loaded from the disk cache, followed by total
  // time and average time to prepare a shader in nanoseconds.
  optional uint32 cache_hit_count = 26;
  optional int64 cache_hit_time = 27;
  optional double cache_hit_avg = 28;
  // number of shader programs compiled/linked, followed by total time and
  // average time to prepare a shader in nanoseconds.
  optional uint32 cache_miss_count = 29;
  optional int64 cache_miss_time = 30;
  optional double cache_miss_avg = 31;

  // max/min/avg CPU memory used for graphics by HWUI at the end of a frame.
  optional int64 graphics_cpu_mem_max = 32;
  optional int64 graphics_cpu_mem_min = 33;
  optional double graphics_cpu_mem_avg = 34;

  // max/min/avg GPU memory used by HWUI at the end of a frame excluding
  // textures.
  optional int64 graphics_gpu_mem_max = 35;
  optional int64 graphics_gpu_mem_min = 36;
  optional double graphics_gpu_mem_avg = 37;

  // max/min/avg memory used for GPU textures by HWUI at the end of a frame.
  optional int64 texture_mem_max = 38;
  optional int64 texture_mem_min = 39;
  optional double texture_mem_avg = 40;

  // max/min/avg memory used by HWUI at the end of a frame. This is a sum of
  // previous 3 categories.
  optional int64 all_mem_max = 41;
  optional int64 all_mem_min = 42;
  optional double all_mem_avg = 43;
}

message AndroidHwuiMetric {
  //  HWUI metrics for processes that have a RenderThread.
  repeated ProcessRenderInfo process_info = 1;
}

// End of protos/perfetto/metrics/android/hwui_metric.proto

// Begin of protos/perfetto/metrics/android/io_metric.proto

// Measure Android IO stats in a trace.
// Note: This is an aggregated metric, for unaggregated metrics look at
// AndroidIoUnaggregated in io_unagg_metric.proto.
message AndroidIo {
  // Next id: 3
  // Stats for Counters in an f2fs file system.
  // Counters are available for various operations.
  message F2fsCounterStats {
    optional string name = 1;
    optional double max = 2;
    optional double sum = 3;
    optional double min = 5;
    optional int64 dur = 6;
    optional int64 count = 7;
    optional double avg = 8;
  }
  // Aggregated stats for write operations in an f2fs file system.
  message F2fsWriteStats {
    optional int64 total_write_count = 1;
    optional int64 distinct_processes = 2;
    optional int64 total_bytes_written = 3;
    optional int64 distinct_device_count = 4;
    optional int64 distinct_inode_count = 5;
    optional int64 distinct_thread_count = 6;
  }
  repeated F2fsCounterStats f2fs_counter_stats = 1;
  repeated F2fsWriteStats f2fs_write_stats = 2;
}

// End of protos/perfetto/metrics/android/io_metric.proto

// Begin of protos/perfetto/metrics/android/io_unagg_metric.proto

// IO metrics on Android in unaggregated form.
// Note: this generates a lot of data so should not be requested unless it
// is clear that this data is necessary.
message AndroidIoUnaggregated {
  // Next id: 2
  message F2fsWriteUnaggreagatedStat {
    optional uint32 tid = 1;
    optional string thread_name = 2;
    optional uint32 pid = 3;
    optional string process_name = 4;
    optional int64 ino = 5;
    optional int64 dev = 6;
  }
  // F2fs write stats which are grouped by thread and inode.
  repeated F2fsWriteUnaggreagatedStat f2fs_write_unaggregated_stats = 1;
}
// End of protos/perfetto/metrics/android/io_unagg_metric.proto

// Begin of protos/perfetto/metrics/android/ion_metric.proto

// ion memory stats on Android.
message AndroidIonMetric {
  message Buffer {
    optional string name = 1;
    optional double avg_size_bytes = 2;
    optional double min_size_bytes = 3;
    optional double max_size_bytes = 4;

    // Total allocation size.
    // Essentially the sum of positive allocs (-> new buffers).
    optional double total_alloc_size_bytes = 5;
  }

  repeated Buffer buffer = 1;
}

// End of protos/perfetto/metrics/android/ion_metric.proto

// Begin of protos/perfetto/metrics/android/irq_runtime_metric.proto

// measure max IRQ runtime and IRQ tasks running over threshold.
message AndroidIrqRuntimeMetric {
  message IrqSlice {
    // IRQ name
    optional string irq_name = 1;
    // timestamp
    optional int64 ts = 2;
    // runtime of IRQ task
    optional int64 dur = 3;
  }
  message ThresholdMetric {
    // Threshold value
    optional string threshold = 1;
    // over threshold count
    optional int64 over_threshold_count = 2;
    // anomaly ratio (over threshold count / total count)
    optional double anomaly_ratio = 3;
  }
  message IrqRuntimeMetric {
    // max runtime of IRQ tasks
    optional int64 max_runtime = 1;
    // total IRQ tasks
    optional int64 total_count = 2;
    // over threshold metric
    optional ThresholdMetric threshold_metric = 3;
    // information for top 10 IRQ tasks
    repeated IrqSlice longest_irq_slices = 4;
  }

  // metrics for hardirq and softirq
  optional IrqRuntimeMetric hw_irq = 1;
  optional IrqRuntimeMetric sw_irq = 2;
}

// End of protos/perfetto/metrics/android/irq_runtime_metric.proto

// Begin of protos/perfetto/metrics/android/jank_cuj_metric.proto

message AndroidJankCujMetric {
  repeated Cuj cuj = 1;

  // Next id: 12
  message Cuj {
    // ID of the CUJ that is unique within the trace.
    optional int32 id = 1;

    // Name of the CUJ, extracted from the CUJ trace marker.
    // For example SHADE_EXPAND_COLLAPSE from J<SHADE_EXPAND_COLLAPSE>.
    optional string name = 2;

    // Details about the process (uid, version, etc)
    optional AndroidProcessMetadata process = 3;

    // ts of the CUJ trace marker slice.
    optional int64 ts = 4;

    // dur of the CUJ trace marker slice.
    optional int64 dur = 5;

    // Details about each of the frames within the CUJ.
    repeated Frame frame = 6;

    // Details about each of the SF frames within the CUJ.
    repeated Frame sf_frame = 10;

    // Metrics extracted from the counters output by FrameTracker
    // Does not contain the frame_dur percentile information.
    optional Metrics counter_metrics = 7;

    // Metrics extracted from the frame timeline.
    optional Metrics timeline_metrics = 8;

    // Metrics extracted from the trace slices.
    optional Metrics trace_metrics = 9;

    // Layer name of the surface where the cuj is drawn.
    optional string layer_name = 11;
  }

  // Next id: 11
  message Frame {
    // Index of the frame within the single user journey.
    optional int64 frame_number = 1;

    // VSYNC ID of the frame.
    optional int64 vsync = 2;

    optional int64 ts = 3;
    optional int64 dur = 4;
    optional int64 dur_expected = 7;

    // Whether the app process missed the frame deadline.
    // Only set for the App frames. Always left unset for SF frames.
    optional bool app_missed = 5;

    // Whether SF missed the frame deadline.
    optional bool sf_missed = 6;

    // Jank severity weight score for janky frames.
    optional double jank_score = 10;

    // Whether the SF callback missed before emitting jank metrics.
    // SF callback is used to get the jank classification.
    optional bool sf_callback_missed = 8;

    // Whether the HWUI callback missed before emitting jank metrics.
    // HWUI callback is used to get the frame duration.
    optional bool hwui_callback_missed = 9;
  }

  // Next id: 22
  message Metrics {
    // Overall number of frames within the CUJ.
    optional int64 total_frames = 1;

    // Number of missed frames.
    optional int64 missed_frames = 2;

    // Number of frames missed due to the app missing the deadline.
    optional int64 missed_app_frames = 3;

    // Number of frames missed due to SF.
    optional int64 missed_sf_frames = 4;

    // Weighted number of missed frames.
    optional double weighted_missed_frames = 21;

    // Weighted number of frames missed due to the app missing the deadline.
    optional double weighted_missed_app_frames = 19;

    // Weighted number of frames missed due to SF.
    optional double weighted_missed_sf_frames = 20;

    // Number of successive frames missed.
    // Not available in timeline_metrics and trace_metrics.
    optional int64 missed_frames_max_successive = 5;

    // Max frame duration in nanoseconds.
    optional int64 frame_dur_max = 6;

    // Duration in ns of the animation.
    optional int64 anim_duration = 18;

    // Average frame duration in nanoseconds.
    // Not available in counter_metrics.
    optional int64 frame_dur_avg = 7;

    // Median frame duration in nanoseconds.
    // Not available in counter_metrics.
    optional int64 frame_dur_p50 = 8;

    // P90 frame duration in nanoseconds.
    // Not available in counter_metrics.
    optional int64 frame_dur_p90 = 9;

    // P95 frame duration in nanoseconds.
    // Not available in counter_metrics.
    optional int64 frame_dur_p95 = 10;

    // P99 frame duration in nanoseconds.
    // Not available in counter_metrics.
    optional int64 frame_dur_p99 = 11;

    // Median frame duration in milliseconds.
    // Not available in counter_metrics.
    optional double frame_dur_ms_p50 = 12;

    // P90 frame duration in milliseconds.
    // Not available in counter_metrics.
    optional double frame_dur_ms_p90 = 13;

    // P95 frame duration in milliseconds.
    // Not available in counter_metrics.
    optional double frame_dur_ms_p95 = 14;

    // P99 frame duration in milliseconds.
    // Not available in counter_metrics.
    optional double frame_dur_ms_p99 = 15;

    // Number of frames with missed SF callback.
    optional int64 sf_callback_missed_frames = 16;

    // Number of frames with missed HWUI callback.
    optional int64 hwui_callback_missed_frames = 17;
  }
}

// End of protos/perfetto/metrics/android/jank_cuj_metric.proto

// Begin of protos/perfetto/metrics/android/java_heap_class_stats.proto

message JavaHeapClassStats {
  // Next id: 13
  message TypeCount {
    reserved 11;
    optional string type_name = 1;
    optional bool is_libcore_or_array = 12;

    optional int64 obj_count = 2;
    optional int64 size_bytes = 3;
    optional int64 native_size_bytes = 4;
    optional int64 reachable_obj_count = 5;
    optional int64 reachable_size_bytes = 6;
    optional int64 reachable_native_size_bytes = 7;
    optional int64 dominated_obj_count = 8;
    optional int64 dominated_size_bytes = 9;
    optional int64 dominated_native_size_bytes = 10;
  }

  message Sample {
    optional int64 ts = 1;
    repeated TypeCount type_count = 2;
  }

  // Stats per process. One sample per dump (with continuous dump you can
  // have more samples differentiated by ts).
  message InstanceStats {
    optional uint32 upid = 1;
    optional perfetto.protos.AndroidProcessMetadata process = 2;
    repeated Sample samples = 3;
  }

  repeated InstanceStats instance_stats = 1;
}

// End of protos/perfetto/metrics/android/java_heap_class_stats.proto

// Begin of protos/perfetto/metrics/android/java_heap_histogram.proto

message JavaHeapHistogram {
  // Next id: 9
  message TypeCount {
    optional string type_name = 1;
    optional string category = 4;

    optional uint32 obj_count = 2;
    optional uint32 reachable_obj_count = 3;

    optional uint32 size_kb = 5;
    optional uint32 reachable_size_kb = 6;
    optional uint32 native_size_kb = 7;
    optional uint32 reachable_native_size_kb = 8;
  }

  message Sample {
    optional int64 ts = 1;
    repeated TypeCount type_count = 2;
  }

  // Heap stats per process. One sample per dump (with continuous dump you can
  // have more samples differentiated by ts).
  message InstanceStats {
    optional uint32 upid = 1;
    optional AndroidProcessMetadata process = 2;
    repeated Sample samples = 3;
  }

  repeated InstanceStats instance_stats = 1;
}

// End of protos/perfetto/metrics/android/java_heap_histogram.proto

// Begin of protos/perfetto/metrics/android/java_heap_stats.proto

message JavaHeapStats {
  // Was repeated HeapRoots roots = 7;
  reserved 7;

  // Next id: 13
  message Sample {
    optional int64 ts = 1;
    // Size of the Java heap in bytes
    optional int64 heap_size = 2;
    // Native size of all the objects (not included in heap_size)
    optional int64 heap_native_size = 8;
    optional int64 obj_count = 4;
    // Size of the reachable objects in bytes.
    optional int64 reachable_heap_size = 3;
    // Native size of all the reachable objects (not included in
    // reachable_heap_size)
    optional int64 reachable_heap_native_size = 9;
    optional int64 reachable_obj_count = 5;
    // Sum of anonymous RSS + swap pages in bytes.
    optional int64 anon_rss_and_swap_size = 6;
    optional int64 dmabuf_rss_size = 12;

    // OOM adjustment score
    optional int64 oom_score_adj = 10;
    // Process uptime in millis at the time of the heap dump
    optional int64 process_uptime_ms = 11;
  }

  // Heap stats per process. One sample per dump (can be > 1 if continuous
  // dump is enabled).
  message InstanceStats {
    optional uint32 upid = 1;
    optional AndroidProcessMetadata process = 2;
    repeated Sample samples = 3;
  }

  repeated InstanceStats instance_stats = 1;
}

// End of protos/perfetto/metrics/android/java_heap_stats.proto

// Begin of protos/perfetto/metrics/android/lmk_metric.proto

// LMK stats on Android.
message AndroidLmkMetric {
  message ByOomScore {
    optional int32 oom_score_adj = 1;
    optional int32 count = 2;
  }

  // Total count of LMK events observed in the trace.
  optional int32 total_count = 1;
  repeated ByOomScore by_oom_score = 2;

  // OOM reaper kills. Enabled via the oom/mark_victim point. Should never
  // happen.
  optional int32 oom_victim_count = 3;
}

// End of protos/perfetto/metrics/android/lmk_metric.proto

// Begin of protos/perfetto/metrics/android/lmk_reason_metric.proto

// Global process state at LMK time, used to identify potential culprits.
// TODO: rename to AndroidLmkProcessState
message AndroidLmkReasonMetric {
  message Process {
    optional AndroidProcessMetadata process = 1;

    // OOM score adj of the process.
    optional int32 oom_score_adj = 2;

    // RSS + swap.
    optional int64 size = 3;

    optional int64 file_rss_bytes = 4;
    optional int64 anon_rss_bytes = 5;
    optional int64 shmem_rss_bytes = 6;
    optional int64 swap_bytes = 7;
  }
  message Lmk {
    // OOM score adj of the LMK'ed process.
    optional int32 oom_score_adj = 1;

    // Total size of the ION heap in bytes during this LMK.
    optional int64 ion_heaps_bytes = 4;
    // Deprecated. Prefer ion_heaps_bytes.
    optional int64 system_ion_heap_size = 2;

    // Processes present during this LMK.
    repeated Process processes = 3;
  }

  // LMKs present in the trace, ordered on their timestamp.
  repeated Lmk lmks = 1;
}

// End of protos/perfetto/metrics/android/lmk_reason_metric.proto

// Begin of protos/perfetto/metrics/android/mem_metric.proto

// Memory metrics on Android.
message AndroidMemoryMetric {
  message ProcessMetrics {
    optional string process_name = 1;
    optional ProcessMemoryCounters total_counters = 2;
    repeated PriorityBreakdown priority_breakdown = 3;
  }

  message PriorityBreakdown {
    optional string priority = 1;
    optional ProcessMemoryCounters counters = 2;
  }

  message ProcessMemoryCounters {
    optional Counter anon_rss = 1;
    optional Counter file_rss = 2;
    optional Counter swap = 3;
    optional Counter anon_and_swap = 4;

    // Available when ART trace events are available.
    optional Counter java_heap = 5;
  }

  message Counter {
    optional double min = 1;
    optional double max = 2;
    optional double avg = 3;

    // Memory growth observed in the counter sequence. In case of multiple
    // processes with the same name, break ties using max.
    optional double delta = 4;
  }

  // Process metrics, grouped by process name
  repeated ProcessMetrics process_metrics = 1;
}

// End of protos/perfetto/metrics/android/mem_metric.proto

// Begin of protos/perfetto/metrics/android/mem_unagg_metric.proto

// Unaggregated memory metrics on Android.
message AndroidMemoryUnaggregatedMetric {
  message ProcessValues {
    optional string process_name = 1;
    optional ProcessMemoryValues mem_values = 2;
  }

  message ProcessMemoryValues {
    repeated Value anon_rss = 1;
    repeated Value file_rss = 2;
    repeated Value swap = 3;
    repeated Value anon_and_swap = 4;
  }

  message Value {
    optional int64 ts = 1;
    optional int32 oom_score = 2;
    optional double value = 3;
  }

  // Process metrics for every process instance in trace.
  repeated ProcessValues process_values = 1;
}

// End of protos/perfetto/metrics/android/mem_unagg_metric.proto

// Begin of protos/perfetto/metrics/android/monitor_contention_agg_metric.proto

// This metric provides aggregated information about monitor contention graph
// in a trace
message AndroidMonitorContentionAggMetric {
  // Next id: 2
  // Stats for Monitor contention aggregated by process.
  message ProcessAggregation {
    optional string name = 1;
    optional int64 total_contention_count = 2;
    optional int64 total_contention_dur = 3;
    optional int64 main_thread_contention_count = 4;
    optional int64 main_thread_contention_dur = 5;
  }
  repeated ProcessAggregation process_aggregation = 1;
}

// End of protos/perfetto/metrics/android/monitor_contention_agg_metric.proto

// Begin of protos/perfetto/metrics/android/monitor_contention_metric.proto

// This metric provides information about the monitor contention graph in a
// trace
message AndroidMonitorContentionMetric {
  // Next field id: 26
  message Node {
    // Global context
    optional int64 node_parent_id = 1;
    optional int64 node_child_id = 24;
    optional int64 node_id = 2;
    optional int64 ts = 3;
    optional int64 dur = 4;
    optional int64 monotonic_dur = 25;
    optional string process_name = 14;
    optional uint32 pid = 23;
    optional uint32 waiter_count = 11;
    repeated ThreadStateBreakdown thread_states = 19;
    repeated BlockedFunctionBreakdown blocked_functions = 20;

    // Blocking context
    optional string blocking_method = 5;
    optional string short_blocking_method = 7;
    optional string blocking_src = 9;
    optional string blocking_thread_name = 13;
    optional bool is_blocking_thread_main = 16;
    optional uint32 blocking_thread_tid = 22;

    // Blocked context
    optional string blocked_method = 6;
    optional string short_blocked_method = 8;
    optional string blocked_src = 10;
    optional string blocked_thread_name = 12;
    optional bool is_blocked_thread_main = 15;
    optional uint32 blocked_thread_tid = 21;

    // Binder context
    optional int64 binder_reply_ts = 17;
    optional uint32 binder_reply_tid = 18;
  }

  message ThreadStateBreakdown {
    optional string thread_state = 1;
    optional int64 thread_state_dur = 2;
    optional int64 thread_state_count = 3;
  }

  message BlockedFunctionBreakdown {
    optional string blocked_function = 1;
    optional int64 blocked_function_dur = 2;
    optional int64 blocked_function_count = 3;
  }

  repeated Node node = 1;
}

// End of protos/perfetto/metrics/android/monitor_contention_metric.proto

// Begin of protos/perfetto/metrics/android/multiuser_metric.proto

// Metrics for Multiuser events, such as switching users.
message AndroidMultiuserMetric {
  // Holds the data for a Multiuser event.
  message EventData {
    // Duration of the event (in milliseconds).
    optional int32 duration_ms = 1;

    // CPU usage of each process during the event.
    message CpuUsage {
      // The userId of the process (e.g. 0 or 10).
      optional int32 user_id = 1;
      // The name of the process.
      optional string process_name = 2;
      // The number of CPU cycles (in megacycles) spent by that process during
      // the event.
      optional int32 cpu_mcycles = 3;
      // The ratio of this process's cycles to the total for all processes,
      // expressed as a percentage.
      optional float cpu_percentage = 4;
      // General identifier for this usage source: determined from the process
      // name, user, etc. Should be stable across multiple runs (i.e. does not
      // print the user_id directly).
      optional string identifier = 5;
    }
    repeated CpuUsage cpu_usage = 2;
  }

  // Metrics for a user switch.
  optional EventData user_switch = 1;
}
// End of protos/perfetto/metrics/android/multiuser_metric.proto

// Begin of protos/perfetto/metrics/android/network_metric.proto

message AndroidNetworkMetric {
  message PacketStatistic {
    // Packet count.
    optional int64 packets = 1;

    // Packet Bytes.
    optional int64 bytes = 2;

    // Timestamp when first packet received or transmitted.
    optional int64 first_packet_timestamp_ns = 3;

    // Timestamp when last packet received or transmitted.
    optional int64 last_packet_timestamp_ns = 4;

    // Interval between first & last packet. The minimum interval is 10ms.
    optional int64 interval_ns = 5;

    // Data Speed.
    optional double data_rate_kbps = 6;
  }

  message CorePacketStatistic {
    optional uint32 id = 1;
    optional PacketStatistic packet_statistic = 2;
  }

  message Rx {
    // Total packets statistic.
    optional PacketStatistic total = 1;

    // Per core packets statistic.
    repeated CorePacketStatistic core = 2;

    // GRO aggregation ratio.
    optional string gro_aggregation_ratio = 3;
  }

  message Tx {
    // Total packets statistic.
    optional PacketStatistic total = 1;

    // Per core packets statistic.
    repeated CorePacketStatistic core = 2;
  }

  message NetDevice {
    // Network device name.
    optional string name = 1;

    // Ingress traffic statistic.
    optional Rx rx = 2;

    // Egress traffic statistic
    optional Tx tx = 3;
  }

  message NetRxActionStatistic {
    // SoftIrq NET_RX action count.
    optional int64 count = 1;

    // SoftIrq NET_RX action was running in millisecond.
    optional double runtime_ms = 2;

    // SoftIrq NET_RX action average running time.
    optional double avg_runtime_ms = 3;

    // CPU megacycles (i.e. cycles divided by 1e6).
    optional int64 mcycles = 4;

    // Average weighted CPU frequency by the time the NET_RX Action
    // running at each frequency.
    optional int64 avg_freq_khz = 5;
  }

  message NetTxActionStatistic {
    // SoftIrq NET_TX action count.
    optional int64 count = 1;

    // SoftIrq NET_TX action was running in millisecond.
    optional double runtime_ms = 2;

    // SoftIrq NET_TX action average running time.
    optional double avg_runtime_ms = 3;

    // CPU megacycles (i.e. cycles divided by 1e6).
    optional int64 mcycles = 4;

    // Average weighted CPU frequency by the time the NET_TX Action
    // running at each frequency.
    optional int64 avg_freq_khz = 5;
  }

  message IpiActionStatistic {
    // SoftIrq IPI action count.
    optional int64 count = 1;

    // SoftIrq IPI action was running in millisecond.
    optional double runtime_ms = 2;

    // SoftIrq IPI action average running time.
    optional double avg_runtime_ms = 3;
  }

  message CoreNetRxActionStatistic {
    optional uint32 id = 1;
    optional NetRxActionStatistic net_rx_action_statistic = 2;
  }

  message CoreNetTxActionStatistic {
    optional uint32 id = 1;
    optional NetTxActionStatistic net_tx_action_statistic = 2;
  }

  message NetRxAction {
    // Total NET_RX action statistics.
    optional NetRxActionStatistic total = 1;

    // Per core NET_RX action statistics.
    repeated CoreNetRxActionStatistic core = 2;

    // The average packet time moves through the kernel stack.
    optional double avg_interstack_latency_ms = 3;
  }

  message NetTxAction {
    // Total NET_TX action statistics.
    optional NetTxActionStatistic total = 1;

    // Per core NET_TX action statistics.
    repeated CoreNetTxActionStatistic core = 2;
  }

  message IpiAction {
    // Total IPI action statistics.
    optional IpiActionStatistic total = 1;
  }

  // Network device metrics.
  repeated NetDevice net_devices = 1;

  // SoftIrq NET_RX action metrics.
  optional NetRxAction net_rx_action = 2;

  // Packet retransmission rate.
  optional double retransmission_rate = 3;

  // Kfree Skb rate (i.e. kfree_skb count divided by the packet count from all
  // net devices).
  optional double kfree_skb_rate = 4;

  // SoftIrq NET_TX action metrics.
  optional NetTxAction net_tx_action = 5;

  // SoftIrq IPI action metrics.
  optional IpiAction ipi_action = 6;
}

// End of protos/perfetto/metrics/android/network_metric.proto

// Begin of protos/perfetto/metrics/android/package_list.proto

message AndroidPackageList {
  message Package {
    optional string package_name = 1;
    optional int64 uid = 2;
    optional int64 version_code = 3;
  }

  repeated Package packages = 1;
}

// End of protos/perfetto/metrics/android/package_list.proto

// Begin of protos/perfetto/metrics/android/powrails_metric.proto

message AndroidPowerRails {
  // Energy data per Power Rail at given ts.
  message EnergyData {
    // Time since device boot(CLOCK_BOTTOMTIME) in milli-seconds.
    optional int64 timestamp_ms = 1;
    // Accumulated energy since device boot in microwatt-seconds(uws).
    optional double energy_uws = 2;
  }

  message PowerRails {
    // Name of the rail.
    optional string name = 1;
    // Energy data for given rail and for all samples in the trace.
    repeated EnergyData energy_data = 2;
    // The average used power between the first and the last sampled
    // energy data in miliwatt (mw)
    optional double avg_used_power_mw = 3;
  }

  // Energy data per Power Rail.
  repeated PowerRails power_rails = 1;

  // The average used power between the first and last sampled rail across all
  // the rails in milliwatts (mw).
  optional double avg_total_used_power_mw = 2;
}
// End of protos/perfetto/metrics/android/powrails_metric.proto

// Begin of protos/perfetto/metrics/android/profiler_smaps.proto

message ProfilerSmaps {
  message Mapping {
    optional string path = 1;
    optional int32 size_kb = 2;
    optional int32 private_dirty_kb = 3;
    optional int32 swap_kb = 4;
  }

  message Instance {
    optional AndroidProcessMetadata process = 1;
    repeated Mapping mappings = 2;
  }

  repeated Instance instance = 1;
}

// End of protos/perfetto/metrics/android/profiler_smaps.proto

// Begin of protos/perfetto/metrics/android/rt_runtime_metric.proto

// measure max RT runtime and RT tasks running over 5ms.
message AndroidRtRuntimeMetric {
  message RtSlice {
    // thread name
    optional string tname = 1;
    // timestamp
    optional int64 ts = 2;
    // runtime of RT task
    optional int64 dur = 3;
  }

  // max runtime of RT tasks
  optional int64 max_runtime = 1;
  // how many RT tasks are over 5ms.
  optional int64 over_5ms_count = 2;
  // information for top 10 RT tasks
  repeated RtSlice longest_rt_slices = 3;
}

// End of protos/perfetto/metrics/android/rt_runtime_metric.proto

// Begin of protos/perfetto/metrics/android/simpleperf.proto

// Metric that stores information related to atrace events generated by
// simpleperf tool
message AndroidSimpleperfMetric {
  optional double urgent_ratio = 1;

  message PerfEventMetric {
    // Simpleperf event name
    optional string name = 1;

    message Thread {
      // Thread ID
      optional int32 tid = 1;
      // Thread name
      optional string name = 2;
      // CPU ID
      optional int32 cpu = 3;
      // Total counter value
      optional double total = 4;
    }

    message Process {
      // Process ID
      optional int32 pid = 1;
      // Process name
      optional string name = 2;
      // Metrics for each thread in this process.
      repeated Thread threads = 3;
      // Total counter value over all threads in this process
      optional double total = 4;
    }

    // Metrics for each process
    repeated Process processes = 2;

    // Total counter value over all processes and threads
    optional double total = 3;
  }

  repeated PerfEventMetric events = 2;
}

// End of protos/perfetto/metrics/android/simpleperf.proto

// Begin of protos/perfetto/metrics/android/startup_metric.proto

// Android app startup metrics.
message AndroidStartupMetric {
  // A simplified view of the task state durations for a thread
  // and a span of time.
  message TaskStateBreakdown {
    optional int64 running_dur_ns = 1;
    optional int64 runnable_dur_ns = 2;
    optional int64 uninterruptible_sleep_dur_ns = 3;
    optional int64 interruptible_sleep_dur_ns = 4;
    optional int64 uninterruptible_io_sleep_dur_ns = 5;
    optional int64 uninterruptible_non_io_sleep_dur_ns = 6;
  }

  message McyclesByCoreType {
    optional int64 little = 1;
    optional int64 big = 2;
    optional int64 bigger = 3;
    optional int64 unknown = 4;
  }

  message Slice {
    optional int64 dur_ns = 1;
    optional double dur_ms = 2;
  }

  // Timing information spanning the intent received by the
  // activity manager to the first frame drawn.
  // Next id: 38
  message ToFirstFrame {
    // The duration between the intent received and first frame.
    optional int64 dur_ns = 1;
    optional double dur_ms = 17;

    // Breakdown of time to first frame by task state for the main thread of
    // the process starting up.
    optional TaskStateBreakdown main_thread_by_task_state = 2;

    // The mcycles taken by this startup across all CPUs (broken down by core
    // type).
    optional McyclesByCoreType mcycles_by_core_type = 26;

    // In this timespan, how many processes (apart from the main activity) were
    // spawned.
    optional uint32 other_processes_spawned_count = 3;

    // Total time spent in activity manager between the initial intent
    // and the end of the activity starter.
    optional Slice time_activity_manager = 4;

    // The following slices follow the typical steps post-fork.
    optional Slice time_activity_thread_main = 5;
    optional Slice time_bind_application = 6;
    optional Slice time_activity_start = 7;
    optional Slice time_activity_resume = 8;
    optional Slice time_activity_restart = 21;
    optional Slice time_choreographer = 9;
    optional Slice time_inflate = 22;
    optional Slice time_get_resources = 23;

    // If we are starting a new process, record the duration from the
    // intent being received to the time we call the zygote.
    optional Slice time_before_start_process = 10;

    // The actual duration of the process start (based on the zygote slice).
    optional Slice time_during_start_process = 11;

    // The duration from launch to first running state thread of startup
    // process.
    optional Slice time_to_running_state = 35;

    optional Slice to_post_fork = 18;
    optional Slice to_activity_thread_main = 19;
    optional Slice to_bind_application = 20;

    optional Slice time_post_fork = 16;

    // Total time on class initialization during app startup.
    optional Slice time_class_initialization = 36;
    // The total time spent on opening dex files.
    optional Slice time_dex_open = 24;
    // Total time spent verifying classes during app startup.
    optional Slice time_verify_class = 25;

    // Number of methods that were compiled by JIT during app startup.
    optional uint32 jit_compiled_methods = 27;

    // Number of class initializations during app startup.
    optional uint32 class_initialization_count = 37;

    // Time spent running CPU on jit thread pool.
    optional Slice time_jit_thread_pool_on_cpu = 28;

    // Time spent on garbage collection.
    optional Slice time_gc_total = 29;
    optional Slice time_gc_on_cpu = 30;

    // Time spent in lock contention on the main thread of the process being
    // started up. This includes *all* types of lock contention not just monitor
    // contention.
    optional Slice time_lock_contention_thread_main = 31;

    // Time spent in monitor lock contention on the main thread of the
    // process being started up. This will be a subset of the time counted by
    // |time_lock_contention_thread_main|.
    optional Slice time_monitor_contention_thread_main = 32;

    // Time spent in opening dex files on the main thread of the process
    // being started up.
    optional Slice time_dex_open_thread_main = 33;

    // Time spent in dlopening .so files on the main thread of the process
    // being started up.
    optional Slice time_dlopen_thread_main = 34;

    // Removed: was other_process_to_activity_cpu_ratio.
    reserved 12;

    // Removed: was uint32 versions of to_post_fork, to_activity_thread_main and
    // to_bind_application.
    reserved 13, 14, 15;
  }

  // Metrics about startup which were developed by looking at experiments using
  // high-speed cameras (HSC).
  message HscMetrics {
    // The duration of the full "startup" as defined by HSC tests.
    optional Slice full_startup = 1;
  }

  message Activity {
    optional string name = 1;
    optional string method = 2;
    optional int64 ts_method_start = 4;

    // Field 3 contained Slice with a sum of durations for matching slices.
    reserved 3;
  }

  message BinderTransaction {
    optional Slice duration = 1;
    optional string thread = 2;
    optional string destination_thread = 3;
    optional string destination_process = 4;
    // From
    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=15;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
    optional string flags = 5;
    // From
    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=14;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
    optional string code = 6;
    // From
    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=37;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
    optional int64 data_size = 7;
  }

  // Metrics with information about the status of odex files and the outcome
  // of the loading process.
  // Multiple files might be loaded for a single startup. Platform might also
  // decide to discard an odex file and instead load a fallback, for example
  // in case the OS or apk were updated.
  message OptimizationStatus {
    optional string odex_status = 1;
    optional string compilation_filter = 2;
    optional string compilation_reason = 3;
    optional string location = 4;
    optional string summary = 5;
  }

  // Contains the name and duration of class verification occurred during
  // the startup.
  message VerifyClass {
    optional string name = 1;
    optional int64 dur_ns = 2;
  }

  // Contains timestamps of important events which occurred during the
  // startup.
  message EventTimestamps {
    optional int64 intent_received = 1;
    optional int64 first_frame = 2;
  }

  // Contains information about the state of a system during the app startup.
  // Useful to put the startup in context.
  message SystemState {
    // Whether the dex2oat64 process was running concurrent to the startup.
    // Deprecated as of 10/2022.
    optional bool dex2oat_running = 1 [deprecated = true];

    // Whether the installd process was running concurrent to the startup.
    // Deprecated as of 10/2022.
    optional bool installd_running = 2 [deprecated = true];

    // The number of broadcasts dispatched by the system during the app
    // launch.
    optional int64 broadcast_dispatched_count = 3;

    // The number of broadcasts received by an app or the system during the
    // app launch. Note that multiple packages can be subscribed to the same
    // broadcast so a single dsipatch can cause multiple packages to receive
    // and process a broadcast.
    optional int64 broadcast_received_count = 4;

    // The most active (i.e. consuming the most mcycles) processes during the
    // app launch excluding the process(es) being launched.
    // Note: the exact number of returned is an implementation detail and
    // will likely change over time.
    repeated string most_active_non_launch_processes = 5;

    // Duration the installd process was running concurrent to the startup.
    optional int64 installd_dur_ns = 6;
    // Duration the dex2oat64 process was running concurrent to the startup.
    optional int64 dex2oat_dur_ns = 7;
  }

  // Contains detailed information for slow startup causes.
  message SlowStartReasonDetailed {
    optional string reason = 1;
    optional string details = 2;
  }

  // Contains information for slow startup causes.
  // Next id: 11.
  message SlowStartReason {
    // Points to reason description and solution.
    enum ReasonId {
      REASON_ID_UNSPECIFIED = 0;
      NO_BASELINE_OR_CLOUD_PROFILES = 1;
      RUN_FROM_APK = 2;
      UNLOCK_RUNNING = 3;
      APP_IN_DEBUGGABLE_MODE = 4;
      GC_ACTIVITY = 5;
      DEX2OAT_RUNNING = 6;
      INSTALLD_RUNNING = 7;
      MAIN_THREAD_TIME_SPENT_IN_RUNNABLE = 8;
      MAIN_THREAD_TIME_SPENT_IN_INTERRUPTIBLE_SLEEP = 9;
      MAIN_THREAD_TIME_SPENT_IN_BLOCKING_IO = 10;
      MAIN_THREAD_TIME_SPENT_IN_OPEN_DEX_FILES_FROM_OAT = 11;
      TIME_SPENT_IN_BIND_APPLICATION = 12;
      TIME_SPENT_IN_VIEW_INFLATION = 13;
      TIME_SPENT_IN_RESOURCES_MANAGER_GET_RESOURCES = 14;
      TIME_SPENT_VERIFYING_CLASSES = 15;
      POTENTIAL_CPU_CONTENTION_WITH_ANOTHER_PROCESS = 16;
      JIT_ACTIVITY = 17;
      MAIN_THREAD_LOCK_CONTENTION = 18;
      MAIN_THREAD_MONITOR_CONTENTION = 19;
      JIT_COMPILED_METHODS = 20;
      BROADCAST_DISPATCHED_COUNT = 21;
      BROADCAST_RECEIVED_COUNT = 22;
      STARTUP_RUNNING_CONCURRENT = 23;
      MAIN_THREAD_BINDER_TRANSCATIONS_BLOCKED = 24;
    }
    optional ReasonId reason_id = 1;

    // Brief description for human readability.
    optional string reason = 2;

    // Severity level for a reason.
    enum SeverityLevel {
      SEVERITY_UNSPECIFIED = 0;
      ERROR = 1;
      WARNING = 2;
      INFO = 3;
    }
    optional SeverityLevel severity = 10;

    // Expected value (inherited from threshold definition).
    optional ThresholdValue expected_value = 3;

    // Actual value, can be used to decide severity level.
    optional ActualValue actual_value = 4;

    // Launch duration
    optional int64 launch_dur = 5;

    // Sum of durations of slices and thread states in trace_slices_or_threads.
    // Can be used to decide if a couple of top slices or threads caused the
    // issue.
    optional int64 duration = 6;

    // Information of a subset of slice and thread sections to focused on,
    // sorted by the duration in descending order.
    // By checking out the top slices/threads, developers can identify specific
    // slices or threads for further investigation.
    optional TraceSliceSectionInfo trace_slice_sections = 7;
    optional TraceThreadSectionInfo trace_thread_sections = 8;

    // Details specific for a reason.
    optional string additional_info = 9;
  }

  message ThresholdValue {
    // Expected value. 1 for true and 0 for false for booleans.
    optional int64 value = 1;

    // Expected value unit. Enum, e.g. "ns", "%"
    enum ThresholdUnit {
      THRESHOLD_UNIT_UNSPECIFIED = 0;
      NS = 1;
      PERCENTAGE = 2;
      TRUE_OR_FALSE = 3;
      COUNT = 4;
    }
    optional ThresholdUnit unit = 2;

    // For numeric threshold values only. When higher_expected is true,
    // an app startup is considered performant if actual value is higher
    // than the threshold.
    optional bool higher_expected = 3;
  }

  message ActualValue {
    // Actual value. 1 for true and 0 for false for booleans.
    optional int64 value = 1;

    // Actual duration for percentage thresholds only.
    // E.g. if the threashold is 20% and the launch_duration is 1000ms,
    // then the actual duration is more than 200ms.
    optional int64 dur = 2;
  }

  // Contains information for a section of a slice.
  message TraceSliceSection {
    optional int64 start_timestamp = 1;

    optional int64 end_timestamp = 2;

    optional uint32 slice_id = 3;

    optional string slice_name = 4;

    optional uint32 process_pid = 5;

    optional uint32 thread_tid = 6;
  }

  // Information for the SliceSections
  message TraceSliceSectionInfo {
    repeated TraceSliceSection slice_section = 1;
    optional int64 start_timestamp = 2;
    optional int64 end_timestamp = 3;
  }

  // Contains information for a section of a thread.
  message TraceThreadSection {
    optional int64 start_timestamp = 1;

    optional int64 end_timestamp = 2;

    // Deprecated as of 09/2024
    optional uint32 thread_utid = 3;

    optional string thread_name = 4;

    optional uint32 process_pid = 5;

    optional uint32 thread_tid = 6;
  }

  // Information for the ThreadSections
  message TraceThreadSectionInfo {
    repeated TraceThreadSection thread_section = 1;
    optional int64 start_timestamp = 2;
    optional int64 end_timestamp = 3;
  }

  // Next id: 26
  message Startup {
    // Random id uniquely identifying an app startup in this trace.
    optional uint32 startup_id = 1;

    // Startup type (cold / warm / hot)
    optional string startup_type = 16;

    // Number of CPUs the device has
    optional uint32 cpu_count = 25;

    // Name of the package launched
    optional string package_name = 2;

    // Name of the process launched
    optional string process_name = 3;

    // Details about the activities launched
    repeated Activity activities = 11;

    // Details about slow binder transactions during the startup. The definition
    // of a slow transaction is an implementation detail.
    repeated BinderTransaction long_binder_transactions = 14;

    // Did we ask the zygote for a new process
    optional bool zygote_new_process = 4;

    // Number of processes hosting the activity involved in the launch.
    // This will usually be 1. If it is 0, it is indicative of a data / process
    // error. If > 1, the process died during startup and the system respawned
    // it.
    optional uint32 activity_hosting_process_count = 6;

    // Time it takes to display the first frame of the app`s UI.
    // Details:
    // https://developer.android.com/topic/performance/vitals/launch-time#time-initial
    optional int64 time_to_initial_display = 22;

    // Time to full display (TTFD) is the time ittakes for an app to become
    // interactive for the user.
    // Datails:
    // https://developer.android.com/topic/performance/vitals/launch-time#time-full
    optional int64 time_to_full_display = 23;

    // Contains timestamps of important events which happened during
    // the startup.
    optional EventTimestamps event_timestamps = 13;

    // Timing information spanning the intent received by the
    // activity manager to the first frame drawn.
    optional ToFirstFrame to_first_frame = 5;

    // Details about the process (uid, version, etc)
    optional AndroidProcessMetadata process = 7;

    // Metrics about startup which were developed by looking at experiments
    // using high-speed cameras (HSC).
    optional HscMetrics hsc = 8;

    // The time taken in the startup from intent received to the start time
    // of the reportFullyDrawn slice. This should be longer than the time to
    // first frame as the application decides this after it starts rendering.
    optional Slice report_fully_drawn = 9;

    // Contains information about the status of odex files.
    repeated OptimizationStatus optimization_status = 12;

    // Contains information about the class verification.
    repeated VerifyClass verify_class = 19;

    // Contains the dlopen file names.
    repeated string dlopen_file = 20;

    // Package name of startups running concurrent to the launch.
    repeated string startup_concurrent_to_launch = 18;

    // Contains information about the state of the rest of the system during the
    // startup. This is useful for getting context about why a startup might
    // be slow beyond just what the app is doing.
    optional SystemState system_state = 15;

    // A list of identified potential causes for slow startup.
    // Optional.
    repeated string slow_start_reason = 17;

    // Same as slow_start_reason, but with more detailed information, obsolete.
    repeated SlowStartReasonDetailed slow_start_reason_detailed = 21;

    // Similar to slow_start_reason_detailed, but with much more comprehensive
    // info. such as expected threshold, actual value and threads/slices to
    // inspect. slow_start_reason will be obsolete once
    // slow_start_reason_with_details is completed since
    // slow_start_reason_with_details contains all the data in slow_start_reason
    // and more.
    repeated SlowStartReason slow_start_reason_with_details = 24;

    reserved 10;
  }

  repeated Startup startup = 1;
}

// End of protos/perfetto/metrics/android/startup_metric.proto

// Begin of protos/perfetto/metrics/android/surfaceflinger.proto

message AndroidSurfaceflingerMetric {
  // Counts the number of missed frames in the trace.
  optional uint32 missed_frames = 1;

  // Counts the number of missed HWC frames in the trace.
  optional uint32 missed_hwc_frames = 2;

  // Counts the number of missed GPU frames in the trace.
  optional uint32 missed_gpu_frames = 3;

  // Calculate the number of missed frames divided by
  // total frames
  optional double missed_frame_rate = 4;

  // Calculate the number of missed HWC frames divided by
  // total HWC frames
  optional double missed_hwc_frame_rate = 5;

  // Calculate the number of missed GPU frames divided by
  // total GPU frames
  optional double missed_gpu_frame_rate = 6;

  // Count the number of times SurfaceFlinger needs to invoke GPU
  // for rendering some layers
  optional uint32 gpu_invocations = 7;

  // Calculate the average duration of GPU request by SurfaceFlinger
  // since it enters the FenceMonitor's queue until it gets completed
  optional double avg_gpu_waiting_dur_ms = 8;

  // Calculate the total duration when there is at least one GPU request
  // by SurfaceFlinger that is still waiting for GPU to complete the
  // request.
  // This also equals to the total duration of
  // "waiting for GPU completion <fence_num>" in SurfaceFlinger.
  optional double total_non_empty_gpu_waiting_dur_ms = 9;

  message MetricsPerDisplay {
    // Display ID in SF
    optional string display_id = 1;

    // Counts the number of missed frames in the trace.
    optional uint32 missed_frames = 2;

    // Counts the number of missed HWC frames in the trace.
    optional uint32 missed_hwc_frames = 3;

    // Counts the number of missed GPU frames in the trace.
    optional uint32 missed_gpu_frames = 4;

    // Calculate the number of missed frames divided by
    // total frames
    optional double missed_frame_rate = 5;

    // Calculate the number of missed HWC frames divided by
    // total HWC frames
    optional double missed_hwc_frame_rate = 6;

    // Calculate the number of missed GPU frames divided by
    // total GPU frames
    optional double missed_gpu_frame_rate = 7;
  }

  repeated MetricsPerDisplay metrics_per_display = 10;
}

// End of protos/perfetto/metrics/android/surfaceflinger.proto

// Begin of protos/perfetto/metrics/android/sysui_slice_performance_statistical_data.proto

// Statistical performance data row for a set of slices
message SysUiSlicePerformanceStatisticalData {
  // Name of the Slice
  optional string name = 1;
  // Number of times it happened within the CUJ
  optional int64 cnt = 2;
  // Average duration within the CUJ
  optional int64 avg_dur_ms = 3;
  // Maximal duration within the CUJ
  optional int64 max_dur_ms = 4;
  // Average duration within the CUJ in nanoseconds
  optional int64 avg_dur_ns = 6;
  // Maximal duration within the CUJ in nanoseconds
  optional int64 max_dur_ns = 7;
}
// End of protos/perfetto/metrics/android/sysui_slice_performance_statistical_data.proto

// Begin of protos/perfetto/metrics/android/sysui_notif_shade_list_builder_metric.proto
// System UI Notifications ShadeListBuilder.buildList slices.
// Shows count, average duration, and max duration for each.
message SysuiNotifShadeListBuilderMetric {
  optional SysUiSlicePerformanceStatisticalData all_slices_performance = 1;
  optional SysUiSlicePerformanceStatisticalData
      slices_with_inflation_performance = 2;
  optional SysUiSlicePerformanceStatisticalData
      slices_with_modification_performance = 3;

  // Data row for a single slice
  message SliceDuration {
    // Name of the Slice
    optional string name = 1;

    // Duration in ms
    optional int64 dur_ms = 2;

    // Duration in ns
    optional int64 dur_ns = 3;
  }
  repeated SliceDuration slice = 4;
}
// End of protos/perfetto/metrics/android/sysui_notif_shade_list_builder_metric.proto

// Begin of protos/perfetto/metrics/android/sysui_update_notif_on_ui_mode_changed_metric.proto

// System UI Notifications ShadeListBuilder.buildList slices.
// Shows count, average duration, and max duration for each.
message SysuiUpdateNotifOnUiModeChangedMetric {
  optional SysUiSlicePerformanceStatisticalData all_slices_performance = 1;
  // Data row for a single slice
  message SliceDuration {
    // Name of the Slice
    optional string name = 1;

    // Duration in ms
    optional int64 dur_ms = 2;

    // Duration in ns
    optional int64 dur_ns = 3;
  }
  repeated SliceDuration slice = 2;
}
// End of protos/perfetto/metrics/android/sysui_update_notif_on_ui_mode_changed_metric.proto

// Begin of protos/perfetto/metrics/android/trace_quality.proto

// Metric which checks the data in the trace processor tables is "reasonble"
// (i.e. we would expect to see it from a real device).
//
// This is useful to reject traces which may be valid (so no stat would be
// recorded) but a human would find the trace nonsensical.
message AndroidTraceQualityMetric {
  message Failure {
    // The name of the failed check.
    optional string name = 1;
  }
  repeated Failure failures = 1;
}
// End of protos/perfetto/metrics/android/trace_quality.proto

// Begin of protos/perfetto/metrics/android/unsymbolized_frames.proto

message UnsymbolizedFrames {
  message Frame {
    optional string module = 1;
    optional string build_id = 2;
    optional int64 address = 3;

    // In some cases (Chrome/Webview) the ID that should be used to query
    // symbols in Google's internal tera-scale symbolization service is !=
    // `build_id` and requires some mangling.
    // This field is == 'build_id` for non-chromium cases, and is the breakpad
    // module ID (with lowercase hex digics) for chromium cases.
    optional string google_lookup_id = 4;
  }

  repeated Frame frames = 1;
}

// End of protos/perfetto/metrics/android/unsymbolized_frames.proto

// Begin of protos/perfetto/metrics/android/wattson_in_time_period.proto

message AndroidWattsonTimePeriodMetric {
  // Each version increment means updated structure format or field
  optional int32 metric_version = 1;
  // Each version increment means power model has been updated and estimates
  // might change for the exact same input. Don't compare estimates across
  // different power model versions.
  optional int32 power_model_version = 2;
  repeated AndroidWattsonEstimateInfo period_info = 3;
  // Best effort power estimate made without all the essential traces, but with
  // enough information to make an educated extrapolation of a HW state. The
  // only example right now is for cpu_idle, of which the cpu_idle state can be
  // extrapolated from the swapper thread (aka idle thread).
  optional int32 is_crude_estimate = 4;
}

message AndroidWattsonEstimateInfo {
  optional int32 period_id = 1;
  optional string period_name = 2;
  optional int64 period_dur = 3;
  optional AndroidWattsonCpuSubsystemEstimate cpu_subsystem = 4;
  optional AndroidWattsonGpuSubsystemEstimate gpu_subsystem = 5;
  optional AndroidWattsonTpuSubsystemEstimate tpu_subsystem = 6;
}

message AndroidWattsonCpuSubsystemEstimate {
  // estimates and estimates of subrails
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
  optional AndroidWattsonPolicyEstimate policy0 = 3;
  optional AndroidWattsonPolicyEstimate policy1 = 4;
  optional AndroidWattsonPolicyEstimate policy2 = 5;
  optional AndroidWattsonPolicyEstimate policy3 = 6;
  optional AndroidWattsonPolicyEstimate policy4 = 7;
  optional AndroidWattsonPolicyEstimate policy5 = 8;
  optional AndroidWattsonPolicyEstimate policy6 = 9;
  optional AndroidWattsonPolicyEstimate policy7 = 10;
  optional AndroidWattsonDsuScuEstimate dsu_scu = 11;
}

message AndroidWattsonPolicyEstimate {
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
  optional AndroidWattsonCpuEstimate cpu0 = 3;
  optional AndroidWattsonCpuEstimate cpu1 = 4;
  optional AndroidWattsonCpuEstimate cpu2 = 5;
  optional AndroidWattsonCpuEstimate cpu3 = 6;
  optional AndroidWattsonCpuEstimate cpu4 = 7;
  optional AndroidWattsonCpuEstimate cpu5 = 8;
  optional AndroidWattsonCpuEstimate cpu6 = 9;
  optional AndroidWattsonCpuEstimate cpu7 = 10;
}

message AndroidWattsonCpuEstimate {
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
}

message AndroidWattsonDsuScuEstimate {
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
}

message AndroidWattsonGpuSubsystemEstimate {
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
}

message AndroidWattsonTpuSubsystemEstimate {
  optional float estimated_mw = 1;
  optional float estimated_mws = 2;
}

// End of protos/perfetto/metrics/android/wattson_in_time_period.proto

// Begin of protos/perfetto/metrics/android/wattson_tasks_attribution.proto

message AndroidWattsonTasksAttributionMetric {
  // Each version increment means updated structure format or field
  optional int32 metric_version = 1;
  // Each version increment means power model has been updated and estimates
  // might change for the exact same input. Don't compare estimates across
  // different power model versions.
  optional int32 power_model_version = 2;
  // Lists tasks (e.g. threads, process, package) and associated estimates
  repeated AndroidWattsonTaskPeriodInfo period_info = 3;
  // Best effort power estimate made without all the essential traces, but with
  // enough information to make an educated extrapolation of a HW state. The
  // only example right now is for cpu_idle, of which the cpu_idle state can be
  // extrapolated from the swapper thread (aka idle thread).
  optional int32 is_crude_estimate = 4;
}

// Groups of power per task for each period
message AndroidWattsonTaskPeriodInfo {
  optional int32 period_id = 1;
  optional string period_name = 2;
  repeated AndroidWattsonTaskInfo task_info = 3;
}

message AndroidWattsonTaskInfo {
  // Average estimated power for wall duration in mW
  optional float estimated_mw = 1;
  // Total energy over wall duration across CPUs in mWs
  optional float estimated_mws = 2;
  // Energy attributed to a thread for causing CPU idle exit
  optional float idle_transitions_mws = 3;
  // Sum of estimated_mws and idle_transition_mws, which represents the energy
  // during the active time and the energy to transition into active,
  // respectively
  optional float total_mws = 4;
  optional string thread_name = 5;
  optional string process_name = 6;
  optional string package_name = 7;
  optional int32 thread_id = 8;
  optional int32 process_id = 9;
}

// End of protos/perfetto/metrics/android/wattson_tasks_attribution.proto

// Begin of protos/perfetto/metrics/common/clone_duration.proto

message CloneDuration {
  message ByBuffer {
    optional int32 buffer = 1;
    optional int64 duration_ns = 2;
  }
  repeated ByBuffer by_buffer = 1;
}

// End of protos/perfetto/metrics/common/clone_duration.proto

// Begin of protos/perfetto/metrics/metrics.proto

// Trace processor metadata
// Next id: 21
message TraceMetadata {
  reserved 1;
  optional int64 trace_duration_ns = 2;
  optional string trace_uuid = 3;
  optional string android_build_fingerprint = 4;
  optional string android_incremental_build = 20;
  optional string android_device_manufacturer = 16;
  optional int64 android_profile_boot_classpath = 18;
  optional int64 android_profile_system_server = 19;
  optional int64 statsd_triggering_subscription_id = 5;
  optional int64 trace_size_bytes = 6;
  repeated string trace_trigger = 7;
  optional string trace_causal_trigger = 17;
  optional string unique_session_name = 8;
  optional string trace_config_pbtxt = 9;
  optional int64 sched_duration_ns = 10;
  optional int64 tracing_started_ns = 11;
  optional int64 android_sdk_version = 12;
  optional int64 suspend_count = 13;
  optional int64 data_loss_count = 14;
  optional int64 error_count = 15;
}

// Stats counters for the trace.
// Defined in src/trace_processor/storage/stats.h
message TraceAnalysisStats {
  enum Severity {
    SEVERITY_UNKNOWN = 0;
    SEVERITY_INFO = 1;
    SEVERITY_DATA_LOSS = 2;
    SEVERITY_ERROR = 3;
  }

  enum Source {
    SOURCE_UNKNOWN = 0;
    SOURCE_TRACE = 1;
    SOURCE_ANALYSIS = 2;
  }

  message Stat {
    optional string name = 1;
    optional uint32 idx = 2;
    optional Severity severity = 3;
    optional Source source = 4;

    optional int64 count = 5;
  }

  repeated Stat stat = 1;
}

// Root message for all Perfetto-based metrics (v1 metrics only).
//
// NOTE: the v1 system is "soft" deprecated: no new metrics are allowed but
// we still fully support any existing metrics written using this system.
//
// DO NOT ADD ANY OTHER FIELDS HERE. ADDITION OF NEW v1 METRICS WITH
// IS NO LONGER ALLOWED. PLEASE USE METRICS v2 INSTEAD.
message TraceMetrics {
  // Metrics which were later removed.
  reserved 4, 10, 13, 14, 16, 19;

  // Battery counters metric on Android.
  optional AndroidBatteryMetric android_batt = 5;

  // CPU usage per trace, process and thread.
  optional AndroidCpuMetric android_cpu = 6;

  // Memory metrics on Android (owned by the Android Telemetry team).
  optional AndroidMemoryMetric android_mem = 1;

  // Memory metrics on Android in unaggregated form. (owned by the Android
  // Telemetry team).
  // Note: this generates a lot of data so should not be requested unless it
  // is clear that this data is necessary.
  optional AndroidMemoryUnaggregatedMetric android_mem_unagg = 11;

  // Package list.
  optional AndroidPackageList android_package_list = 12;

  // ion buffer memory metrics.
  optional AndroidIonMetric android_ion = 9;

  // fastrpc subsystem memory metrics.
  optional AndroidFastrpcMetric android_fastrpc = 31;

  // Statistics about low memory kills.
  optional AndroidLmkMetric android_lmk = 8;

  // Power Rails metrics on Android.
  optional AndroidPowerRails android_powrails = 7;

  // Startup metrics on Android (owned by the Android Telemetry team).
  optional AndroidStartupMetric android_startup = 2;

  // Trace metadata (applicable to all traces).
  optional TraceMetadata trace_metadata = 3;

  // Trace stats (applicable to all traces).
  optional TraceAnalysisStats trace_stats = 33;

  // Returns stack frames missing symbols.
  optional UnsymbolizedFrames unsymbolized_frames = 15;

  // If the trace contains a heap graph, output allocation statistics.
  optional JavaHeapStats java_heap_stats = 17;

  // If the trace contains a heap graph, output histogram.
  optional JavaHeapHistogram java_heap_histogram = 21;

  // If the trace contains a heap graph, output stats per heap class.
  optional JavaHeapClassStats java_heap_class_stats = 67;

  // Metrics used to find potential culprits of low-memory kills.
  optional AndroidLmkReasonMetric android_lmk_reason = 18;

  optional AndroidHwuiMetric android_hwui_metric = 20;

  optional AndroidDisplayMetrics display_metrics = 22;

  // Deprecated was AndroidTaskNames
  reserved 23;

  // Deprecated was AndroidThreadTimeInStateMetric
  reserved 24;

  // Metric associated with surfaceflinger.
  optional AndroidSurfaceflingerMetric android_surfaceflinger = 25;

  // GPU metrics on Android.
  optional AndroidGpuMetric android_gpu = 26;

  // Deprecated AndroidSysUiCujMetrics.
  reserved 27;

  // Interaction and frame timings for CUJs (important UI transitions).
  optional AndroidJankCujMetric android_jank_cuj = 48;

  // Metric associated with hwcomposer.
  optional AndroidHwcomposerMetrics android_hwcomposer = 28;

  // Deprecated was AndroidJankMetrics;
  reserved 29;

  // G2D metrics.
  optional G2dMetrics g2d = 30;

  // Dmabuf heap metrics.
  optional AndroidDmaHeapMetric android_dma_heap = 32;

  // Metric to verify the quality of the trace.
  optional AndroidTraceQualityMetric android_trace_quality = 34;

  // Profiler smaps
  optional ProfilerSmaps profiler_smaps = 35;

  // Multiuser - metrics for switching users.
  optional AndroidMultiuserMetric android_multiuser = 36;

  // Metrics related to simpleperf tool
  optional AndroidSimpleperfMetric android_simpleperf = 37;

  // Metrics for the Camera team.
  optional AndroidCameraMetric android_camera = 38;

  // Metrics for dynamic voltage and frequency scaling.
  optional AndroidDvfsMetric android_dvfs = 39;

  // Metrics for network performance.
  optional AndroidNetworkMetric android_netperf = 40;

  // Metrics for the Camera team.
  // Note: this generates a lot of data so should not be requested unless it
  // is clear that this data is necessary.
  optional AndroidCameraUnaggregatedMetric android_camera_unagg = 41;

  // Metrics for RT runtime.
  optional AndroidRtRuntimeMetric android_rt_runtime = 42;

  // Metrics for IRQ runtime.
  optional AndroidIrqRuntimeMetric android_irq_runtime = 43;

  // Was metrics for the Trusty team.
  reserved 44;
  reserved 'android_trusty_workqueues';

  // Was summary of concurrent trace recording.
  reserved 45;
  reserved 'android_other_traces';

  // Per-process Binder transaction metrics.
  optional AndroidBinderMetric android_binder = 46;

  // Metrics for app deadline missed.
  optional AndroidFrameTimelineMetric android_frame_timeline_metric = 47;

  // Blocking calls (e.g. binder calls) for CUJs (important UI transitions).
  optional AndroidBlockingCallsCujMetric android_blocking_calls_cuj_metric = 49;

  optional AndroidMonitorContentionMetric android_monitor_contention = 50;

  optional AndroidSysUINotificationsBlockingCallsMetric
      android_sysui_notifications_blocking_calls_metric = 51;

  // Metrics to track codec framework.
  optional AndroidCodecMetrics codec_metrics = 52;

  // Metric to track Android IO.
  optional AndroidIo android_io = 53;

  // IO metrics on Android in unaggregated form.
  // Note: this generates a lot of data so should not be requested unless it
  // is clear that this data is necessary.
  optional AndroidIoUnaggregated android_io_unagg = 54;

  // Metrics for App Not Responding (ANR) errors.
  optional AndroidAnrMetric android_anr = 55;

  // Aggregated Android Monitor Contention metrics
  optional AndroidMonitorContentionAggMetric android_monitor_contention_agg =
      56;

  optional AndroidBootMetric android_boot = 57;

  // Metric for AdServices module.
  optional AdServicesMetric ad_services_metric = 58;

  optional SysuiNotifShadeListBuilderMetric
      sysui_notif_shade_list_builder_metric = 59;

  optional SysuiUpdateNotifOnUiModeChangedMetric
      sysui_update_notif_on_ui_mode_changed_metric = 60;

  // Metrics for Process starts.
  optional AndroidAppProcessStartsMetric android_app_process_starts = 61;

  // Android boot unaggregated metrics.
  optional AndroidBootUnagg android_boot_unagg = 62;

  // Android garbage collection metrics
  optional AndroidGarbageCollectionUnaggMetric
      android_garbage_collection_unagg = 63;

  // Multiuser - metrics for switching users.
  // Specific for Android Auto
  optional AndroidAutoMultiuserMetric android_auto_multiuser = 64;

  // All blocking calls (e.g. binder calls) for a trace.
  optional AndroidBlockingCallsUnagg android_blocking_calls_unagg = 65;

  // Android OOM unaggregated metrics.
  optional AndroidOomAdjusterMetric android_oom_adjuster = 66;

  // Android Broadcasts aggregated metrics
  optional AndroidBroadcastsMetric android_broadcasts = 68;

  // Android Wattson rail estimate for each app startup.
  optional AndroidWattsonTimePeriodMetric wattson_app_startup_rails = 69;

  // Android Wattson rail estimate for duration of entire trace.
  optional AndroidWattsonTimePeriodMetric wattson_trace_rails = 70;

  // Android Anomaly metric
  optional AndroidAnomalyMetric android_anomaly = 71;

  // Android Wattson app startup metrics.
  optional AndroidWattsonTasksAttributionMetric wattson_trace_threads = 72;

  // Android Wattson thread attribution during markers time window.
  optional AndroidWattsonTasksAttributionMetric wattson_markers_threads = 73;

  // Android Wattson estimate during markers time window.
  optional AndroidWattsonTimePeriodMetric wattson_markers_rails = 74;

  // Android Wattson estimate during time windows defined by atrace apps.
  optional AndroidWattsonTimePeriodMetric wattson_atrace_apps_rails = 75;

  // Android GC stats.
  optional AndroidGarbageCollectionStats android_garbage_collection_stats = 76;

  optional CloneDuration clone_duration = 77;

  // Per-frame blocking calls (e.g. binder calls) during CUJs (important UI
  // transitions).
  optional AndroidCujBlockingCallsPerFrameMetric
      android_blocking_calls_cuj_per_frame_metric = 78;

  // Android Wattson thread attribution during app startups.
  optional AndroidWattsonTasksAttributionMetric wattson_app_startup_threads =
      79;

  // Android Wattson thread attribution during atrace app windows.
  optional AndroidWattsonTasksAttributionMetric wattson_atrace_apps_threads =
      80;

  // Android
  // Demo extensions.
  extensions 450 to 499;

  // Vendor extensions.
  extensions 500 to 1000;

  // Chrome metrics.
  extensions 1001 to 2000;

  // WebView metrics.
  extensions 2001 to 2500;

  // AndroidXR metrics.
  extensions 2501 to 3000;

  // DO NOT ADD ANY OTHER FIELDS HERE. ADDITION OF NEW v1 METRICS IS NO LONGER
  // ALLOWED. PLEASE USE METRICS v2 INSTEAD.
}

// End of protos/perfetto/metrics/metrics.proto
