/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package com_android_server_wifi;

option java_package = "com.android.server.wifi.proto";
option java_outer_classname = "WifiMetricsProto";

// The information about the Wifi events.
message WifiLog {
  reserved 122;

  // Session information that gets logged for every Wifi connection.
  repeated ConnectionEvent connection_event = 1;

  // Number of saved networks in the user profile.
  optional int32 num_saved_networks = 2;

  // Number of open networks in the saved networks.
  optional int32 num_open_networks = 3;

  // Number of legacy personal networks.
  optional int32 num_legacy_personal_networks = 4;

  // Number of legacy enterprise networks.
  optional int32 num_legacy_enterprise_networks = 5;

  // Does the user have location setting enabled.
  optional bool is_location_enabled = 6;

  // Does the user have scanning enabled.
  optional bool is_scanning_always_enabled = 7;

  // Number of times user toggled wifi using the settings menu.
  optional int32 num_wifi_toggled_via_settings = 8;

  // Number of times user toggled wifi using the airplane menu.
  optional int32 num_wifi_toggled_via_airplane = 9;

  // Number of networks added by the user.
  optional int32 num_networks_added_by_user = 10;

  // Number of networks added by applications.
  optional int32 num_networks_added_by_apps = 11;

  // Number scans that returned empty results.
  optional int32 num_empty_scan_results = 12;

  // Number scans that returned at least one result.
  optional int32 num_non_empty_scan_results = 13;

  // Number of single scans requests.
  optional int32 num_oneshot_scans = 14;

  // Number of repeated background scans that were scheduled to the chip.
  optional int32 num_background_scans = 15;

  // Error codes that a scan can result in.
  enum ScanReturnCode {

    // Return Code is unknown.
    SCAN_UNKNOWN = 0;

    // Scan was successful.
    SCAN_SUCCESS = 1;

    // Scan was successfully started, but was interrupted.
    SCAN_FAILURE_INTERRUPTED = 2;

    //  Scan failed to start because of invalid configuration
    //  (bad channel, etc).
    SCAN_FAILURE_INVALID_CONFIGURATION = 3;

    // Could not start a scan because wifi is disabled.
    FAILURE_WIFI_DISABLED = 4;

  }

  // Mapping of error codes to the number of times that scans resulted
  // in that error.
  repeated ScanReturnEntry scan_return_entries = 16;

  message ScanReturnEntry {

    // Return code of the scan.
    optional ScanReturnCode scan_return_code = 1;

    // Number of entries that were found in the scan.
    optional int32 scan_results_count = 2;
  }

  // State of the Wifi.
  enum WifiState {

    // State is unknown.
    WIFI_UNKNOWN = 0;

    // Wifi is disabled.
    WIFI_DISABLED = 1;

    // Wifi is enabled.
    WIFI_DISCONNECTED = 2;

    // Wifi is enabled and associated with an AP.
    WIFI_ASSOCIATED = 3;
  }

  // Mapping of system state to the number of times that scans were requested in
  // that state
  repeated WifiSystemStateEntry wifi_system_state_entries = 17;

  message WifiSystemStateEntry {

    // Current WiFi state.
    optional WifiState wifi_state = 1;

    // Count of scans in state.
    optional int32 wifi_state_count = 2;

    // Is screen on.
    optional bool is_screen_on = 3;
  }

  // Mapping of Error/Success codes to the number of background scans that resulted in it
  repeated ScanReturnEntry background_scan_return_entries = 18;

  // Mapping of system state to the number of times that Background scans were requested in that
  // state
  repeated WifiSystemStateEntry background_scan_request_state = 19;

  // Total number of times the Watchdog of Last Resort triggered, resetting the wifi stack
  optional int32 num_last_resort_watchdog_triggers = 20;

  // Total number of networks over bad association threshold when watchdog triggered
  optional int32 num_last_resort_watchdog_bad_association_networks_total = 21;

  // Total number of networks over bad authentication threshold when watchdog triggered
  optional int32 num_last_resort_watchdog_bad_authentication_networks_total = 22;

  // Total number of networks over bad dhcp threshold when watchdog triggered
  optional int32 num_last_resort_watchdog_bad_dhcp_networks_total = 23;

  // Total number of networks over bad other threshold when watchdog triggered
  optional int32 num_last_resort_watchdog_bad_other_networks_total = 24;

  // Total count of networks seen when watchdog triggered
  optional int32 num_last_resort_watchdog_available_networks_total = 25;

  // Total count of triggers with atleast one bad association network
  optional int32 num_last_resort_watchdog_triggers_with_bad_association = 26;

  // Total count of triggers with atleast one bad authentication network
  optional int32 num_last_resort_watchdog_triggers_with_bad_authentication = 27;

  // Total count of triggers with atleast one bad dhcp network
  optional int32 num_last_resort_watchdog_triggers_with_bad_dhcp = 28;

  // Total count of triggers with atleast one bad other network
  optional int32 num_last_resort_watchdog_triggers_with_bad_other = 29;

  // Count of times connectivity watchdog confirmed pno is working
  optional int32 num_connectivity_watchdog_pno_good = 30;

  // Count of times connectivity watchdog found pno not working
  optional int32 num_connectivity_watchdog_pno_bad = 31;

  // Count of times connectivity watchdog confirmed background scan is working
  optional int32 num_connectivity_watchdog_background_good = 32;

  // Count of times connectivity watchdog found background scan not working
  optional int32 num_connectivity_watchdog_background_bad = 33;

  // The time duration represented by this wifi log, from start to end of capture
  optional int32 record_duration_sec = 34;

  // Counts the occurrences of each individual RSSI poll level
  repeated RssiPollCount rssi_poll_rssi_count = 35;

  // Total number of times WiFi connected immediately after a Last Resort Watchdog trigger,
  // without new networks becoming available.
  optional int32 num_last_resort_watchdog_successes = 36;

  // Total number of saved hidden networks
  optional int32 num_hidden_networks = 37;

  // Total number of saved passpoint / hotspot 2.0 networks
  optional int32 num_passpoint_networks = 38;

  // Total number of scan results
  optional int32 num_total_scan_results = 39;

  // Total number of scan results for open networks
  optional int32 num_open_network_scan_results = 40;

  // Total number of scan results for legacy personal networks
  optional int32 num_legacy_personal_network_scan_results = 41;

  // Total number of scan results for legacy enterprise networks
  optional int32 num_legacy_enterprise_network_scan_results = 42;

  // Total number of scan results for hidden networks
  optional int32 num_hidden_network_scan_results = 43;

  // Total number of scan results for hotspot 2.0 r1 networks
  optional int32 num_hotspot2_r1_network_scan_results = 44;

  // Total number of scan results for hotspot 2.0 r2 networks
  optional int32 num_hotspot2_r2_network_scan_results = 45;

  // Total number of scans handled by framework (oneshot or otherwise)
  optional int32 num_scans = 46;

  // Counts the occurrences of each alert reason.
  repeated AlertReasonCount alert_reason_count = 47;

  // Counts the occurrences of each Wifi score
  repeated WifiScoreCount wifi_score_count = 48;

  // Histogram of Soft AP Durations
  repeated SoftApDurationBucket soft_ap_duration = 49;

  // Histogram of Soft AP ReturnCode
  repeated SoftApReturnCodeCount soft_ap_return_code = 50;

  // Histogram of the delta between scan result RSSI and RSSI polls
  repeated RssiPollCount rssi_poll_delta_count = 51;

  // List of events
  repeated StaEvent sta_event_list = 52;

  // Total number of times WiFi HAL crashed.
  optional int32 num_hal_crashes = 53;

  // Total number of times WiFicond crashed.
  optional int32 num_wificond_crashes = 54;

  // Indicates the number of times an error was encountered in
  // Wifi HAL on |WifiNative.setupInterfaceForClientMode|.
  optional int32 num_setup_client_interface_failure_due_to_hal = 55;

  // Indicates the number of times an error was encountered in
  // Wificond on |WifiNative.setupInterfaceForClientMode|.
  optional int32 num_setup_client_interface_failure_due_to_wificond = 56;

  // Wi-Fi Aware metrics
  optional WifiAwareLog wifi_aware_log = 57;

  // Number of saved Passpoint providers in user profile.
  optional int32 num_passpoint_providers = 58;

  // Count of times Passpoint provider being installed.
  optional int32 num_passpoint_provider_installation = 59;

  // Count of times Passpoint provivider is installed successfully.
  optional int32 num_passpoint_provider_install_success = 60;

  // Count of times Passpoint provider is being uninstalled.
  optional int32 num_passpoint_provider_uninstallation = 61;

  // Count of times Passpoint provider is uninstalled successfully.
  optional int32 num_passpoint_provider_uninstall_success = 62;

  // Count of saved Passpoint providers device has ever connected to.
  optional int32 num_passpoint_providers_successfully_connected = 63;

  // Histogram counting instances of scans with N many ScanResults with unique ssids
  repeated NumConnectableNetworksBucket total_ssids_in_scan_histogram = 64;

  // Histogram counting instances of scans with N many ScanResults/bssids
  repeated NumConnectableNetworksBucket total_bssids_in_scan_histogram = 65;

  // Histogram counting instances of scans with N many unique open ssids
  repeated NumConnectableNetworksBucket available_open_ssids_in_scan_histogram = 66;

  // Histogram counting instances of scans with N many bssids for open networks
  repeated NumConnectableNetworksBucket available_open_bssids_in_scan_histogram = 67;

  // Histogram counting instances of scans with N many unique ssids for saved networks
  repeated NumConnectableNetworksBucket available_saved_ssids_in_scan_histogram = 68;

  // Histogram counting instances of scans with N many bssids for saved networks
  repeated NumConnectableNetworksBucket available_saved_bssids_in_scan_histogram = 69;

  // Histogram counting instances of scans with N many unique SSIDs for open or saved networks
  repeated NumConnectableNetworksBucket available_open_or_saved_ssids_in_scan_histogram = 70;

  // Histogram counting instances of scans with N many BSSIDs for open or saved networks
  repeated NumConnectableNetworksBucket available_open_or_saved_bssids_in_scan_histogram = 71;

  // Histogram counting instances of scans with N many ScanResults matching unique saved passpoint providers
  repeated NumConnectableNetworksBucket available_saved_passpoint_provider_profiles_in_scan_histogram = 72;

  // Histogram counting instances of scans with N many ScanResults BSSIDs matching a saved passpoint provider
  repeated NumConnectableNetworksBucket available_saved_passpoint_provider_bssids_in_scan_histogram = 73;

  // Counts the number of AllSingleScanLister.onResult calls with a full band scan result
  optional int32 full_band_all_single_scan_listener_results = 74;

  // Counts the number of AllSingleScanLister.onResult calls with a partial (channels) scan result
  optional int32 partial_all_single_scan_listener_results = 75;

  // Pno scan metrics
  optional PnoScanMetrics pno_scan_metrics = 76;

  // Histogram of "Connect to Network" notifications.
  // The notification Action should be unset.
  repeated ConnectToNetworkNotificationAndActionCount connect_to_network_notification_count = 77;

  // Histogram of "Connect to Network" notification user actions.
  repeated ConnectToNetworkNotificationAndActionCount connect_to_network_notification_action_count = 78;

  // The number of SSIDs blocked from recommendation by the open network
  // notification recommender
  optional int32 open_network_recommender_blocklist_size = 79;

  // Is the available network notification feature turned on
  optional bool is_wifi_networks_available_notification_on = 80;

  // Count of recommendation updates made by the open network notification
  // recommender
  optional int32 num_open_network_recommendation_updates = 81;

  // Count of connection attempts that were initiated unsuccessfully
  optional int32 num_open_network_connect_message_failed_to_send = 82;

  // Histogram counting instances of scans with N many HotSpot 2.0 R1 APs
  repeated NumConnectableNetworksBucket observed_hotspot_r1_aps_in_scan_histogram = 83;

  // Histogram counting instances of scans with N many HotSpot 2.0 R2 APs
  repeated NumConnectableNetworksBucket observed_hotspot_r2_aps_in_scan_histogram = 84;

  // Histogram counting instances of scans with N many unique HotSpot 2.0 R1 ESS.
  // Where ESS is defined as the (HESSID, ANQP Domain ID), (SSID, ANQP Domain ID) or
  // (SSID, BSSID) tuple depending on AP configuration (in the above priority
  // order).
  repeated NumConnectableNetworksBucket observed_hotspot_r1_ess_in_scan_histogram = 85;

  // Histogram counting instances of scans with N many unique HotSpot 2.0 R2 ESS.
  // Where ESS is defined as the (HESSID, ANQP Domain ID), (SSID, ANQP Domain ID) or
  // (SSID, BSSID) tuple depending on AP configuration (in the above priority
  // order).
  repeated NumConnectableNetworksBucket observed_hotspot_r2_ess_in_scan_histogram = 86;

  // Histogram counting number of HotSpot 2.0 R1 APs per observed ESS in a scan
  // (one value added per unique ESS - potentially multiple counts per single
  // scan!)
  repeated NumConnectableNetworksBucket observed_hotspot_r1_aps_per_ess_in_scan_histogram = 87;

  // Histogram counting number of HotSpot 2.0 R2 APs per observed ESS in a scan
  // (one value added per unique ESS - potentially multiple counts per single
  // scan!)
  repeated NumConnectableNetworksBucket observed_hotspot_r2_aps_per_ess_in_scan_histogram = 88;

  // SoftAP event list tracking sessions and client counts in tethered mode
  repeated SoftApConnectedClientsEvent soft_ap_connected_clients_events_tethered = 89;

  // SoftAP event list tracking sessions and client counts in local only mode
  repeated SoftApConnectedClientsEvent soft_ap_connected_clients_events_local_only = 90;

  // WPS connection metrics - removed
  reserved 91;
  reserved "wps_metrics";

  // Wifi power statistics
  optional WifiPowerStats wifi_power_stats = 92;

  // Number of connectivity single scan requests.
  optional int32 num_connectivity_oneshot_scans = 93;

  // WifiWake statistics
  optional WifiWakeStats wifi_wake_stats = 94;

  // Histogram counting instances of scans with N many 802.11mc (RTT) supporting APs
  repeated NumConnectableNetworksBucket observed_80211mc_supporting_aps_in_scan_histogram = 95;

  // Total number of times supplicant crashed.
  optional int32 num_supplicant_crashes = 96;

  // Total number of times hostapd crashed.
  optional int32 num_hostapd_crashes = 97;

  // Indicates the number of times an error was encountered in
  // supplicant on |WifiNative.setupInterfaceForClientMode|.
  optional int32 num_setup_client_interface_failure_due_to_supplicant = 98;

  // Indicates the number of times an error was encountered in
  // Wifi HAL on |WifiNative.setupInterfaceForSoftApMode|.
  optional int32 num_setup_soft_ap_interface_failure_due_to_hal = 99;

  // Indicates the number of times an error was encountered in
  // Wifi HAL on |WifiNative.setupInterfaceForSoftApMode|.
  optional int32 num_setup_soft_ap_interface_failure_due_to_wificond = 100;

  // Indicates the number of times an error was encountered in
  // Wifi HAL on |WifiNative.setupInterfaceForSoftApMode|.
  optional int32 num_setup_soft_ap_interface_failure_due_to_hostapd = 101;

  // Indicates the number of times we got an interface down in client mode.
  optional int32 num_client_interface_down = 102;

  // Indicates the number of times we got an interface down in softap mode.
  optional int32 num_soft_ap_interface_down = 103;

  // Indicates the number of scan requests from external apps.
  optional int32 num_external_app_oneshot_scan_requests = 104;

  // Indicates the number of times a scan request from an external foreground app was throttled.
  optional int32 num_external_foreground_app_oneshot_scan_requests_throttled = 105;

  // Indicates the number of times a scan request from an external background app was throttled.
  optional int32 num_external_background_app_oneshot_scan_requests_throttled = 106;

  // WifiLastResortWatchdog time milliseconds delta between trigger and first connection success
  optional int64 watchdog_trigger_to_connection_success_duration_ms = 107 [default = -1];

  // The number of times wifi experienced failures after watchdog has already been triggered and is
  // waiting for a connection success
  optional int64 watchdog_total_connection_failure_count_after_trigger = 108;

  // Number of times DFS channel scans are requested in single scan requests.
  optional int32 num_oneshot_has_dfs_channel_scans = 109;

  // Wi-Fi RTT metrics
  optional WifiRttLog wifi_rtt_log = 110;

  // Flag which indicates if Connected MAC Randomization is enabled
  optional bool is_mac_randomization_on = 111 [default = false];

  // Number of radio mode changes to MCC (Multi channel concurrency).
  optional int32 num_radio_mode_change_to_mcc = 112;

  // Number of radio mode changes to SCC (Single channel concurrency).
  optional int32 num_radio_mode_change_to_scc = 113;

  // Number of radio mode changes to SBS (Single band simultaneous).
  optional int32 num_radio_mode_change_to_sbs = 114;

  // Number of radio mode changes to DBS (Dual band simultaneous).
  optional int32 num_radio_mode_change_to_dbs = 115;

  // Number of times the firmware picked a SoftAp channel not satisfying user band preference.
  optional int32 num_soft_ap_user_band_preference_unsatisfied = 116;

  // Identifier for experimental scoring parameter settings.
  optional string score_experiment_id = 117;

  // Data on wifi radio usage
  optional WifiRadioUsage wifi_radio_usage = 118;

  // Stores settings values used for metrics testing.
  optional ExperimentValues experiment_values = 119;

  // List of WifiIsUnusableEvents which get logged when we notice that WiFi is unusable.
  // Collected only when WIFI_IS_UNUSABLE_EVENT_METRICS_ENABLED Settings is enabled.
  repeated WifiIsUnusableEvent wifi_is_unusable_event_list = 120;

  // Counts the occurrences of each link speed (Mbps) level
  // with rssi (dBm) and rssi^2 sums (dBm^2)
  repeated LinkSpeedCount link_speed_counts = 121;

  // Hardware revision (EVT, DVT, PVT etc.)
  optional string hardware_revision = 124;

  // Total wifi link layer usage data over the logging duration in ms.
  optional WifiLinkLayerUsageStats wifi_link_layer_usage_stats = 125;

  // Multiple lists of timestamped link layer stats with labels to represent whether wifi is usable
  repeated WifiUsabilityStats wifi_usability_stats_list = 126;

  // Counts the occurrences of each Wifi usability score provided by external app
  repeated WifiUsabilityScoreCount wifi_usability_score_count = 127;

  // List of PNO scan stats, one element for each mobility state
  repeated DeviceMobilityStatePnoScanStats mobility_state_pno_stats_list = 128;

  // Wifi p2p statistics
  optional WifiP2pStats wifi_p2p_stats = 129;

  // Easy Connect (DPP) metrics
  optional WifiDppLog wifi_dpp_log = 130;

  // Number of Enhanced Open (OWE) networks in the saved networks.
  optional int32 num_enhanced_open_networks = 131;

  // Number of WPA3-Personal networks.
  optional int32 num_wpa3_personal_networks = 132;

  // Number of WPA3-Enterprise networks.
  optional int32 num_wpa3_enterprise_networks = 133;

  // Total number of scan results for Enhanced open networks
  optional int32 num_enhanced_open_network_scan_results = 134;

  // Total number of scan results for WPA3-Personal networks
  optional int32 num_wpa3_personal_network_scan_results = 135;

  // Total number of scan results for WPA3-Enterprise networks
  optional int32 num_wpa3_enterprise_network_scan_results = 136;

  // WifiConfigStore read/write metrics.
  optional WifiConfigStoreIO wifi_config_store_io = 137;

  // Total number of saved networks with mac randomization enabled.
  optional int32 num_saved_networks_with_mac_randomization = 138;

  // Link Probe metrics
  optional LinkProbeStats link_probe_stats = 139;

  // List of NetworkSelectionExperimentDecisions stats for each experiment
  repeated NetworkSelectionExperimentDecisions network_selection_experiment_decisions_list = 140;

  // Network Request API surface metrics.
  optional WifiNetworkRequestApiLog wifi_network_request_api_log = 141;

  // Network Suggestion API surface metrics.
  optional WifiNetworkSuggestionApiLog wifi_network_suggestion_api_log = 142;

  // WifiLock statistics
  optional WifiLockStats wifi_lock_stats = 143;

  // Stats on number of times Wi-Fi is turned on/off though the WifiManager#setWifiEnabled API
  optional WifiToggleStats wifi_toggle_stats = 144;

  // Number of times WifiManager#addOrUpdateNetwork is called.
  optional int32 num_add_or_update_network_calls = 145;

  // Number of times WifiManager#enableNetwork is called.
  optional int32 num_enable_network_calls = 146;

  // Passpoint provison metrics
  optional PasspointProvisionStats passpoint_provision_stats = 147;

  // Histogram of the EAP method type of all installed Passpoint profiles for R1
  repeated PasspointProfileTypeCount installed_passpoint_profile_type_for_r1 = 123;

  // Histogram of the EAP method type of all installed Passpoint profiles for R2
  repeated PasspointProfileTypeCount installed_passpoint_profile_type_for_r2 = 148;

  // Histogram of Tx link speed at 2G
  repeated Int32Count tx_link_speed_count_2g = 149;

  // Histogram of Tx link speed at 5G low band
  repeated Int32Count tx_link_speed_count_5g_low = 150;

  // Histogram of Tx link speed at 5G middle band
  repeated Int32Count tx_link_speed_count_5g_mid = 151;

  // Histogram of Tx link speed at 5G high band
  repeated Int32Count tx_link_speed_count_5g_high = 152;

  // Histogram of Rx link speed at 2G
  repeated Int32Count rx_link_speed_count_2g = 153;

  // Histogram of Rx link speed at 5G low band
  repeated Int32Count rx_link_speed_count_5g_low = 154;

  // Histogram of Rx link speed at 5G middle band
  repeated Int32Count rx_link_speed_count_5g_mid = 155;

  // Histogram of Rx link speed at 5G high band
  repeated Int32Count rx_link_speed_count_5g_high = 156;

  // Count of IP renewal failures.
  optional int32 num_ip_renewal_failure = 157;

  // Metrics collected by health monitor
  optional HealthMonitorMetrics health_monitor_metrics = 158;

  // Metrics related to the WifiBlocklistMonitor
  optional BssidBlocklistStats bssid_blocklist_stats = 159;

  // Connection duration under various health conditions
  optional ConnectionDurationStats connection_duration_stats = 160;

  // Number of WAPI-Personal saved networks.
  optional int32 num_wapi_personal_networks = 161;

  // Number of WAPI-Enterprise saved networks.
  optional int32 num_wapi_enterprise_networks = 162;

  // Total number of scan results for WAPI-Personal networks
  optional int32 num_wapi_personal_network_scan_results = 163;

  // Total number of scan results for WAPI-Enterprise networks
  optional int32 num_wapi_enterprise_network_scan_results = 164;

  // Is the external WiFi connected network scorer from OEM extension module turned on
  optional bool is_external_wifi_scorer_on = 165 [default = false];

  // Metrics related to Wi-Fi off
  optional WifiOffMetrics wifi_off_metrics = 166;

  // Total number of scan results for MBO supported networks
  optional int32 num_mbo_supported_network_scan_results = 167;

  // Total number of scan results for MBO cellular data aware networks
  optional int32 num_mbo_cellular_data_aware_network_scan_results = 168;

  // Total number of scan results for OCE supported networks
  optional int32 num_oce_supported_network_scan_results = 169;

  // Total number of scan results for FILS supported networks
  optional int32 num_fils_supported_network_scan_results = 170;

  // Total number of bssids filtered from network selection due to mbo association
  // disallowed indication
  optional int32 num_bssid_filtered_due_to_mbo_assoc_disallow_ind = 171;

  // Total number of connection to network supporting MBO
  optional int32 num_connect_to_network_supporting_mbo = 172;

  // Total number of connection to network supporting OCE
  optional int32 num_connect_to_network_supporting_oce = 173;

  // Total number of scans triggered due to steering request from AP
  optional int32 num_force_scan_due_to_steering_request = 174;

  // Total number of cellular switch requests from MBO supported AP
  optional int32 num_mbo_cellular_switch_request = 175;

  // Total number of connect request to AP adding FILS AKM
  optional int32 num_connect_request_with_fils_akm = 176;

  // Total number of successful L2 connection through FILS authentication
  optional int32 num_l2_connection_through_fils_authentication = 177;

  // Metrics related to limitation in soft ap config
  optional SoftApConfigLimitationMetrics soft_ap_config_limitation_metrics = 178;

  // WiFi channel utilization histogram of various RF bands
  optional ChannelUtilizationHistogram channel_utilization_histogram = 179;

  // WiFi Tx and Rx throughput histogram at various RF bands
  optional ThroughputMbpsHistogram throughput_mbps_histogram = 180;

  // Total number of steering requests which include MBO assoc retry delay
  optional int32 num_steering_request_including_mbo_assoc_retry_delay = 181;

  // Total number of scan results from 11ax network
  optional int32 num_11ax_network_scan_results = 182;

  // Total number of scan results from 6GHz band
  optional int32 num_6g_network_scan_results = 183;

  // Initial partial scan stats
  optional InitPartialScanStats init_partial_scan_stats = 184;

  // Total number of scan results for hotspot 2.0 r3 networks
  optional int32 num_hotspot2_r3_network_scan_results = 185;

  // Histogram counting instances of scans with N many HotSpot 2.0 R3 APs
  repeated NumConnectableNetworksBucket observed_hotspot_r3_aps_in_scan_histogram = 186;

  // Histogram counting number of HotSpot 2.0 R3 APs per observed ESS in a scan
  // (one value added per unique ESS - potentially multiple counts per single
  // scan!)
  repeated NumConnectableNetworksBucket observed_hotspot_r3_aps_per_ess_in_scan_histogram = 187;

  // Histogram counting instances of scans with N many unique HotSpot 2.0 R3 ESS.
  // Where ESS is defined as the (HESSID, ANQP Domain ID), (SSID, ANQP Domain ID) or
  // (SSID, BSSID) tuple depending on AP configuration (in the above priority
  // order).
  repeated NumConnectableNetworksBucket observed_hotspot_r3_ess_in_scan_histogram = 188;

  // Total number of Passpoint providers with no Root CA in their profile.
  optional int32 num_passpoint_provider_with_no_root_ca = 189;

  // Total number of Passpoint providers with self-signed root CA in their profile.
  optional int32 num_passpoint_provider_with_self_signed_root_ca = 190;

  // Total number of Passpoint providers with subscription expiration date in their profile.
  optional int32 num_passpoint_provider_with_subscription_expiration = 191;

  // List of user initiated actions
  repeated UserActionEvent user_action_events = 192;

  // Does the user have wifi verbose logging enabled.
  optional bool is_verbose_logging_enabled = 193;

  // Does the user have enhanced MAC randomization forced to on.
  optional bool is_enhanced_mac_randomization_force_enabled = 194;

  // Metered stats for saved networks.
  optional MeteredNetworkStats metered_network_stats_saved = 195;

  // Metered stats for suggestion networks.
  optional MeteredNetworkStats metered_network_stats_suggestion = 196;

  // Does the user have wifi wake enabled.
  optional bool is_wifi_wake_enabled = 197;

  // User reaction to the carrier or suggestion app approval UI.
  optional UserReactionToApprovalUiEvent user_reaction_to_approval_ui_event = 198;

  // Number of connection with different BSSID between framework and firmware selection.
  optional int32 num_bssid_different_selection_between_framework_and_firmware = 199;

  // Metrics about carrier wifi network.
  optional CarrierWifiMetrics carrier_wifi_metrics = 200;

  // Long version code of wifi mainline module, 0 means not available.
  optional int64 mainline_module_version = 201;

  // Histogram of Tx link speed at 6G low band
  repeated Int32Count tx_link_speed_count_6g_low = 202;

  // Histogram of Tx link speed at 6G middle band
  repeated Int32Count tx_link_speed_count_6g_mid = 203;

  // Histogram of Tx link speed at 6G high band
  repeated Int32Count tx_link_speed_count_6g_high = 204;

  // Histogram of Rx link speed at 6G low band
  repeated Int32Count rx_link_speed_count_6g_low = 205;

  // Histogram of Rx link speed at 6G middle band
  repeated Int32Count rx_link_speed_count_6g_mid = 206;

  // Histogram of Rx link speed at 6G high band
  repeated Int32Count rx_link_speed_count_6g_high = 207;

  // Metrics about the first connection after boot.
  optional FirstConnectAfterBootStats first_connect_after_boot_stats = 208;

  // Metrics for Wifi to Wifi switches.
  optional WifiToWifiSwitchStats wifi_to_wifi_switch_stats = 209;

  // Bandwidth estimator stats.
  optional BandwidthEstimatorStats bandwidth_estimator_stats = 210;

  // Total number of scan results from 6GHz PSC band
  optional int32 num_6g_psc_network_scan_results = 211;

  // Total number of Passpoint connections with a venue URL
  optional int32 total_number_of_passpoint_connections_with_venue_url = 212;

  // Total number of Passpoint connections with a T&C URL
  optional int32 total_number_of_passpoint_connections_with_terms_and_conditions_url = 213;

  // Total number of user accepted and T&C process completed successfully
  optional int32 total_number_of_passpoint_acceptance_of_terms_and_conditions = 214;

  // Total number of Passpoint profiles with decorated identity prefix
  optional int32 total_number_of_passpoint_profiles_with_decorated_identity = 215;

  // Scope of Passpoint deauth-imminent notification: ESS or BSS
  repeated Int32Count passpoint_deauth_imminent_scope = 216;

  // Total number of steering requests from AP
  optional int32 num_steering_request = 217;

  // Histogram corresponding to the number of times recent connection failure status are reported
  // per WifiConfiguration.RecentFailureReason
  repeated Int32Count recent_failure_association_status = 218;

  // Histogram of country codes observed from scan results.
  // Bucket WifiMetrics.COUNTRY_CODE_CONFLICT_WIFI_SCAN for the code conflict within scan results.
  // Bucket WifiMetrics.COUNTRY_CODE_CONFLICT_WIFI_SCAN_TELEPHONY for the code conflict between wifi
  // and telephony.
  // Bucket value is capped to WifiMetrics.MAX_COUNTRY_CODE_COUNT.
  repeated Int32Count country_code_scan_histogram = 219;

  // Each WifiUsabilityStatsTraining instance contains a list of WifiUsabilityStatsEntry objects,
  // representing a time series of WiFi usability statistics recorded within a specific data
  // capture period. It also includes information about the type of data capture and the duration
  // of the capture period.
  repeated WifiUsabilityStatsTraining wifi_usability_stats_training = 220;
}

// Information that gets logged for every WiFi connection.
message RouterFingerPrint {

  enum RoamType {

    // Type is unknown.
    ROAM_TYPE_UNKNOWN = 0;

    // No roaming - usually happens on a single band (2.4 GHz) router.
    ROAM_TYPE_NONE = 1;

    // Enterprise router.
    ROAM_TYPE_ENTERPRISE = 2;

    // DBDC => Dual Band Dual Concurrent essentially a router that
    // supports both 2.4 GHz and 5 GHz bands.
    ROAM_TYPE_DBDC = 3;
  }

  enum Auth {

    // Auth is unknown.
    AUTH_UNKNOWN = 0;

    // No authentication.
    AUTH_OPEN = 1;

    // If the router uses a personal authentication.
    AUTH_PERSONAL = 2;

    // If the router is setup for enterprise authentication.
    AUTH_ENTERPRISE = 3;
  }

  enum RouterTechnology {

    // Router is unknown.
    ROUTER_TECH_UNKNOWN = 0;

    // Router Channel A.
    ROUTER_TECH_A = 1;

    // Router Channel B.
    ROUTER_TECH_B = 2;

    // Router Channel G.
    ROUTER_TECH_G = 3;

    // Router Channel N.
    ROUTER_TECH_N = 4;

    // Router Channel AC.
    ROUTER_TECH_AC = 5;

    // When the channel is not one of the above.
    ROUTER_TECH_OTHER = 6;

    // Router Channel AX.
    ROUTER_TECH_AX = 7;
  }

  enum EapMethod {

    // No EAP method used
    TYPE_EAP_UNKNOWN = 0;

    // EAP with Transport Layer Security
    TYPE_EAP_TLS = 1;

    // EAP with Tunneled Transport Layer Security
    TYPE_EAP_TTLS = 2;

    // EAP with Subscriber Identity Module [RFC-4186]
    TYPE_EAP_SIM = 3;

    // EAP with Authentication and Key Agreement [RFC-4187]
    TYPE_EAP_AKA = 4;

    // EAP with Authentication and Key Agreement Prime [RFC-5448]
    TYPE_EAP_AKA_PRIME = 5;

    // Protected EAP
    TYPE_EAP_PEAP = 6;

    // EAP for Hotspot 2.0 r2 OSEN
    TYPE_EAP_UNAUTH_TLS = 7;

    // EAP with Password
    TYPE_EAP_PWD = 8;

    // EAP with WAPI certifcate
    TYPE_EAP_WAPI_CERT = 9;
  }

  enum AuthPhase2Method {

    // No phase2 method
    TYPE_PHASE2_NONE = 0;

    // Password Authentication Protocol
    TYPE_PHASE2_PAP = 1;

    // Microsoft Challenge Handshake Authentication Protocol
    TYPE_PHASE2_MSCHAP = 2;

    // Microsoft Challenge Handshake Authentication Protocol v2
    TYPE_PHASE2_MSCHAPV2 = 3;

    // Generic Token Card
    TYPE_PHASE2_GTC = 4;

    // EAP-Subscriber Identity Module [RFC-4186]
    TYPE_PHASE2_SIM = 5;

    // EAP-Authentication and Key Agreement [RFC-4187]
    TYPE_PHASE2_AKA = 6;

    // EAP-Authentication and Key Agreement Prime [RFC-5448]
    TYPE_PHASE2_AKA_PRIME = 7;
  }

  enum OcspType {
    // Do not use OCSP stapling
    TYPE_OCSP_NONE = 0;

    // Try to use OCSP stapling, but not require response
    TYPE_OCSP_REQUEST_CERT_STATUS = 1;

    // Require valid OCSP stapling response
    TYPE_OCSP_REQUIRE_CERT_STATUS = 2;

    // Require valid OCSP stapling response for all not-trusted certificates
    // in the server certificate chain
    TYPE_OCSP_REQUIRE_ALL_NON_TRUSTED_CERTS_STATUS = 3;
  }

  optional RoamType roam_type = 1;

  // Channel on which the connection takes place.
  optional int32 channel_info = 2;

  // DTIM setting of the router.
  optional int32 dtim = 3;

  // Authentication scheme of the router.
  optional Auth authentication = 4;

  // If the router is hidden.
  optional bool hidden = 5;

  // Channel information.
  optional RouterTechnology router_technology = 6;

  // whether ipv6 is supported.
  optional bool supports_ipv6 = 7;

  // If the router is a Passpoint / Hotspot 2.0 network
  optional bool passpoint = 8;

  // EAP method used by the enterprise network
  optional EapMethod eap_method = 9;

  // Phase 2 authentication method after setting up a secure channel
  optional AuthPhase2Method auth_phase2_method = 10;

  // Online certificate status protocol stapling type
  optional OcspType ocsp_type = 11;

  // PMK caching enablement
  optional bool pmk_cache_enabled = 12;

  // Max Tx link speed (in Mbps) supported by current network (STA and AP)
  optional int32 max_supported_tx_link_speed_mbps = 13;

  // Max Rx link speed (in Mbps) supported by current network (STA and AP)
  optional int32 max_supported_rx_link_speed_mbps = 14;

  // If the Passpoint connection is provided by the Home provider or Roaming/visited network
  optional bool is_passpoint_home_provider = 15;
}

enum ClientRole {
  // default/Invalid role
  ROLE_UNKNOWN = 0;

  // STA created for scans only.
  ROLE_CLIENT_SCAN_ONLY = 1;

  // secondary STA used for make before break.
  ROLE_CLIENT_SECONDARY_TRANSIENT = 2;

  // secondary STA created for local connection (no internet connectivity).
  ROLE_CLIENT_LOCAL_ONLY = 3;

  // primary STA.
  ROLE_CLIENT_PRIMARY = 4;

  // Long lived secondary STA used for restricted use cases
  ROLE_CLIENT_SECONDARY_LONG_LIVED = 5;
}

message ConnectionEvent {

  // Roam Type.
  enum RoamType {

    // Type is unknown.
    ROAM_UNKNOWN = 0;

    // No roaming.
    ROAM_NONE = 1;

    // DBDC roaming.
    ROAM_DBDC = 2;

    // Enterprise roaming.
    ROAM_ENTERPRISE = 3;

    // User selected roaming.
    ROAM_USER_SELECTED = 4;

    // Unrelated.
    ROAM_UNRELATED = 5;
  }

  // Connectivity Level Failure.
  enum ConnectivityLevelFailure {

    // Failure is unknown.
    HLF_UNKNOWN = 0;

    // No failure.
    HLF_NONE = 1;

    // DHCP failure.
    HLF_DHCP = 2;

    // No internet connection.
    HLF_NO_INTERNET = 3;

    // No internet connection.
    HLF_UNWANTED = 4;
  }

  // Level 2 failure reason.
  enum Level2FailureReason {

    // Unknown default
    FAILURE_REASON_UNKNOWN = 0;

    // The reason code if there is no error during authentication. It could
    // also imply that there no authentication in progress.
    AUTH_FAILURE_NONE = 1;

    // The reason code if there was a timeout authenticating.
    AUTH_FAILURE_TIMEOUT = 2;

    // The reason code if there was a wrong password while authenticating.
    AUTH_FAILURE_WRONG_PSWD = 3;

    // The reason code if there was EAP failure while authenticating.
    AUTH_FAILURE_EAP_FAILURE = 4;

    // The reason code if the AP can no longer accept new clients.
    ASSOCIATION_REJECTION_AP_UNABLE_TO_HANDLE_NEW_STA = 5;

    // The reason code if AP disconnects STA during the connecting state.
    DISCONNECTION_NON_LOCAL = 6;

    // The reason code if a user rejects this connection.
    AUTH_FAILURE_REJECTED_BY_USER = 7;

    // The reason code if an insecure Enterprise connection requires user's approval
    DISCONNECTED_USER_APPROVAL_NEEDED = 8;
  }

  // Entity that recommended connecting to this network.
  enum ConnectionNominator {
    // Unknown nominator
    NOMINATOR_UNKNOWN = 0;

    // User selected network manually
    NOMINATOR_MANUAL = 1;

    // Saved network
    NOMINATOR_SAVED = 2;

    // Suggestion API
    NOMINATOR_SUGGESTION = 3;

    // Passpoint
    NOMINATOR_PASSPOINT = 4;

    // Carrier suggestion
    NOMINATOR_CARRIER = 5;

    // External scorer
    NOMINATOR_EXTERNAL_SCORED = 6;

    // Network Specifier
    NOMINATOR_SPECIFIER = 7;

    // User connected choice override
    NOMINATOR_SAVED_USER_CONNECT_CHOICE = 8;

    // Open Network Available Pop-up
    NOMINATOR_OPEN_NETWORK_AVAILABLE = 9;
  }

  enum NetworkType {
    // Unknown network type
    TYPE_UNKNOWN = 0;

    // WPA2 network
    TYPE_WPA2 = 1;

    // WPA3 network
    TYPE_WPA3 = 2;

    // Passpoint network
    TYPE_PASSPOINT = 3;

    // EAP network, excluding passpoint
    TYPE_EAP = 4;

    // OWE network
    TYPE_OWE = 5;

    // Open network
    TYPE_OPEN = 6;

    // WAPI network
    TYPE_WAPI = 7;
  }

  enum NetworkCreator {
    // This network is created by an unknown app.
    CREATOR_UNKNOWN = 0;

    // This network is created by the user.
    CREATOR_USER = 1;

    // This network is created by a carrier app.
    CREATOR_CARRIER = 2;
  }

  // Start time of the connection, in milliseconds since Unix epoch (1970-01-01).
  optional int64 start_time_millis = 1 [deprecated=true]; // [(datapol.semantic_type) = ST_TIMESTAMP];

  // Start time of the connection, in milliseconds since device boot
  optional int64 start_time_since_boot_millis = 28 [default = 0];

  // Duration to connect.
  optional int32 duration_taken_to_connect_millis = 2;

  // Router information.
  optional RouterFingerPrint router_fingerprint = 3;

  // RSSI at the start of the connection.
  optional int32 signal_strength = 4;

  // Roam Type.
  optional RoamType roam_type = 5;

  // Result of the connection.
  optional int32 connection_result = 6;

  // Reasons for level 2 failure (needs to be coordinated with wpa-supplicant).
  optional int32 level_2_failure_code = 7;

  // Failures that happen at the connectivity layer.
  optional ConnectivityLevelFailure connectivity_level_failure_code = 8;

  // Has bug report been taken.
  optional bool automatic_bug_report_taken = 9;

  // Connection is using locally generated random MAC address.
  optional bool use_randomized_mac = 10 [default = false];

  // Who chose to connect.
  optional ConnectionNominator connection_nominator = 11;

  // The currently running network selector when this connection event occurred.
  optional int32 network_selector_experiment_id = 12;

  // Breakdown of level_2_failure_code with more detailed reason.
  optional Level2FailureReason level_2_failure_reason = 13
          [default = FAILURE_REASON_UNKNOWN];

  // Connection is using an aggressively generated random MAC address.
  optional bool use_aggressive_mac = 14;

  // Number of BSSIDs for this network that were excluded from network selection.
  optional int32 num_bssid_in_blocklist = 15;

  // The type of network for this connection.
  optional NetworkType network_type = 16;

  // UID of the app that created this network.
  optional NetworkCreator network_creator = 17;

  // Whether the screen is on when the connection event starts
  optional bool screen_on = 18;

  // Number of consecutive connection failures with the same SSID at high RSSI
  // before current connection event. Any connection failure at low RSSI in the
  // middle won't break the streak count. The count is cleared after
  // a network disconnection event.
  optional int32 num_consecutive_connection_failure = 19 [default = -1];

  // Indicates if the profile used for the connection was provisioned by Passpoint OSU server
  optional bool is_osu_provisioned = 20;

  // The wireless interface name e.g. "wlan0", "wlan1". Used to distinguish which event stream this
  // ConnectionEvent belongs to when multiple interfaces are active concurrently.
  optional string interface_name = 27;

  // The role of the wireless interface at the start of the connection.
  // Gives more information on what purpose this interface is used for.
  optional ClientRole interface_role = 29;

  // Indicates if the profile used for the connection is carrier merged.
  optional bool is_carrier_merged = 30;

  // Indicates if this was the first connection event after boot
  optional bool is_first_connection_after_boot = 31;
}

// Number of occurrences of a specific RSSI poll rssi value
message RssiPollCount {
  // RSSI
  optional int32 rssi = 1;

  // Number of RSSI polls with 'rssi'
  optional int32 count = 2;

  // Beacon frequency of the channel in MHz
  optional int32 frequency = 3;
}

// Number of occurrences of a specific alert reason value
message AlertReasonCount {
  // Alert reason
  optional int32 reason = 1;

  // Number of alerts with |reason|.
  optional int32 count = 2;
}

// Counts the number of instances of a specific Wifi Score calculated by WifiScoreReport
message WifiScoreCount {
  // Wifi Score
  optional int32 score = 1;

  // Number of Wifi score reports with this score
  optional int32 count = 2;
}

// Counts the number of instances of a specific Wifi Usability Score
message WifiUsabilityScoreCount {
  // Wifi Usability Score
  optional int32 score = 1;

  // Number of Wifi score reports with this score
  optional int32 count = 2;
}

// Number of occurrences of a specific link speed (Mbps)
// and sum of rssi (dBm) and rssi^2 (dBm^2)
message LinkSpeedCount {
  // Link speed (Mbps)
  optional int32 link_speed_mbps = 1;

  // Number of RSSI polls with link_speed
  optional int32 count = 2;

  // Sum of absolute values of rssi values (dBm)
  optional int32 rssi_sum_dbm = 3;

  // Sum of squares of rssi values (dBm^2)
  optional int64 rssi_sum_of_squares_dbm_sq = 4;
}


// Number of occurrences of Soft AP session durations
message SoftApDurationBucket {
  // Bucket covers duration : [duration_sec, duration_sec + bucket_size_sec)
  // The (inclusive) lower bound of Soft AP session duration represented by this bucket
  optional int32 duration_sec = 1;

  // The size of this bucket
  optional int32 bucket_size_sec = 2;

  // Number of soft AP session durations that fit into this bucket
  optional int32 count = 3;
}

// Number of occurrences of a soft AP session return code
message SoftApReturnCodeCount {

  enum SoftApStartResult {

    // SoftApManager return code unknown
    SOFT_AP_RETURN_CODE_UNKNOWN = 0;

    // SoftAp started successfully
    SOFT_AP_STARTED_SUCCESSFULLY = 1;

    // Catch all for failures with no specific failure reason
    SOFT_AP_FAILED_GENERAL_ERROR = 2;

    // SoftAp failed to start due to NO_CHANNEL error
    SOFT_AP_FAILED_NO_CHANNEL = 3;

    // SoftAp failed to start due to unsupported configuration error
    SOFT_AP_FAILED_UNSUPPORTED_CONFIGURATION = 4;
  }

  // Historical, no longer used for writing as of 01/2017.
  optional int32 return_code = 1 [deprecated = true];

  // Occurrences of this soft AP return code
  optional int32 count = 2;

  // Result of attempt to start SoftAp
  optional SoftApStartResult start_result = 3;
}

message StaEvent {
  message ConfigInfo {
    // The set of key management protocols supported by this configuration.
    optional uint32 allowed_key_management = 1 [default = 0];

    // The set of security protocols supported by this configuration.
    optional uint32 allowed_protocols = 2 [default = 0];

    // The set of authentication protocols supported by this configuration.
    optional uint32 allowed_auth_algorithms = 3 [default = 0];

    // The set of pairwise ciphers for WPA supported by this configuration.
    optional uint32 allowed_pairwise_ciphers = 4 [default = 0];

    // The set of group ciphers supported by this configuration.
    optional uint32 allowed_group_ciphers = 5;

    // Is this a 'hidden network'
    optional bool hidden_ssid = 6;

    // Is this a Hotspot 2.0 / passpoint network
    optional bool is_passpoint = 7;

    // Is this an 'ephemeral' network (Not in saved network list, recommended externally)
    optional bool is_ephemeral = 8;

    // Has a successful connection ever been established using this WifiConfiguration
    optional bool has_ever_connected = 9;

    // RSSI of the scan result candidate associated with this WifiConfiguration
    optional int32 scan_rssi = 10 [default = -127];

    // Frequency of the scan result candidate associated with this WifiConfiguration
    optional int32 scan_freq = 11 [default = -1];
  }

  enum EventType {
    // Default/Invalid event
    TYPE_UNKNOWN = 0;

    // Supplicant Association Rejection event. Code contains the 802.11
    TYPE_ASSOCIATION_REJECTION_EVENT = 1;

    // Supplicant L2 event,
    TYPE_AUTHENTICATION_FAILURE_EVENT = 2;

    // Supplicant L2 event
    TYPE_NETWORK_CONNECTION_EVENT = 3;

    // Supplicant L2 event
    TYPE_NETWORK_DISCONNECTION_EVENT = 4;

    // Supplicant L2 event
    TYPE_SUPPLICANT_STATE_CHANGE_EVENT = 5;

    // Supplicant L2 event
    TYPE_CMD_ASSOCIATED_BSSID = 6;

    // IP Manager successfully completed IP Provisioning
    TYPE_CMD_IP_CONFIGURATION_SUCCESSFUL = 7;

    // IP Manager failed to complete IP Provisioning
    TYPE_CMD_IP_CONFIGURATION_LOST = 8;

    // IP Manager lost reachability to network neighbors
    TYPE_CMD_IP_REACHABILITY_LOST = 9;

    // Indicator that Supplicant is targeting a BSSID for roam/connection
    TYPE_CMD_TARGET_BSSID = 10;

    // Wifi framework is initiating a connection attempt
    TYPE_CMD_START_CONNECT = 11;

    // Wifi framework is initiating a roaming connection attempt
    TYPE_CMD_START_ROAM = 12;

    // SystemAPI connect() command, Settings App
    TYPE_CONNECT_NETWORK = 13;

    // Network Agent has validated the internet connection (Captive Portal Check success, or user
    // validation)
    TYPE_NETWORK_AGENT_VALID_NETWORK = 14;

    // Framework initiated disconnect. Sometimes generated to give an extra reason for a disconnect
    // Should typically be followed by a NETWORK_DISCONNECTION_EVENT with a local_gen = true
    TYPE_FRAMEWORK_DISCONNECT = 15;

    // The NetworkAgent score for wifi has changed in a way that may impact
    // connectivity
    TYPE_SCORE_BREACH = 16;

    // Framework changed Sta interface MAC address
    TYPE_MAC_CHANGE = 17;

    // Wifi is turned on
    TYPE_WIFI_ENABLED = 18;

    // Wifi is turned off
    TYPE_WIFI_DISABLED = 19;

    // The NetworkAgent Wifi usability score has changed in a way that may
    // impact connectivity
    TYPE_WIFI_USABILITY_SCORE_BREACH = 20;

    // Link probe was performed
    TYPE_LINK_PROBE = 21;
  }

  enum FrameworkDisconnectReason {
    // default/none/unknown value
    DISCONNECT_UNKNOWN = 0;

    // API DISCONNECT
    DISCONNECT_API = 1;

    // Some framework internal reason (generic)
    DISCONNECT_GENERIC = 2;

    // Network Agent network validation failed, user signaled network unwanted
    DISCONNECT_UNWANTED = 3;

    // Roaming timed out
    DISCONNECT_ROAM_WATCHDOG_TIMER = 4;

    // P2P service requested wifi disconnect
    DISCONNECT_P2P_DISCONNECT_WIFI_REQUEST = 5;

    // SIM was removed while using a SIM config
    DISCONNECT_RESET_SIM_NETWORKS = 6;

    // The network being evaluated in Make-Before-Break was disconnected due to no internet.
    DISCONNECT_MBB_NO_INTERNET = 7;

    // The network has been removed from the database.
    DISCONNECT_NETWORK_REMOVED = 8;

    // The network has been marked as metered.
    DISCONNECT_NETWORK_METERED = 9;

    // The network has been disabled temporarily.
    DISCONNECT_NETWORK_TEMPORARY_DISABLED = 10;

    // The network has been disabled permanently.
    DISCONNECT_NETWORK_PERMANENT_DISABLED = 11;

    // Carrier offload for this network has been disabled.
    DISCONNECT_CARRIER_OFFLOAD_DISABLED = 12;

    // Disconnected due to an issue with passpoint terms and conditions URL.
    DISCONNECT_PASSPOINT_TAC = 13;

    // VCN policy is requesting to tear down the network.
    DISCONNECT_VCN_REQUEST = 14;

    // Connected to a network that's not found in the database.
    DISCONNECT_UNKNOWN_NETWORK = 15;

    // The network has been marked as untrusted.
    DISCONNECT_NETWORK_UNTRUSTED = 16;

    // Wi-Fi 7 support for this network has been enabled or disabled.
    DISCONNECT_NETWORK_WIFI7_TOGGLED = 17;

    // IP configuration is lost. Triggered by connectivity
    DISCONNECT_IP_CONFIGURATION_LOST = 18;

    // IP reachability is lost. Triggered by connectivity
    DISCONNECT_IP_REACHABILITY_LOST = 19;

    // No credentials
    DISCONNECT_NO_CREDENTIALS = 20;

    // Connection timed out
    DISCONNECT_CONNECT_WATCHDOG_TIMER = 21;
  }

  // Authentication Failure reasons as reported through the API.
  enum AuthFailureReason {
    // Unknown default
    AUTH_FAILURE_UNKNOWN = 0;

    // The reason code if there is no error during authentication. It could also imply that there no
    // authentication in progress,
    AUTH_FAILURE_NONE = 1;

    // The reason code if there was a timeout authenticating.
    AUTH_FAILURE_TIMEOUT = 2;

    // The reason code if there was a wrong password while authenticating.
    AUTH_FAILURE_WRONG_PSWD = 3;

    // The reason code if there was EAP failure while authenticating.
    AUTH_FAILURE_EAP_FAILURE = 4;
  }

  // What event was this
  optional EventType type = 1;

  // 80211 death reason code, relevant to NETWORK_DISCONNECTION_EVENTs
  optional int32 reason = 2 [default = -1];

  // 80211 Association Status code, relevant to ASSOCIATION_REJECTION_EVENTs
  optional int32 status = 3 [default = -1];

  // Designates whether a NETWORK_DISCONNECT_EVENT was by the STA or AP
  optional bool local_gen = 4 [default = false];

  // Network information from the WifiConfiguration of a framework initiated connection attempt
  optional ConfigInfo config_info = 5;

  // RSSI from the last rssi poll (Only valid for active connections)
  optional int32 last_rssi = 6 [default = -127];

  // Link speed from the last rssi poll (Only valid for active connections)
  optional int32 last_link_speed = 7 [default = -1];

  // Frequency from the last rssi poll (Only valid for active connections)
  optional int32 last_freq = 8 [default = -1];

  // Enum used to define bit positions in the supplicant_state_change_bitmask
  // See {@code frameworks/base/wifi/java/android/net/wifi/SupplicantState.java} for documentation
  enum SupplicantState {
    STATE_DISCONNECTED = 0;

    STATE_INTERFACE_DISABLED = 1;

    STATE_INACTIVE = 2;

    STATE_SCANNING = 3;

    STATE_AUTHENTICATING = 4;

    STATE_ASSOCIATING = 5;

    STATE_ASSOCIATED = 6;

    STATE_FOUR_WAY_HANDSHAKE = 7;

    STATE_GROUP_HANDSHAKE = 8;

    STATE_COMPLETED = 9;

    STATE_DORMANT = 10;

    STATE_UNINITIALIZED = 11;

    STATE_INVALID = 12;
  }

  // Bit mask of all supplicant state changes that occurred since the last event
  optional uint32 supplicant_state_changes_bitmask = 9 [default = 0];

  // The number of milliseconds that have elapsed since the device booted
  optional int64 start_time_millis = 10 [default = 0];

  optional FrameworkDisconnectReason framework_disconnect_reason = 11 [default = DISCONNECT_UNKNOWN];

  // Flag which indicates if an association rejection event occurred due to a timeout
  optional bool association_timed_out = 12 [default = false];

  // Authentication failure reason, as reported by WifiManager (calculated from state & deauth code)
  optional AuthFailureReason auth_failure_reason = 13 [default = AUTH_FAILURE_UNKNOWN];

  // NetworkAgent score of connected wifi
  optional int32 last_score = 14 [default = -1];

  // NetworkAgent Wifi usability score of connected wifi
  optional int32 last_wifi_usability_score = 15 [default = -1];

  // Prediction horizon (in second) of Wifi usability score provided by external
  // system app
  optional int32 last_prediction_horizon_sec = 16 [default = -1];

  // Only valid if event type == TYPE_LINK_PROBE.
  // true if link probe succeeded, false otherwise.
  optional bool link_probe_was_success = 17;

  // Only valid if event type == TYPE_LINK_PROBE and link_probe_was_success == true.
  // Elapsed time, in milliseconds, of a successful link probe.
  optional int32 link_probe_success_elapsed_time_ms = 18;

  // Only valid if event type == TYPE_LINK_PROBE and link_probe_was_success == false.
  // Failure reason for an unsuccessful link probe.
  optional LinkProbeStats.LinkProbeFailureReason link_probe_failure_reason = 19;

  // Number of bytes transmitted across mobile networks since device boot.
  optional int64 mobile_tx_bytes = 20 [default = -1];

  // // Number of bytes received across mobile networks since device boot.
  optional int64 mobile_rx_bytes = 21 [default = -1];

  // Number of bytes transmitted since device boot.
  optional int64 total_tx_bytes = 22 [default = -1];

  // Number of bytes received since device boot.
  optional int64 total_rx_bytes = 23 [default = -1];

  // Whether screen is on when the event happens
  optional bool screen_on = 24;

  // Whether cellular data network is available
  optional bool is_cellular_data_available = 25;

  // Whether Adaptive Connectivity is enabled
  optional bool is_adaptive_connectivity_enabled = 26;

  // The wireless interface name e.g. "wlan0", "wlan1". Used to distinguish which event stream this
  // StaEvent belongs to when multiple interfaces are active concurrently.
  optional string interface_name = 27;

  // The role of the wireless interface
  // Gives more information on what purpose this interface is used for.
  optional ClientRole interface_role = 28;
}

// Wi-Fi Aware metrics
message WifiAwareLog {
  // total number of unique apps that used Aware (measured on attach)
  optional int32 num_apps = 1;

  // total number of unique apps that used an identity callback when attaching
  optional int32 num_apps_using_identity_callback = 2;

  // maximum number of attaches for an app
  optional int32 max_concurrent_attach_sessions_in_app = 3;

  // histogram of attach request results
  repeated NanStatusHistogramBucket histogram_attach_session_status = 4;

  // maximum number of concurrent publish sessions in a single app
  optional int32 max_concurrent_publish_in_app = 5;

  // maximum number of concurrent subscribe sessions in a single app
  optional int32 max_concurrent_subscribe_in_app = 6;

  // maximum number of concurrent discovery (publish+subscribe) sessions in a single app
  optional int32 max_concurrent_discovery_sessions_in_app = 7;

  // maximum number of concurrent publish sessions in the system
  optional int32 max_concurrent_publish_in_system = 8;

  // maximum number of concurrent subscribe sessions in the system
  optional int32 max_concurrent_subscribe_in_system = 9;

  // maximum number of concurrent discovery (publish+subscribe) sessions in the system
  optional int32 max_concurrent_discovery_sessions_in_system = 10;

  // histogram of publish request results
  repeated NanStatusHistogramBucket histogram_publish_status = 11;

  // histogram of subscribe request results
  repeated NanStatusHistogramBucket histogram_subscribe_status = 12;

  // number of unique apps which experienced a discovery session creation failure due to lack of
  // resources
  optional int32 num_apps_with_discovery_session_failure_out_of_resources = 13;

  // histogram of create ndp request results
  repeated NanStatusHistogramBucket histogram_request_ndp_status = 14;

  // histogram of create ndp out-of-band (OOB) request results
  repeated NanStatusHistogramBucket histogram_request_ndp_oob_status = 15;

  // maximum number of concurrent active data-interfaces (NDI) in a single app
  optional int32 max_concurrent_ndi_in_app = 19;

  // maximum number of concurrent active data-interfaces (NDI) in the system
  optional int32 max_concurrent_ndi_in_system = 20;

  // maximum number of concurrent data-paths (NDP) in a single app
  optional int32 max_concurrent_ndp_in_app = 21;

  // maximum number of concurrent data-paths (NDP) in the system
  optional int32 max_concurrent_ndp_in_system = 22;

  // maximum number of concurrent secure data-paths (NDP) in a single app
  optional int32 max_concurrent_secure_ndp_in_app = 23;

  // maximum number of concurrent secure data-paths (NDP) in the system
  optional int32 max_concurrent_secure_ndp_in_system = 24;

  // maximum number of concurrent data-paths (NDP) per data-interface (NDI)
  optional int32 max_concurrent_ndp_per_ndi = 25;

  // histogram of durations of Aware being available
  repeated HistogramBucket histogram_aware_available_duration_ms = 26;

  // histogram of durations of Aware being enabled
  repeated HistogramBucket histogram_aware_enabled_duration_ms = 27;

  // histogram of duration (in ms) of attach sessions
  repeated HistogramBucket histogram_attach_duration_ms = 28;

  // histogram of duration (in ms) of publish sessions
  repeated HistogramBucket histogram_publish_session_duration_ms = 29;

  // histogram of duration (in ms) of subscribe sessions
  repeated HistogramBucket histogram_subscribe_session_duration_ms = 30;

  // histogram of duration (in ms) of data-paths (NDP)
  repeated HistogramBucket histogram_ndp_session_duration_ms = 31;

  // histogram of usage (in MB) of data-paths (NDP)
  repeated HistogramBucket histogram_ndp_session_data_usage_mb = 32;

  // histogram of usage (in MB) of data-path creation time (in ms) measured as request -> confirm
  repeated HistogramBucket histogram_ndp_creation_time_ms = 33;

  // statistics for data-path (NDP) creation time (in ms) measured as request -> confirm: minimum
  optional int64 ndp_creation_time_ms_min = 34;

  // statistics for data-path (NDP) creation time (in ms) measured as request -> confirm: maximum
  optional int64 ndp_creation_time_ms_max = 35;

  // statistics for data-path (NDP) creation time (in ms) measured as request -> confirm: sum
  optional int64 ndp_creation_time_ms_sum = 36;

  // statistics for data-path (NDP) creation time (in ms) measured as request -> confirm: sum of sq
  optional int64 ndp_creation_time_ms_sum_of_sq = 37;

  // statistics for data-path (NDP) creation time (in ms) measured as request -> confirm: number of
  // samples
  optional int64 ndp_creation_time_ms_num_samples = 38;

  // total time within the logging window that aware was available
  optional int64 available_time_ms = 39;

  // total time within the logging window that aware was enabled
  optional int64 enabled_time_ms = 40;

  // maximum number of concurrent publish sessions enabling ranging in a single app
  optional int32 max_concurrent_publish_with_ranging_in_app = 41;

  // maximum number of concurrent subscribe sessions specifying a geofence in a single app
  optional int32 max_concurrent_subscribe_with_ranging_in_app = 42;

  // maximum number of concurrent publish sessions enabling ranging in the system
  optional int32 max_concurrent_publish_with_ranging_in_system = 43;

  // maximum number of concurrent subscribe sessions specifying a geofence in the system
  optional int32 max_concurrent_subscribe_with_ranging_in_system = 44;

  // histogram of subscribe session geofence minimum (only when specified)
  repeated HistogramBucket histogram_subscribe_geofence_min = 45;

  // histogram of subscribe session geofence maximum (only when specified)
  repeated HistogramBucket histogram_subscribe_geofence_max = 46;

  // total number of subscribe sessions which enabled ranging
  optional int32 num_subscribes_with_ranging = 47;

  // total number of matches (service discovery indication) with ranging provided
  optional int32 num_matches_with_ranging = 48;

  // total number of matches (service discovery indication) for service discovery with ranging
  // enabled which did not trigger ranging
  optional int32 num_matches_without_ranging_for_ranging_enabled_subscribes = 49;

  // Total number of different types of NDP requests
  repeated NdpRequestTypeHistogramBucket histogram_ndp_request_type = 50;

  // Histogram bucket for Wi-Fi Aware logs. Range is [start, end)
  message HistogramBucket {
    // lower range of the bucket (inclusive)
    optional int64 start = 1;

    // upper range of the bucket (exclusive)
    optional int64 end = 2;

    // number of samples in the bucket
    optional int32 count = 3;
  }

  // Status of various NAN operations
  enum NanStatusTypeEnum {
    // constant to be used by proto
    UNKNOWN = 0;

    // NAN operation succeeded
    SUCCESS = 1;

    // NAN Discovery Engine/Host driver failures
    INTERNAL_FAILURE = 2;

    // NAN OTA failures
    PROTOCOL_FAILURE = 3;

    // The publish/subscribe discovery session id is invalid
    INVALID_SESSION_ID = 4;

    // Out of resources to fufill request
    NO_RESOURCES_AVAILABLE = 5;

    // Invalid arguments passed
    INVALID_ARGS = 6;

    // Invalid peer id
    INVALID_PEER_ID = 7;

    // Invalid NAN data-path (ndp) id
    INVALID_NDP_ID = 8;

    // Attempting to enable NAN when not available, e.g. wifi is disabled
    NAN_NOT_ALLOWED = 9;

    // Over the air ACK not received
    NO_OTA_ACK = 10;

    // Attempting to enable NAN when already enabled
    ALREADY_ENABLED = 11;

    // Can't queue tx followup message foor transmission
    FOLLOWUP_TX_QUEUE_FULL = 12;

    // Unsupported concurrency of NAN and another feature - NAN disabled
    UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 13;

    // Unknown NanStatusType
    UNKNOWN_HAL_STATUS = 14;
  }

  // Histogram bucket for Wi-Fi Aware (NAN) status.
  message NanStatusHistogramBucket {
    // status type defining the bucket
    optional NanStatusTypeEnum nan_status_type = 1;

    // number of samples in the bucket
    optional int32 count = 2;
  }

  enum NdpRequestTypeEnum {
    // Unknown Type
    NETWORK_SPECIFIER_TYPE_UNKNOWN = 0;

    // TYPE: in band, specific peer: role, client_id, session_id, peer_id, pmk/passphrase optional
    NETWORK_SPECIFIER_TYPE_IB = 1;

    // TYPE: in band, any peer: role, client_id, session_id, pmk/passphrase optional
    NETWORK_SPECIFIER_TYPE_IB_ANY_PEER = 2;

    //TYPE: out-of-band: role, client_id, peer_mac, pmk/passphrase optional
    NETWORK_SPECIFIER_TYPE_OOB = 3;

    //TYPE: out-of-band, any peer: role, client_id, pmk/passphrase optional
    NETWORK_SPECIFIER_TYPE_OOB_ANY_PEER = 4;

  }

  message NdpRequestTypeHistogramBucket {
    // request type defining the bucket
    optional NdpRequestTypeEnum ndp_request_type = 1;
    // number of samples in the bucket
    optional int32 count = 2;

  }
}

// Data point used to build 'Number of Connectable Network' histograms
message NumConnectableNetworksBucket {
  // Number of connectable networks seen in a scan result
  optional int32 num_connectable_networks = 1 [default = 0];

  // Number of scan results with num_connectable_networks
  optional int32 count = 2 [default = 0];
}

// Pno scan metrics
// Here "Pno Scan" refers to the session of offloaded scans, these metrics count the result of a
// single session, and not the individual scans within that session.
message PnoScanMetrics {
  // Total number of attempts to offload pno scans
  optional int32 num_pno_scan_attempts = 1;

  // Total number of pno scans failed
  optional int32 num_pno_scan_failed = 2;

  // Number of pno scans started successfully over offload
  optional int32 num_pno_scan_started_over_offload = 3;

  // Number of pno scans failed over offload
  optional int32 num_pno_scan_failed_over_offload = 4;

  // Total number of pno scans that found any network
  optional int32 num_pno_found_network_events = 5;
}

// Number of occurrences for a particular "Connect to Network" Notification or
// notification Action.
message ConnectToNetworkNotificationAndActionCount {

  // "Connect to Network" notifications
  enum Notification {

    // Default
    NOTIFICATION_UNKNOWN = 0;

    // Initial notification with a recommended network.
    NOTIFICATION_RECOMMEND_NETWORK = 1;

    // Notification when connecting to the recommended network.
    NOTIFICATION_CONNECTING_TO_NETWORK = 2;

    // Notification when successfully connected to the network.
    NOTIFICATION_CONNECTED_TO_NETWORK = 3;

    // Notification when failed to connect to network.
    NOTIFICATION_FAILED_TO_CONNECT = 4;
  }

  // "Connect to Network" notification actions
  enum Action {

    // Default
    ACTION_UNKNOWN = 0;

    // User dismissed the "Connect to Network" notification.
    ACTION_USER_DISMISSED_NOTIFICATION = 1;

    // User tapped action button to connect to recommended network.
    ACTION_CONNECT_TO_NETWORK = 2;

    // User tapped action button to open Wi-Fi Settings.
    ACTION_PICK_WIFI_NETWORK = 3;

    // User tapped "Failed to connect" notification to open Wi-Fi Settings.
    ACTION_PICK_WIFI_NETWORK_AFTER_CONNECT_FAILURE = 4;
  }

  // Recommenders of the "Connect to Network" notification
  enum Recommender {

    // Default.
    RECOMMENDER_UNKNOWN = 0;

    // Open Network Available recommender.
    RECOMMENDER_OPEN = 1;
  }

  // Notification Type.
  optional Notification notification = 1;

  // Action Type.
  optional Action action = 2;

  // Recommender Type.
  optional Recommender recommender = 3;

  // Occurrences of this action.
  optional int32 count = 4;
}

// SoftAP event tracking sessions and client counts
message SoftApConnectedClientsEvent {

  // Soft AP event Types
  enum SoftApEventType {

    // Soft AP in single AP mode is Up and ready for use.
    // The sequence of the events in single AP mode:
    // SOFT_AP_UP -> ... (ex:NUM_CLIENTS_CHANGED) -> SOFT_AP_DOWN
    SOFT_AP_UP = 0;

    // Soft AP in single/dual AP mode is Down.
    SOFT_AP_DOWN = 1;

    // Number of connected soft AP clients has changed.
    NUM_CLIENTS_CHANGED = 2;

    // Soft AP in dual AP mode is Up and ready for use.
    // There are two DUAL_AP_BOTH_INSTANCES_UP events in dual AP mode for
    // storing each instance information.
    // The sequence of the events in dual AP mode:
    // DUAL_AP_BOTH_INSTANCES_UP -> DUAL_AP_BOTH_INSTANCES_UP
    // ... (ex: DUAL_AP_ONE_INSTANCE_DOWN or NUM_CLIENTS_CHANGED) -> SOFT_AP_DOWN
    DUAL_AP_BOTH_INSTANCES_UP = 3;

    // One of the dual AP instance is Down.
    DUAL_AP_ONE_INSTANCE_DOWN = 4;
  }

  // Soft AP channel bandwidth types
  enum ChannelBandwidth {

    BANDWIDTH_INVALID = 0;

    BANDWIDTH_20_NOHT = 1;

    BANDWIDTH_20 = 2;

    BANDWIDTH_40 = 3;

    BANDWIDTH_80 = 4;

    BANDWIDTH_80P80 = 5;

    BANDWIDTH_160 = 6;
  }

  // The operational mode  of the Soft AP.
  enum Generation {

    WIFI_STANDARD_UNKNOWN = 0;

    WIFI_STANDARD_LEGACY = 1;

    WIFI_STANDARD_11N = 4;

    WIFI_STANDARD_11AC = 5;

    WIFI_STANDARD_11AX = 6;
  }

  // Type of event being recorded
  optional SoftApEventType event_type = 1;

  // Time passed since last boot in milliseconds
  optional int64 time_stamp_millis = 2;

  // Number of connected clients if event_type is NUM_CLIENTS_CHANGED, otherwise zero.
  optional int32 num_connected_clients = 3;

  // Channel frequency used for Soft AP
  optional int32 channel_frequency = 4;

  // Channel bandwidth used for Soft AP
  optional ChannelBandwidth channel_bandwidth = 5;

  // Maximum number of client setting in SoftApConfiguration
  optional int32 max_num_clients_setting_in_softap_configuration = 6;

  // Maximum number of client setting in SoftApCapability
  optional int32 max_num_clients_setting_in_softap_capability = 7;

  // Auto shutdown timeout setting in SoftApConfiguration
  optional int64 shutdown_timeout_setting_in_softap_configuration = 8;

  // Framework default auto shutdown timeout setting
  optional int64 default_shutdown_timeout_setting = 9;

  // Indicates if user enabled the client_control
  optional bool client_control_is_enabled = 10;

  // The operational mode of the AP
  optional Generation generation = 11;

  // Number of connected clients on current frequency if event_type is NUM_CLIENTS_CHANGED,
  // otherwise zero. On dual AP, it may be different from num_connected_clients
  // because there are two instances and num_connected_clients is used to record
  // total number of the clients. But num_connected_clients_on_current_frequency
  // is used to record the number of the clients on specific instance. (depends
  // on channel_frequency)
  optional int32 num_connected_clients_on_current_frequency = 12;

  // Auto shutdown enabled setting in SoftApConfiguration
  optional bool auto_shutdown_is_enabled = 13;
}

// Power stats for Wifi
message WifiPowerStats {

  // Duration of log (ms)
  optional int64 logging_duration_ms = 1;

  // Energy consumed by wifi (mAh)
  optional double energy_consumed_mah = 2;

  // Amount of time wifi is in idle (ms)
  optional int64 idle_time_ms = 3;

  // Amount of time wifi is in rx (ms)
  optional int64 rx_time_ms = 4;

  // Amount of time wifi is in tx (ms)
  optional int64 tx_time_ms = 5;

  // Amount of time kernel is active because of wifi data (ms)
  optional int64 wifi_kernel_active_time_ms = 6;

  // Number of packets sent (tx)
  optional int64 num_packets_tx = 7;

  // Number of bytes sent (tx)
  optional int64 num_bytes_tx = 8;

  // Number of packets received (rx)
  optional int64 num_packets_rx = 9;

  // Number of bytes sent (rx)
  optional int64 num_bytes_rx = 10;

  // Amount of time wifi is in sleep (ms)
  optional int64 sleep_time_ms = 11;

  // Amount of time wifi is scanning (ms)
  optional int64 scan_time_ms = 12;

  // Actual monitored rail energy consumed by wifi (mAh)
  optional double monitored_rail_energy_consumed_mah = 13;
}

// Metrics for Wifi Wake
message WifiWakeStats {
  // An individual session for Wifi Wake
  message Session {
    // A Wifi Wake lifecycle event
    message Event {
      // Elapsed time in milliseconds since start of session.
      optional int64 elapsed_time_millis = 1;

      // Number of scans that have occurred since start of session.
      optional int32 elapsed_scans = 2;
    }

    // Start time of session in milliseconds.
    optional int64 start_time_millis = 1;

    // The number of networks the lock was provided with at start.
    optional int32 locked_networks_at_start = 2;

    // The number of networks in the lock at the time of the initialize event. Only valid if
    // initialize_event is recorded.
    optional int32 locked_networks_at_initialize = 6;

    // Event for fully initializing the WakeupLock (i.e. WakeupLock is "locked").
    optional Event initialize_event = 7;

    // Event for unlocking the WakeupLock. Does not occur if lock was initialized with 0 networks.
    optional Event unlock_event = 3;

    // Event for triggering wakeup.
    optional Event wakeup_event = 4;

    // Event for WifiWake reset event. This event marks the end of a session.
    optional Event reset_event = 5;
  }

  // Total number of sessions for Wifi Wake.
  optional int32 num_sessions = 1;

  // Session information for every Wifi Wake session (up to a maximum of 10).
  repeated Session sessions = 2;

  // Number of ignored calls to start (due to WakeupController already being active).
  optional int32 num_ignored_starts = 3;

  // Number of Wifi Wake sessions that have recorded wakeup events.
  optional int32 num_wakeups = 4;
}

// Metrics for Wi-Fi RTT
message WifiRttLog {
  // Number of RTT request API calls
  optional int32 num_requests = 1;

  // Histogram of RTT operation overall status
  repeated RttOverallStatusHistogramBucket histogram_overall_status = 2;

  // RTT to Access Points metrics
  optional RttToPeerLog rtt_to_ap = 3;

  // RTT to Wi-Fi Aware peers metrics
  optional RttToPeerLog rtt_to_aware = 4;

  // Histogram of how long a measurement with only AP take.
  repeated HistogramBucket histogram_measurement_duration_ap_only = 5;

  // Histogram of how long a measurement with aware peer included take.
  repeated HistogramBucket histogram_measurement_duration_with_aware = 6;

  // Metrics for a RTT to Peer (peer = AP or Wi-Fi Aware)
  message RttToPeerLog {
    // Total number of API calls
    optional int32 num_requests = 1;

    // Total number of individual requests
    optional int32 num_individual_requests = 2;

    // Total number of apps which requested RTT
    optional int32 num_apps = 3;

    // Histogram of total number of RTT requests by an app (WifiRttManager#startRanging)
    repeated HistogramBucket histogram_num_requests_per_app = 4;

    // Histogram of number of peers in a single RTT request (RangingRequest entries)
    repeated HistogramBucket histogram_num_peers_per_request = 5;

    // Histogram of status of individual RTT operations (RangingResult entries)
    repeated RttIndividualStatusHistogramBucket histogram_individual_status = 6;

    // Histogram of measured distances (RangingResult entries)
    repeated HistogramBucket histogram_distance = 7;

    // Histogram of interval of RTT requests by an app (WifiRttManager#startRanging)
    repeated HistogramBucket histogram_request_interval_ms = 8;
  }

  // Histogram bucket for Wi-Fi RTT logs. Range is [start, end)
  message HistogramBucket {
    // lower range of the bucket (inclusive)
    optional int64 start = 1;

    // upper range of the bucket (exclusive)
    optional int64 end = 2;

    // number of samples in the bucket
    optional int32 count = 3;
  }

  // Status codes for overall RTT operation
  enum RttOverallStatusTypeEnum {
    // constant to be used by proto
    OVERALL_UNKNOWN = 0;

    // RTT operation succeeded (individual results may still fail)
    OVERALL_SUCCESS = 1;

    // RTT operation failed (unspecified reason)
    OVERALL_FAIL = 2;

    // RTT operation failed since RTT was not available (e.g. Airplane mode)
    OVERALL_RTT_NOT_AVAILABLE = 3;

    // RTT operation timed-out: didn't receive response from HAL in expected time
    OVERALL_TIMEOUT = 4;

    // RTT operation aborted since the app is spamming the service
    OVERALL_THROTTLE = 5;

    // RTT request to HAL received immediate failure
    OVERALL_HAL_FAILURE = 6;

    // RTT to Wi-Fi Aware peer using PeerHandle failed to get a MAC address translation
    OVERALL_AWARE_TRANSLATION_FAILURE = 7;

    // RTT operation failed due to missing Location permission (post execution)
    OVERALL_LOCATION_PERMISSION_MISSING = 8;
  }

  // Status codes for individual RTT operation
  enum RttIndividualStatusTypeEnum {
    // constant to be used by proto
    UNKNOWN = 0;

    // RTT operation succeeded
    SUCCESS = 1;

    // RTT failure: generic reason (no further information)
    FAILURE = 2;

    // Target STA does not respond to request
    FAIL_NO_RSP = 3;

    // Request rejected. Applies to 2-sided RTT only
    FAIL_REJECTED = 4;

    // Operation not scheduled
    FAIL_NOT_SCHEDULED_YET = 5;

    // Timing measurement times out
    FAIL_TM_TIMEOUT = 6;

    // Target on different channel, cannot range
    FAIL_AP_ON_DIFF_CHANNEL = 7;

    // Ranging not supported
    FAIL_NO_CAPABILITY = 8;

    // Request aborted for unknown reason
    ABORTED = 9;

    // Invalid T1-T4 timestamp
    FAIL_INVALID_TS = 10;

    // 11mc protocol failed
    FAIL_PROTOCOL = 11;

    // Request could not be scheduled
    FAIL_SCHEDULE = 12;

    // Responder cannot collaborate at time of request
    FAIL_BUSY_TRY_LATER = 13;

    // Bad request args
    INVALID_REQ = 14;

    // WiFi not enabled
    NO_WIFI = 15;

    // Responder overrides param info, cannot range with new params
    FAIL_FTM_PARAM_OVERRIDE = 16;

    // HAL did not provide a result to a framework request
    MISSING_RESULT = 17;
  }

  // Histogram bucket for Wi-Fi RTT overall operation status
  message RttOverallStatusHistogramBucket {
    // status type defining the bucket
    optional RttOverallStatusTypeEnum status_type = 1;

    // number of samples in the bucket
    optional int32 count = 2;
  }

  // Histogram bucket for Wi-Fi RTT individual operation status
  message RttIndividualStatusHistogramBucket {
    // status type defining the bucket
    optional RttIndividualStatusTypeEnum status_type = 1;

    // number of samples in the bucket
    optional int32 count = 2;
  }
}

// Usage data for the wifi radio while device is running on battery.
message WifiRadioUsage {
  // Duration of log (ms)
  optional int64 logging_duration_ms = 1;

  // Total time for which the radio is awake due to scan.
  optional int64 scan_time_ms = 2;
}

message ExperimentValues {
  reserved 1;
  reserved "wifi_is_unusable_logging_enabled";

  // Minimum number of txBad to trigger a data stall
  optional int32 wifi_data_stall_min_tx_bad = 2;

  // Minimum number of txSuccess to trigger a data stall
  // when rxSuccess is 0
  optional int32 wifi_data_stall_min_tx_success_without_rx = 3;

  // Indicates if we are logging LinkSpeedCount in metrics
  optional bool link_speed_counts_logging_enabled = 4;

  // Duration for evaluating Wifi condition to trigger a data stall
  // measured in milliseconds
  optional int32 data_stall_duration_ms = 5;

  // Threshold of Tx throughput below which to trigger a data stall
  // measured in Kbps
  optional int32 data_stall_tx_tput_thr_kbps = 6;

  // Threshold of Rx throughput below which to trigger a data stall
  // measured in Kbps
  optional int32 data_stall_rx_tput_thr_kbps = 7;

  // Threshold of Tx packet error rate above which to trigger a data stall
  // in percentage
  optional int32 data_stall_tx_per_thr = 8;

  // Threshold of CCA level above which to trigger a data stall in percentage
  optional int32 data_stall_cca_level_thr = 9;

  // Health monitor RSSI poll valid time in ms
  optional int32 health_monitor_rssi_poll_valid_time_ms = 10;
}

message BssidBlocklistStats {
  // Distributions of number of blocked BSSIDs filtered out from network selection.
  repeated Int32Count network_selection_filtered_bssid_count = 1;

  // If this is enabled, then network connections in high movement state will be skipped unless
  // we find a candidate BSSID with similar RSSI in 2 scans sufficiently far apart.
  optional bool high_movement_multiple_scans_feature_enabled = 2;

  // Number of times connection is skipped in the high movement state
  // only relevant if high_movement_multiple_scans_feature_enabled=true
  optional int32 num_high_movement_connection_skipped = 3;

  // Number of times connection is initiated in the high movement state
  // only relevant if high_movement_multiple_scans_feature_enabled=true
  optional int32 num_high_movement_connection_started = 4;

  // Histogram corresponding to the number of times BSSIDs are blocked per
  // WifiBlocklistMonitor.FailureReason.
  repeated Int32Count bssid_blocklist_per_reason_count = 5;

  // Histogram corresponding to the number of times WifiConfigurations are blocked per
  // WifiConfiguration.NetworkSelectionStatus.NetworkSelectionDisableReason.
  repeated Int32Count wifi_config_blocklist_per_reason_count = 6;
}

message WifiIsUnusableEvent {
  enum TriggerType {
    // Default/Invalid event
    TYPE_UNKNOWN = 0;

    // There is a data stall from tx failures
    TYPE_DATA_STALL_BAD_TX = 1;

    // There is a data stall from rx failures
    TYPE_DATA_STALL_TX_WITHOUT_RX = 2;

    // There is a data stall from both tx and rx failures
    TYPE_DATA_STALL_BOTH = 3;

    // Firmware generated an alert
    TYPE_FIRMWARE_ALERT = 4;

    // IP Manager lost reachability to network neighbors
    TYPE_IP_REACHABILITY_LOST = 5;
  }

  // What event triggered WifiIsUnusableEvent.
  optional TriggerType type = 1;

  // The timestamp at which this event occurred.
  // Measured in milliseconds that have elapsed since the device booted.
  optional int64 start_time_millis = 2;

  // NetworkAgent score of connected wifi.
  // Defaults to -1 if the score was never set.
  optional int32 last_score = 3 [default = -1];

  // Delta of successfully transmitted (ACKed) unicast data packets
  // between the last two WifiLinkLayerStats.
  optional int64 tx_success_delta = 4;

  // Delta of transmitted unicast data retry packets
  // between the last two WifiLinkLayerStats.
  optional int64 tx_retries_delta = 5;

  // Delta of lost (not ACKed) transmitted unicast data packets
  // between the last two WifiLinkLayerStats.
  optional int64 tx_bad_delta = 6;

  // Delta of received unicast data packets
  // between the last two WifiLinkLayerStats.
  optional int64 rx_success_delta = 7;

  // Time in millisecond between the last two WifiLinkLayerStats.
  optional int64 packet_update_time_delta = 8;

  // The timestamp at which the last WifiLinkLayerStats was updated.
  // Measured in milliseconds that have elapsed since the device booted.
  optional int64 last_link_layer_stats_update_time = 9;

  // Firmware alert code. Only valid when the event was triggered by a firmware alert, otherwise -1.
  optional int32 firmware_alert_code = 10 [default = -1];

  // NetworkAgent wifi usability score of connected wifi.
  // Defaults to -1 if the score was never set.
  optional int32 last_wifi_usability_score = 11 [default = -1];

  // Prediction horizon (in second) of Wifi usability score provided by external
  // system app
  optional int32 last_prediction_horizon_sec = 12 [default = -1];

  // Whether screen status is on when WifiIsUnusableEvent happens.
  optional bool screen_on = 13 [default = false];

  // Number of bytes transmitted across mobile networks since device boot.
  optional int64 mobile_tx_bytes = 14 [default = -1];

  // // Number of bytes received across mobile networks since device boot.
  optional int64 mobile_rx_bytes = 15 [default = -1];

  // Number of bytes transmitted since device boot.
  optional int64 total_tx_bytes = 16 [default = -1];

  // Number of bytes received since device boot.
  optional int64 total_rx_bytes = 17 [default = -1];
}

message PasspointProfileTypeCount {
  enum EapMethod {
    // Unknown Type
    TYPE_UNKNOWN = 0;

    // EAP_TLS (13)
    TYPE_EAP_TLS = 1;

    // EAP_TTLS (21)
    TYPE_EAP_TTLS = 2;

    // EAP_SIM (18)
    TYPE_EAP_SIM = 3;

    // EAP_AKA (23)
    TYPE_EAP_AKA = 4;

    // EAP_AKA_PRIME (50)
    TYPE_EAP_AKA_PRIME = 5;
  }

  // Eap method type set in Passpoint profile
  optional EapMethod eap_method_type = 1;

  // Num of installed Passpoint profile with same eap method
  optional int32 count = 2;
}

message WifiLinkLayerUsageStats {
  // Total logging duration in ms.
  optional int64 logging_duration_ms = 1;

  // Total time the wifi radio is on in ms over the logging duration.
  optional int64 radio_on_time_ms = 2;

  // Total time the wifi radio is doing tx in ms over the logging duration.
  optional int64 radio_tx_time_ms = 3;

  // Total time the wifi radio is doing rx in ms over the logging duration.
  optional int64 radio_rx_time_ms = 4;

  // Total time the wifi radio is scanning in ms over the logging duration.
  optional int64 radio_scan_time_ms = 5;

  // Total time the wifi radio spent doing nan scans in ms over the logging duration.
  optional int64 radio_nan_scan_time_ms = 6;

  // Total time the wifi radio spent doing background scans in ms over the logging duration.
  optional int64 radio_background_scan_time_ms = 7;

  // Total time the wifi radio spent doing roam scans in ms over the logging duration.
  optional int64 radio_roam_scan_time_ms = 8;

  // Total time the wifi radio spent doing pno scans in ms over the logging duration.
  optional int64 radio_pno_scan_time_ms = 9;

  // Total time the wifi radio spent doing hotspot 2.0 scans and GAS exchange
  // in ms over the logging duration.
  optional int64 radio_hs20_scan_time_ms = 10;

  // Radio stats from all the radios
  repeated RadioStats radio_stats = 11;
}

// WifiUsabilityStatsEntry will only be uploaded when its timestamp is within the data capture
// period
message WifiUsabilityStatsEntry {
  // Status codes for link probe status
  enum LinkProbeStatus {
    // Link probe status is unknown
    PROBE_STATUS_UNKNOWN = 0;

    // Link probe is not triggered
    PROBE_STATUS_NO_PROBE = 1;

    // Link probe is triggered and the result is success
    PROBE_STATUS_SUCCESS = 2;

    // Link probe is triggered and the result is failure
    PROBE_STATUS_FAILURE = 3;
  }

  // Codes for cellular data network type
  enum CellularDataNetworkType {
    // Unknown network
    NETWORK_TYPE_UNKNOWN = 0;

    // GSM network
    NETWORK_TYPE_GSM = 1;

    // CDMA network
    NETWORK_TYPE_CDMA = 2;

    // CDMA EVDO network
    NETWORK_TYPE_EVDO_0 = 3;

    // WCDMA network
    NETWORK_TYPE_UMTS = 4;

    // TDSCDMA network
    NETWORK_TYPE_TD_SCDMA = 5;

    // LTE network
    NETWORK_TYPE_LTE = 6;

    // NR network
    NETWORK_TYPE_NR = 7;
  }

  enum CaptureEventType {
    // Unknown event
    CAPTURE_EVENT_TYPE_UNKNOWN = 0;

    // This is a synchronous event
    CAPTURE_EVENT_TYPE_SYNCHRONOUS = 1;

    // RSSI polling turned on
    CAPTURE_EVENT_TYPE_RSSI_POLLING_ENABLED = 2;

    // RSSI polling turned off
    CAPTURE_EVENT_TYPE_RSSI_POLLING_DISABLED = 3;

    // Data sample came from CMD_ONESHOT_RSSI_POLL
    CAPTURE_EVENT_TYPE_ONESHOT_RSSI_POLL = 4;

    // IP reachability lost
    CAPTURE_EVENT_TYPE_IP_REACHABILITY_LOST = 5;

    // IP reachability failure
    CAPTURE_EVENT_TYPE_IP_REACHABILITY_FAILURE = 6;

    // Firmware alert
    CAPTURE_EVENT_TYPE_FIRMWARE_ALERT = 7;
  }

  // Absolute milliseconds from device boot when these stats were sampled
  optional int64 time_stamp_ms = 1;

  // The RSSI at the sample time
  optional int32 rssi = 2;

  // Link speed at the sample time in Mbps
  optional int32 link_speed_mbps = 3;

  // The total number of tx success counted from the last radio chip reset
  optional int64 total_tx_success = 4;

  // The total number of MPDU data packet retries counted from the last radio chip reset
  optional int64 total_tx_retries = 5;

  // The total number of tx bad counted from the last radio chip reset
  optional int64 total_tx_bad = 6;

  // The total number of rx success counted from the last radio chip reset
  optional int64 total_rx_success = 7;

  // The total time the wifi radio is on in ms counted from the last radio chip reset
  optional int64 total_radio_on_time_ms = 8;

  // The total time the wifi radio is doing tx in ms counted from the last radio chip reset
  optional int64 total_radio_tx_time_ms = 9;

  // The total time the wifi radio is doing rx in ms counted from the last radio chip reset
  optional int64 total_radio_rx_time_ms = 10;

  // The total time spent on all types of scans in ms counted from the last radio chip reset
  optional int64 total_scan_time_ms = 11;

  // The total time spent on nan scans in ms counted from the last radio chip reset
  optional int64 total_nan_scan_time_ms = 12;

  // The total time spent on background scans in ms counted from the last radio chip reset
  optional int64 total_background_scan_time_ms = 13;

  // The total time spent on roam scans in ms counted from the last radio chip reset
  optional int64 total_roam_scan_time_ms = 14;

  // The total time spent on pno scans in ms counted from the last radio chip reset
  optional int64 total_pno_scan_time_ms = 15;

  // The total time spent on hotspot2.0 scans and GAS exchange in ms counted from the last radio
  // chip reset
  optional int64 total_hotspot_2_scan_time_ms = 16;

  // Internal framework Wifi score
  optional int32 wifi_score = 17;

  // Wifi usability score provided by external system app
  optional int32 wifi_usability_score = 18;

  // Sequence number from external system app to framework
  optional int32 seq_num_to_framework = 19;

  // The total time CCA is on busy status on the current frequency in ms
  // counted from the last radio chip reset
  optional int64 total_cca_busy_freq_time_ms = 20;

  // The total radio on time of the current frequency from the last radio
  // chip reset
  optional int64 total_radio_on_freq_time_ms = 21;

  // The total number of beacons received from the last radio chip reset
  optional int64 total_beacon_rx = 22;

  // Prediction horizon (in second) of Wifi usability score provided by external
  // system app
  optional int32 prediction_horizon_sec = 23;

  // The link probe status since last stats update
  optional LinkProbeStatus probe_status_since_last_update = 24;

  // The elapsed time of the most recent link probe since last stats update;
  optional int32 probe_elapsed_time_since_last_update_ms = 25;

  // The MCS rate of the most recent link probe since last stats update
  optional int32 probe_mcs_rate_since_last_update = 26;

  // Rx link speed at the sample time in Mbps
  optional int32 rx_link_speed_mbps = 27;

  // Sequence number generated by framework
  optional int32 seq_num_inside_framework = 28;

  // Whether current entry is for the same BSSID on the same frequency compared
  // to last entry
  optional bool is_same_bssid_and_freq = 29;

  // Cellular data network type currently in use on the device for data transmission
  optional CellularDataNetworkType cellular_data_network_type = 30;

  // Cellular signal strength in dBm, NR: CsiRsrp, LTE: Rsrp, WCDMA/TDSCDMA: Rscp,
  // CDMA: Rssi, EVDO: Rssi, GSM: Rssi
  optional int32 cellular_signal_strength_dbm = 31;

  // Cellular signal strength in dB, NR: CsiSinr, LTE: Rsrq, WCDMA: EcNo, TDSCDMA: invalid,
  // CDMA: Ecio, EVDO: SNR, GSM: invalid */
  optional int32 cellular_signal_strength_db = 32;

  // Whether the primary registered cell of current entry is same as that of previous entry
  optional bool is_same_registered_cell = 33;

  // The device mobility state
  optional DeviceMobilityStatePnoScanStats.DeviceMobilityState
          device_mobility_state = 34;

  // Duty cycle of the connection.
  // if this connection is being served using time slicing on a radio with one or more interfaces
  // (i.e MCC), then this field contains the duty cycle assigned to this interface in percent.
  // If no concurrency or not using time slicing during concurrency (i.e SCC or DBS), set to 100.
  optional int32 time_slice_duty_cycle_in_percent = 35;

  // WME data packet contention time statistics for all four categories: BE, BK, VI, VO
  repeated ContentionTimeStats contention_time_stats = 36;

  // The channel utilization ratio (value) in the range of
  // [BssLoad.MIN_CHANNEL_UTILIZATION, BssLoad.MAX_CHANNEL_UTILIZATION], where MIN_CHANNEL_UTILIZATION
  // corresponds to ratio 0%, MAX_CHANNEL_UTILIZATION corresponds to ratio 100%,
  // see {@link com.android.server.wifi.util.InformationElementUtil}
  optional int32 channel_utilization_ratio = 37;

  // Indicate whether current link layer throughput is sufficient, see {@link WifiDataStall#isThroughputSufficient()}.
  optional bool is_throughput_sufficient = 38;

  // Indicate whether Wi-Fi scoring is enabled by the user, see {@link WifiManager#setWifiScoringEnabled(boolean)}.
  optional bool is_wifi_scoring_enabled = 39;

  // Indicate whether Cellular data is available, see {@link WifiDataStall#isCellularDataAvailable()}.
  optional bool is_cellular_data_available = 40;

  // Rate statistics, including number of successful packets, retries, etc.,
  // indexed by preamble, bandwidth, number of spatial streams, MCS.
  repeated RateStats rate_stats = 41;

  // Number of stations associated with current AP.
  optional int32 sta_count = 42;

  // Channel utilization at current AP in the range of [0, 255].
  optional int32 channel_utilization = 43;

  // Link layer radio stats for all the radios
  repeated RadioStats radio_stats = 44;

  // Number of WiFi links.
  optional int32 wifi_link_count = 45;

  // Link layer radio stats for all WiFi links
  repeated LinkStats link_stats = 46;

  // The MLO mode
  // See details in @WifiManager.MloMode
  optional int32 mlo_mode = 47;

  // The number of tx bytes transmitted on current interface
  optional int64 tx_transmitted_bytes = 48;

  // The number of rx bytes transmitted on current interface
  optional int64 rx_transmitted_bytes = 49;

  // The total number of LABEL_BAD event happens
  optional int32 label_bad_event_count = 50;

  // Current WiFi state in framework
  optional int32 wifi_framework_state = 51;

  // Downstream throughput estimation provided by Network Capabilities
  optional int32 is_network_capabilities_downstream_sufficient = 52;

  // Upstream throughput estimation provided by Network Capabilities
  optional int32 is_network_capabilities_upstream_sufficient = 53;

  // Downstream throughput estimation used in Network Selection
  optional int32 is_throughput_predictor_downstream_sufficient = 54;

  // Upstream throughput estimation provided by Network Capabilities
  optional int32 is_throughput_predictor_upstream_sufficient = 55;

  // If bluetooth is connected
  optional bool is_bluetooth_connected = 56;

  // State of UWB adapter. Refers to
  // UwbManager#registerAdapterStateCallback(Executor, AdapterStateCallback)
  optional int32 uwb_adapter_state = 57;

  // Wifi Low Latency mode state
  optional bool is_low_latency_activated = 58;

  // Maximum supported tx link speed in Mbps
  optional int32 max_supported_tx_linkspeed = 59;

  // Maximum supported rx link speed in Mbps
  optional int32 max_supported_rx_linkspeed = 60;

  // Wifi Voip mode state
  optional int32 voip_mode = 61;

  // Device Role of thread. Refers to ThreadNetworkController@DeviceRole
  optional int32 thread_device_role = 62;

  // Capture buffer event type
  optional CaptureEventType capture_event_type = 63;

  // Some capture event types (eg. ip reachability lost) have a code associated
  // with them. This code is stored here.
  optional int32 capture_event_type_subcode = 64;

  optional int32 status_data_stall = 65;

  // If the full data capture is being stored (field isFullCapture is true in the function call
  // WifiManager.storeCapturedData), this field will represent the time offset between this sample
  // and the first sample in the capture buffer. i.e. this field will have the value 0 for the
  // first sample in the capture buffer.
  // If isFullCapture is false, then this field will be the time offset between the capture start
  // time and the timestamp of this sample.
  optional int64 timestamp_offset_ms = 66;
}

message ContentionTimeStats {
  enum AccessCategory {
    // WME Best Effort Access Category
    WME_ACCESS_CATEGORY_BE = 0;

    // WME Background Access Category
    WME_ACCESS_CATEGORY_BK = 1;

    // WME Video Access Category
    WME_ACCESS_CATEGORY_VI = 2;

    // WME Voice Access Category
    WME_ACCESS_CATEGORY_VO = 3;
  }

  // WME access category
  optional AccessCategory access_category = 1;

  // Data packet min contention time in microseconds
  optional int64 contention_time_min_micros = 2;

  // Data packet max contention time in microseconds
  optional int64 contention_time_max_micros = 3;

  // Data packet average contention time in microseconds
  optional int64 contention_time_avg_micros = 4;

  // Number of data packets used for contention statistics
  optional int64 contention_num_samples = 5;
}

message PacketStats {
  enum AccessCategory {
    // WME Best Effort Access Category
    WME_ACCESS_CATEGORY_BE = 0;

    // WME Background Access Category
    WME_ACCESS_CATEGORY_BK = 1;

    // WME Video Access Category
    WME_ACCESS_CATEGORY_VI = 2;

    // WME Voice Access Category
    WME_ACCESS_CATEGORY_VO = 3;
  }

  // WME access category
  optional AccessCategory access_category = 1;

  // The number of tx success counted from the last radio chip reset
  optional int64 tx_success = 2;

  // The number of MPDU data packet retries counted from the last radio chip reset
  optional int64 tx_retries = 3;

  // The number of tx bad counted from the last radio chip reset
  optional int64 tx_bad = 4;

  // The number of rx success counted from the last radio chip reset
  optional int64 rx_success = 5;
}

message RateStats {
  enum WifiPreambleType {
    // Preamble type for IEEE 802.11a/g, IEEE Std 802.11-2020, Section 17
    WIFI_PREAMBLE_OFDM = 0;
    // Preamble type for IEEE 802.11b, IEEE Std 802.11-2020, Section 16
    WIFI_PREAMBLE_CCK = 1;
    // Preamble type for IEEE 802.11n, IEEE Std 802.11-2020, Section 19
    WIFI_PREAMBLE_HT = 2;
    // Preamble type for IEEE 802.11ac, IEEE Std 802.11-2020, Section 21
    WIFI_PREAMBLE_VHT = 3;
    // Preamble type for IEEE 802.11ax, IEEE Std 802.11-2020, Section 27
    WIFI_PREAMBLE_HE = 5;
    // Preamble type for IEEE 802.11be, IEEE Std 802.11-2021, Section 36
    WIFI_PREAMBLE_EHT = 6;
    // Invalid
    WIFI_PREAMBLE_INVALID = -1;
  }

  enum WifiSpatialStreams {
    // Single stream, 1x1
    WIFI_SPATIAL_STREAMS_ONE = 0;
    // Dual streams, 2x2
    WIFI_SPATIAL_STREAMS_TWO = 1;
    // Three streams, 3x3
    WIFI_SPATIAL_STREAMS_THREE = 2;
    // Four streams, 4x4
    WIFI_SPATIAL_STREAMS_FOUR = 3;
    // Invalid
    WIFI_SPATIAL_STREAMS_INVALID = -1;
  }

  enum WifiChannelBandwidth {
    // Channel bandwidth: 20MHz
    WIFI_BANDWIDTH_20_MHZ = 0;
    // Channel bandwidth: 40MHz
    WIFI_BANDWIDTH_40_MHZ = 1;
    // Channel bandwidth: 80MHz
    WIFI_BANDWIDTH_80_MHZ = 2;
    // Channel bandwidth: 160MHz
    WIFI_BANDWIDTH_160_MHZ = 3;
    // Channel bandwidth: 80MHz + 80MHz
    WIFI_BANDWIDTH_80P80_MHZ = 4;
    // Channel bandwidth: 5MHz
    WIFI_BANDWIDTH_5_MHZ = 5;
    // Channel bandwidth: 10MHz
    WIFI_BANDWIDTH_10_MHZ = 6;
    // Channel bandwidth: 320MHz
    WIFI_BANDWIDTH_320_MHZ = 7;
    // Invalid channel bandwidth
    WIFI_BANDWIDTH_INVALID = -1;
  }

  // Preamble information.
  optional WifiPreambleType preamble = 1;

  // Number of spatial streams.
  optional WifiSpatialStreams nss = 2;

  // Bandwidth information.
  optional WifiChannelBandwidth bw = 3;

  // MCS index. OFDM/CCK rate code would be as per IEEE std in the units of 0.5Mbps.
  // HT/VHT/HE: it would be MCS index.
  optional int32 rate_mcs_idx = 4;

  // Bitrate in units of 100 Kbps.
  optional int32 bit_rate_in_kbps = 5;

  // Number of successfully transmitted data packets (ACK received).
  optional int32 tx_mpdu = 6;

  // Number of received data packets.
  optional int32 rx_mpdu = 7;

  // Number of data packet losses (no ACK).
  optional int32 mpdu_lost = 8;

  // Number of data packet retries.
  optional int32 retries = 9;
}

message RadioStats {
  // The Radio ID
  optional int32 radio_id = 1;
  // The total time the wifi radio is on in ms counted from the last radio chip reset
  optional int64 total_radio_on_time_ms = 2;

  // The total time the wifi radio is doing tx in ms counted from the last radio chip reset
  optional int64 total_radio_tx_time_ms = 3;

  // The total time the wifi radio is doing rx in ms counted from the last radio chip reset
  optional int64 total_radio_rx_time_ms = 4;

  // The total time spent on all types of scans in ms counted from the last radio chip reset
  optional int64 total_scan_time_ms = 5;

  // The total time spent on nan scans in ms counted from the last radio chip reset
  optional int64 total_nan_scan_time_ms = 6;

  // The total time spent on background scans in ms counted from the last radio chip reset
  optional int64 total_background_scan_time_ms = 7;

  // The total time spent on roam scans in ms counted from the last radio chip reset
  optional int64 total_roam_scan_time_ms = 8;

  // The total time spent on pno scans in ms counted from the last radio chip reset
  optional int64 total_pno_scan_time_ms = 9;

  // The total time spent on hotspot2.0 scans and GAS exchange in ms counted from the last radio
  // chip reset
  optional int64 total_hotspot_2_scan_time_ms = 10;

  // Time for which the radio is in active tranmission per tx level
  repeated int32 tx_time_ms_per_level = 11;
}

message LinkStats {
  enum LinkState {
    // Chip does not support reporting the state of the link
    LINK_STATE_UNKNOWN = 0;

    // Link has not been in use since last report. It is placed in power save
    LINK_STATE_NOT_IN_USE = 1;

    // Link is in use. In presence of traffic, it is set to be power active.
    LINK_STATE_IN_USE = 2;
  }

  enum WifiChannelBandwidth {
    // Channel bandwidth: 20MHz
    WIFI_BANDWIDTH_20_MHZ = 0;
    // Channel bandwidth: 40MHz
    WIFI_BANDWIDTH_40_MHZ = 1;
    // Channel bandwidth: 80MHz
    WIFI_BANDWIDTH_80_MHZ = 2;
    // Channel bandwidth: 160MHz
    WIFI_BANDWIDTH_160_MHZ = 3;
    // Channel bandwidth: 80MHz + 80MHz
    WIFI_BANDWIDTH_80P80_MHZ = 4;
    // Channel bandwidth: 5MHz
    WIFI_BANDWIDTH_5_MHZ = 5;
    // Channel bandwidth: 10MHz
    WIFI_BANDWIDTH_10_MHZ = 6;
    // Channel bandwidth: 320MHz
    WIFI_BANDWIDTH_320_MHZ = 7;
    // Invalid channel bandwidth
    WIFI_BANDWIDTH_INVALID = -1;
  }

  // The Link ID
  optional int32 link_id = 1;

  // Link state
  optional LinkState state = 2;

  // Identifier of the radio on which link is currently operating
  optional int32 radio_id = 3;

  // Frequency of the link in MHz
  optional int32 frequency_mhz = 4;

  // Number of beacons received from our own AP
  optional int32 beacon_rx = 5;

  // RSSI of management frames
  optional int32 rssi_mgmt = 6;

  // Duty cycle of the link.
  optional int32 time_slice_duty_cycle_in_percent = 7;

  // Overall RSSI from wpa_supplicant signal_poll
  optional int32 rssi = 8;

  // channel width of WiFi link.
  optional WifiChannelBandwidth channel_width = 9;

  // Center frequency (MHz) of first segment.
  optional int32 center_freq_first_seg = 10;

  // Center frequency (MHz) of second segment.
  optional int32 center_freq_second_seg = 11;

  // Total time for which the radio is awake on this channel.
  optional int64 on_time_in_ms = 12;

  // Total time for which CCA is held busy on this channel.
  optional int64 cca_busy_time_in_ms = 13;

  // WME data packet contention time statistics for all four categories: BE, BK, VI, VO
  repeated ContentionTimeStats contention_time_stats = 14;

  // Packet statistics for all four categories: BE, BK, VI, VO
  repeated PacketStats packet_stats = 15;

  // Peer statistics on this WiFi link
  repeated PeerInfo peer_info = 16;

  // List of scan results who have the same freq with current WiFi link
  repeated ScanResultWithSameFreq scan_result_with_same_freq = 17;

  // TX linkspeed in this WiFi link
  optional int32 tx_linkspeed = 18;

  // RX linkspeed in this WiFi link
  optional int32 rx_linkspeed = 19;
}

message PeerInfo {
  // Station count.
  optional int32 sta_count = 1;

  // Channel utilization.
  optional int32 chan_util = 2;

  // Rate statistics, including number of successful packets, retries, etc.,
  // indexed by preamble, bandwidth, number of spatial streams, MCS.
  repeated RateStats rate_stats = 3;
}

message ScanResultWithSameFreq {
  // timestamp in microseconds (since boot) when this result was last seen.
  optional int64 scan_result_timestamp_micros = 1;

  // The detected signal level in dBm
  optional int32 rssi = 2;

  // The center frequency of the primary 20 MHz frequency (in MHz) of the channel
  optional int32 frequency_mhz = 3;
}

message WifiUsabilityStats {
  enum Label {
    // Default label
    LABEL_UNKNOWN = 0;

    // Wifi is usable
    LABEL_GOOD = 1;

    // Wifi is unusable
    LABEL_BAD = 2;
  }

  enum UsabilityStatsTriggerType {
    // Default/Invalid event
    TYPE_UNKNOWN = 0;

    // There is a data stall from tx failures
    TYPE_DATA_STALL_BAD_TX = 1;

    // There is a data stall from rx failures
    TYPE_DATA_STALL_TX_WITHOUT_RX = 2;

    // There is a data stall from both tx and rx failures
    TYPE_DATA_STALL_BOTH = 3;

    // Firmware generated an alert
    TYPE_FIRMWARE_ALERT = 4;

    // IP Manager lost reachability to network neighbors
    TYPE_IP_REACHABILITY_LOST = 5;
  }

  // The current wifi usability state
  optional Label label = 1;

  // The list of timestamped wifi usability stats
  repeated WifiUsabilityStatsEntry stats = 2;

  // What event triggered WifiUsabilityStats.
  optional UsabilityStatsTriggerType trigger_type = 3;

  // Firmware alert code. Only valid when the stats was triggered by a firmware
  // alert, otherwise -1.
  optional int32 firmware_alert_code = 4 [default = -1];

  // Absolute milliseconds from device boot when these stats were sampled
  optional int64 time_stamp_ms = 5;
}

message TrainingData {
  // The list of timestamped wifi usability stats
  repeated WifiUsabilityStatsEntry stats = 1;
}

message WifiUsabilityStatsTraining {
  // Data capture type
  optional int32 data_capture_type = 1;

  // Capture period start timestamp floored to the nearest hour.
  optional int64 capture_start_timestamp_secs = 2;

  optional TrainingData training_data = 3;

  // If isFullCapture is true in the WifiManager.storeCaptureData call, this represents the time
  // offset between the last sample in the capture buffer and the time the capture buffer was
  // stored. If ring buffer is empty (no last sample), we set store_time_offset_ms to 0.
  // If isFullCapture is false, this represents the time between 'capture period stop time' and the
  // time the capture buffer was stored.
  optional int64 store_time_offset_ms = 4;
}

message DeviceMobilityStatePnoScanStats {
  // see WifiManager.DEVICE_MOBILITY_STATE_* constants
  enum DeviceMobilityState {
    // Unknown mobility
    UNKNOWN = 0;

    // High movement
    HIGH_MVMT = 1;

    // Low movement
    LOW_MVMT = 2;

    // Stationary
    STATIONARY = 3;
  }

  // The device mobility state
  optional DeviceMobilityState device_mobility_state = 1;

  // The number of times that this state was entered
  optional int32 num_times_entered_state = 2;

  // The total duration elapsed while in this mobility state, in ms
  optional int64 total_duration_ms = 3;

  // the total duration elapsed while in this mobility state with PNO scans running, in ms
  optional int64 pno_duration_ms = 4;
}

// The information about the Wifi P2p events.
message WifiP2pStats {

  // Group event list tracking sessions and client counts in tethered mode.
  repeated GroupEvent group_event = 1;

  // Session information that gets logged for every Wifi P2p connection.
  repeated P2pConnectionEvent connection_event = 2;

  // Number of persistent group in the user profile.
  optional int32 num_persistent_group = 3;

  // Number of peer scan.
  optional int32 num_total_peer_scans = 4;

  // Number of service scan.
  optional int32 num_total_service_scans = 5;
}

message P2pConnectionEvent {

  enum ConnectionType {

    // fresh new connection.
    CONNECTION_FRESH = 0;

    // reinvoke a group.
    CONNECTION_REINVOKE = 1;

    // create a group with the current device as the group owner locally.
    CONNECTION_LOCAL = 2;

    // create a group or join a group with config.
    CONNECTION_FAST = 3;
  }

  enum ConnectivityLevelFailure {

    // Failure is unknown.
    CLF_UNKNOWN = 0;

    // No failure.
    CLF_NONE = 1;

    // Timeout for current connecting request.
    CLF_TIMEOUT = 2;

    // The connecting request is canceled by the user.
    CLF_CANCEL = 3;

    // Provision discovery failure, e.g. no pin code, timeout, rejected by the peer.
    CLF_PROV_DISC_FAIL = 4;

    // Invitation failure, e.g. rejected by the peer.
    CLF_INVITATION_FAIL = 5;

    // Incoming request is rejected by the user.
    CLF_USER_REJECT = 6;

    // New connection request is issued before ending previous connecting request.
    CLF_NEW_CONNECTION_ATTEMPT = 7;

    // Group has been removed
    CLF_GROUP_REMOVED = 8;

    // Creating group failed
    CLF_CREATE_GROUP_FAILED = 9;
  }

  // WPS method.
  enum WpsMethod {
    // WPS is skipped for Group Reinvoke.
    WPS_NA = -1;

    // Push button configuration.
    WPS_PBC = 0;

    // Display pin method configuration - pin is generated and displayed on device.
    WPS_DISPLAY = 1;

    // Keypad pin method configuration - pin is entered on device.
    WPS_KEYPAD = 2;

    // Label pin method configuration - pin is labelled on device.
    WPS_LABEL = 3;
  }

  enum GroupBand {
    // Unknown band/frequency
    BAND_UNKNOWN = 0;
    // With any band
    BAND_AUTO = 1;
    // With 2G band
    BAND_2G = 2;
    // With 5G band
    BAND_5G = 3;
    // With 6G band
    BAND_6G = 4;
    // With a specific frequency
    BAND_FREQUENCY = 5;
  }

  // Start time of the connection.
  optional int64 start_time_millis = 1;

  // Type of the connection.
  optional ConnectionType connection_type = 2;

  // WPS method.
  optional WpsMethod wps_method = 3 [default = WPS_NA];

  // Duration to connect.
  optional int32 duration_taken_to_connect_millis = 4;

  // Failures that happen at the connectivity layer.
  optional ConnectivityLevelFailure connectivity_level_failure_code = 5;

  // Group role. This could be unknown with connect() call when the WifiConfig doesn't have the
  // credential.
  optional GroupEvent.GroupRole group_role = 6;

  // Group band preference
  optional GroupBand band = 7;

  // Group frequency in MHz if positive. Otherwise, no frequency preference.
  optional int32 frequency_mhz = 8;

  // STA mode channel frequency. 0 means unknown.
  optional int32 sta_frequency_mhz = 9;

  // The uid of the app that initiates the connection.
  optional int32 uid = 10;

  // if the country code is in the world mode
  optional bool is_country_code_world_mode = 11;

  // fallback to negotiation if device receives invitation response status code "information is
  // currently unavailable"
  optional bool fallback_to_negotiation_on_invite_status_info_unavailable = 12;

  // The try count of connection
  optional int32 try_count = 13;

  // The Attribution tag to identify the caller
  optional string attribution_tag = 14;
}

// GroupEvent tracking group information from GroupStarted to GroupRemoved.
message GroupEvent {

  enum GroupRole {

    GROUP_OWNER = 0;

    GROUP_CLIENT = 1;

    GROUP_UNKNOWN = 2;
  }

  // The ID of network in supplicant for this group.
  optional int32 net_id = 1;

  // Start time of the group.
  optional int64 start_time_millis = 2;

  // Channel frequency used for Group.
  optional int32 channel_frequency = 3;

  // Is group owner or group client.
  optional GroupRole group_role = 5;

  // Number of connected clients.
  optional int32 num_connected_clients = 6;

  // Cumulative number of connected clients.
  optional int32 num_cumulative_clients = 7;

  // The session duration.
  optional int32 session_duration_millis = 8;

  // The idle duration. A group without any client is in idle.
  optional int32 idle_duration_millis = 9;
}

// Easy Connect (DPP)
message WifiDppLog {
  reserved 6;

  // Number of Configurator-Initiator requests
  optional int32 num_dpp_configurator_initiator_requests = 1;

  // Number of Enrollee-Initiator requests
  optional int32 num_dpp_enrollee_initiator_requests = 2;

  // Easy Connect (DPP) Enrollee success
  optional int32 num_dpp_enrollee_success = 3;

  // Easy Connect (DPP) Configurator success code bucket
  repeated DppConfiguratorSuccessStatusHistogramBucket dpp_configurator_success_code = 4;

  // Easy Connect (DPP) failure code bucket
  repeated DppFailureStatusHistogramBucket dpp_failure_code = 5;

  // Easy Connect (DPP) operation time bucket
  repeated HistogramBucketInt32 dpp_operation_time = 7;

  // Number of Enrollee-Responder peer devices supporting DPP protocol version 1
  optional int32 num_dpp_r1_capable_enrollee_responder_devices = 8;

  // Number of Enrollee-Responder peer devices supporting DPP protocol version 2
  optional int32 num_dpp_r2_capable_enrollee_responder_devices = 9;

  // Number of Enrollee-Responder incompatible configurations found in DPP R2 compatibility check.
  optional int32 num_dpp_r2_enrollee_responder_incompatible_configuration = 10;

  // Number of Enrollee-Responder requests
  optional int32 num_dpp_enrollee_responder_requests = 11;

  // Number of Enrollee-Responder success
  optional int32 num_dpp_enrollee_responder_success = 12;

  // Histogram bucket for Wi-Fi DPP configurator success
  message DppConfiguratorSuccessStatusHistogramBucket {
    // status type defining the bucket
    optional DppConfiguratorSuccessCode dpp_status_type = 1;

    // number of samples in the bucket
    optional int32 count = 2;
  }

  // Histogram bucket for Wi-Fi DPP failures
  message DppFailureStatusHistogramBucket {
    // status type defining the bucket
    optional DppFailureCode dpp_status_type = 1;

    // number of samples in the bucket
    optional int32 count = 2;
  }

  enum DppConfiguratorSuccessCode {
    // Unknown success code
    EASY_CONNECT_EVENT_SUCCESS_UNKNOWN = 0;

    // Easy Connect Configurator success event: Configuration sent to enrollee
    EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_SENT = 1;

    // Easy Connect Configurator success event: Configuration applied by enrollee
    EASY_CONNECT_EVENT_SUCCESS_CONFIGURATION_APPLIED = 2;
  }

  enum DppFailureCode {
    // Unknown failure
    EASY_CONNECT_EVENT_FAILURE_UNKNOWN = 0;

    // Easy Connect Failure event: Scanned QR code is either not a Easy Connect URI, or the Easy
    // Connect URI has errors.
    EASY_CONNECT_EVENT_FAILURE_INVALID_URI = 1;

    // Easy Connect Failure event: Bootstrapping/Authentication initialization process failure.
    EASY_CONNECT_EVENT_FAILURE_AUTHENTICATION = 2;

    // Easy Connect Failure event: Both devices are implementing the same role and are
    // incompatible.
    EASY_CONNECT_EVENT_FAILURE_NOT_COMPATIBLE = 3;

    // Easy Connect Failure event: Configuration process has failed due to malformed message.
    EASY_CONNECT_EVENT_FAILURE_CONFIGURATION = 4;

    // Easy Connect Failure event: Easy Connect request while in another Easy Connect exchange.
    EASY_CONNECT_EVENT_FAILURE_BUSY = 5;

    // Easy Connect Failure event: No response from the peer.
    EASY_CONNECT_EVENT_FAILURE_TIMEOUT = 6;

    // Easy Connect Failure event: General protocol failure.
    EASY_CONNECT_EVENT_FAILURE_GENERIC = 7;

    // Easy Connect Failure event: Feature or option is not supported.
    EASY_CONNECT_EVENT_FAILURE_NOT_SUPPORTED = 8;

    // Easy Connect Failure event: Invalid network provided to Easy Connect configurator.
    // Network must either be WPA3-Personal (SAE) or WPA2-Personal (PSK).
    EASY_CONNECT_EVENT_FAILURE_INVALID_NETWORK = 9;

    // Easy Connect R2 Failure event: Enrollee cannot find the network.
    EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK = 10;

    // Easy Connect R2 Failure event: Enrollee failed to authenticate with the network.
    EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION = 11;

    // Easy Connect R2 Failure event: Enrollee rejected the configuration.
    EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION = 12;

    // Easy Connect Failure event: System failed to generate DPP URI.
    EASY_CONNECT_EVENT_FAILURE_URI_GENERATION = 13;

    // Easy Connect Failure event: Enrollee didn't scan the network's operating channel.
    EASY_CONNECT_EVENT_FAILURE_ENROLLEE_FAILED_TO_SCAN_NETWORK_CHANNEL = 14;
  }
}

// WifiConfigStore read/write metrics.
message WifiConfigStoreIO {
  // Histogram of config store read durations.
  repeated DurationBucket read_durations = 1;

  // Histogram of config store write durations.
  repeated DurationBucket write_durations = 2;

  // Total Number of instances of write/read duration in this duration bucket.
  message DurationBucket {
    // Bucket covers duration : [range_start_ms, range_end_ms)
    // The (inclusive) lower bound of read/write duration represented by this bucket
    optional int32 range_start_ms = 1;

    // The (exclusive) upper bound of read/write duration represented by this bucket
    optional int32 range_end_ms = 2;

    // Number of read/write durations that fit into this bucket
    optional int32 count = 3;
  }
}

// Histogram bucket counting with int32. Range is [start, end)
message HistogramBucketInt32 {
  // lower range of the bucket (inclusive)
  optional int32 start = 1;

  // upper range of the bucket (exclusive)
  optional int32 end = 2;

  // number of samples in the bucket
  optional int32 count = 3;
}

// Counts occurrences of a int32 key
message Int32Count {
  // the key
  optional int32 key = 1;

  // the count
  optional int32 count = 2;
}

message LinkProbeStats {
  enum LinkProbeFailureReason {
    // unknown reason
    LINK_PROBE_FAILURE_REASON_UNKNOWN = 0;

    // Specified MCS rate when it is unsupported by the driver.
    LINK_PROBE_FAILURE_REASON_MCS_UNSUPPORTED = 1;

    // Driver reported that no ACK was received for the transmitted probe.
    LINK_PROBE_FAILURE_REASON_NO_ACK = 2;

    // Driver failed to report on the status of the transmitted probe within the timeout.
    LINK_PROBE_FAILURE_REASON_TIMEOUT = 3;

    // An existing link probe is in progress.
    LINK_PROBE_FAILURE_REASON_ALREADY_STARTED = 4;
  }

  // Counts the number of failures for each failure reason.
  message LinkProbeFailureReasonCount {
    // The failure reason.
    optional LinkProbeFailureReason failure_reason = 1;

    // The number of occurrences for this failure reason.
    optional int32 count = 2;
  }

  // Counts the number of link probes for each experiment.
  message ExperimentProbeCounts {
    // The experiment ID.
    optional string experiment_id = 1;

    // The number of link probes triggered for this experiment.
    optional int32 probe_count = 2;
  }

  // Counts the occurrences of RSSI values when a link probe succeeds.
  repeated Int32Count success_rssi_counts = 1;

  // Counts the occurrences of RSSI values when a link probe fails.
  repeated Int32Count failure_rssi_counts = 2;

  // Counts the occurrences of Link Speed values when a link probe succeeds.
  repeated Int32Count success_link_speed_counts = 3;

  // Counts the occurrences of Link Speed values when a link probe fails.
  repeated Int32Count failure_link_speed_counts = 4;

  // Histogram for the number of seconds since the last TX success when a link probe succeeds.
  repeated HistogramBucketInt32 success_seconds_since_last_tx_success_histogram = 5;

  // Histogram for the number of seconds since the last TX success when a link probe fails.
  repeated HistogramBucketInt32 failure_seconds_since_last_tx_success_histogram = 6;

  // Histogram for the elapsed time of successful link probes, in ms.
  repeated HistogramBucketInt32 success_elapsed_time_ms_histogram = 7;

  // Counts the occurrences of error codes for failed link probes.
  repeated LinkProbeFailureReasonCount failure_reason_counts = 8;

  // Counts the number of link probes for each experiment.
  repeated ExperimentProbeCounts experiment_probe_counts = 9;
}

// Stores the decisions that were made by a experiment when compared against another experiment
message NetworkSelectionExperimentDecisions {
  // the id of one experiment
  optional int32 experiment1_id = 1;

  // the id of the other experiment
  optional int32 experiment2_id = 2;

  // Counts occurrences of the number of network choices there were when experiment1 makes the
  // same network selection as experiment2.
  // The keys are the number of network choices, and the values are the number of occurrences of
  // this number of network choices when exp1 and exp2 make the same network selection.
  repeated Int32Count same_selection_num_choices_counter = 3;

  // Counts occurrences of the number of network choices there were when experiment1 makes the
  // same network selection as experiment2.
  // The keys are the number of network choices, and the values are the number of occurrences of
  // this number of network choices when exp1 and exp2 make different network selections.
  // Note that it is possible for the network selection to be different even when there only exists
  // a single network choice, since choosing not to connect to that network is a valid choice.
  repeated Int32Count different_selection_num_choices_counter = 4;
}

// NetworkRequest API metrics.
message WifiNetworkRequestApiLog {
  // Number of requests via this API surface.
  optional int32 num_request = 1;

  // Histogram of requests via this API surface to number of networks matched in scan results.
  repeated HistogramBucketInt32 network_match_size_histogram = 2;

  // Number of requests via this API surface that bypassed user approval.
  optional int32 num_user_approval_bypass = 4;

  // Number of requests via this API surface that was rejected by the user.
  optional int32 num_user_reject = 5;

  // Number of unique apps using this API surface.
  optional int32 num_apps = 6;

  // Number of connections on primary iface.
  optional int32 num_connect_on_primary_iface = 7;

  // Number of successful network connection from this API.
  optional int32 num_connect_success_on_primary_iface = 3;

  // Histogram of connection durations in seconds using this API surface.
  repeated HistogramBucketInt32 connection_duration_sec_on_primary_iface_histogram = 8;

  // Number of connections on secondary iface (STA + STA)
  optional int32 num_connect_on_secondary_iface = 9;

  // Number of connection success on secondary iface (STA + STA)
  optional int32 num_connect_success_on_secondary_iface = 10;

  // Histogram of connection durations in seconds on secondary iface using this API surface.
  repeated HistogramBucketInt32 connection_duration_sec_on_secondary_iface_histogram = 11;

  // Number of times there were concurrent connections (STA + STA):
  // - on a primary iface (internet) and
  // - on a secondary iface (using this API surface)
  optional int32 num_concurrent_connection = 12;

  // Histogram of concurrent connection durations in seconds using this API surface (STA + STA).
  repeated HistogramBucketInt32 concurrent_connection_duration_sec_histogram = 13;
}

// NetworkSuggestion API metrics.
message WifiNetworkSuggestionApiLog {
  enum SuggestionAppTypeCode {
    // UNKNOWN type suggestion app.
    TYPE_UNKNOWN = 0;
    // Suggestion app with carrier privilege.
    TYPE_CARRIER_PRIVILEGED = 1;
    // Suggestion app with network provisioning permission(NETWORK_CARRIER_PROVISIONING).
    TYPE_NETWORK_PROVISIONING = 2;
    // Suggestion app without special privilege.
    TYPE_NON_PRIVILEGED = 3;
  }

  message SuggestionAppCount {
    // Suggestion app type.
    optional SuggestionAppTypeCode app_type = 1;
    // Num of app in this type.
    optional int32 count = 2;
  }

  // Number of modifications to their suggestions by apps.
  optional int32 num_modification = 1;

  // Number of successful network connection from app suggestions.
  optional int32 num_connect_success = 2;

  // Number of network connection failures from app suggestions.
  optional int32 num_connect_failure = 3;

  // Histogram for size of the network lists provided by various apps on the device.
  repeated HistogramBucketInt32 network_list_size_histogram = 4;

  // Count of app using suggestion API with different privilege.
  repeated SuggestionAppCount app_count_per_type = 5;

  // Number of user revoke app's permission from settings or disallowed from UI.
  optional int32 user_revoke_app_suggestion_permission = 6;

  // Number of priority groups configured on the device, excluding the default priority group.
  optional int32 num_priority_groups = 7;

  // Number of times when a ScanResult matched more than one suggestions.
  optional int32 num_multiple_suggestions = 8;

  // Number of saved profiles which also have at least one suggestion (for the same network)
  // provisioned on the device.
  optional int32 num_saved_networks_with_configured_suggestion = 9;
}

// WifiLock metrics
message WifiLockStats {
    // Amount of time wifi is actively in HIGH_PERF mode (ms)
    // This means the lock takes effect and the device takes the actions required for this mode
    optional int64 high_perf_active_time_ms = 1;

    // Amount of time wifi is actively in LOW_LATENCY mode (ms)
    // This means the lock takes effect and the device takes the actions required for this mode
    optional int64 low_latency_active_time_ms = 2;

    // Histogram of HIGH_PERF lock acquisition duration (seconds)
    // Note that acquiring the lock does not necessarily mean that device is actively in that mode
    repeated HistogramBucketInt32 high_perf_lock_acq_duration_sec_histogram = 3;

    // Histogram of LOW_LATENCY lock acquisition duration (seconds)
    // Note that acquiring the lock does not necessarily mean that device is actively in that mode
    repeated HistogramBucketInt32 low_latency_lock_acq_duration_sec_histogram = 4;

    // Histogram of HIGH_PERF active session duration (seconds)
    // This means the lock takes effect and the device takes the actions required for this mode
    repeated HistogramBucketInt32 high_perf_active_session_duration_sec_histogram = 5;

    // Histogram of LOW_LATENCY active session duration (seconds)
    // This means the lock takes effect and the device takes the actions required for this mode
    repeated HistogramBucketInt32 low_latency_active_session_duration_sec_histogram = 6;
}

// Stats on number of times Wi-Fi is turned on/off though the WifiManager#setWifiEnabled API
message WifiToggleStats {
  // Number of time Wi-Fi is turned on by privileged apps
  optional int32 num_toggle_on_privileged = 1;

  // Number of time Wi-Fi is turned off by privileged apps
  optional int32 num_toggle_off_privileged = 2;

  // Number of time Wi-Fi is turned on by normal apps
  optional int32 num_toggle_on_normal = 3;

  // Number of time Wi-Fi is turned off by normal apps
  optional int32 num_toggle_off_normal = 4;
}

// Information about the Passpoint provision metrics.
message PasspointProvisionStats {
  enum ProvisionFailureCode {
    // provisioning failure for unknown reason.
    OSU_FAILURE_UNKNOWN = 0;

    // The reason code for Provisioning Failure due to connection failure to OSU AP.
    OSU_FAILURE_AP_CONNECTION = 1;

    // The reason code for invalid server URL address.
    OSU_FAILURE_SERVER_URL_INVALID = 2;

    // The reason code for provisioning failure due to connection failure to the server.
    OSU_FAILURE_SERVER_CONNECTION = 3;

    // The reason code for provisioning failure due to invalid server certificate.
    OSU_FAILURE_SERVER_VALIDATION = 4;

    // The reason code for provisioning failure due to invalid service provider.
    OSU_FAILURE_SERVICE_PROVIDER_VERIFICATION = 5;

    // The reason code for provisioning failure when a provisioning flow is aborted.
    OSU_FAILURE_PROVISIONING_ABORTED = 6;

    // The reason code for provisioning failure when a provisioning flow is not possible.
    OSU_FAILURE_PROVISIONING_NOT_AVAILABLE = 7;

    // The reason code for provisioning failure due to invalid web url format for an OSU web page.
    OSU_FAILURE_INVALID_URL_FORMAT_FOR_OSU = 8;

    // The reason code for provisioning failure when a command received is not the expected command
    // type.
    OSU_FAILURE_UNEXPECTED_COMMAND_TYPE = 9;

    // The reason code for provisioning failure when a SOAP message is not the expected message
    // type.
    OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_TYPE = 10;

    // The reason code for provisioning failure when a SOAP message exchange fails.
    OSU_FAILURE_SOAP_MESSAGE_EXCHANGE = 11;

    // The reason code for provisioning failure when a redirect listener fails to start.
    OSU_FAILURE_START_REDIRECT_LISTENER = 12;

    // The reason code for provisioning failure when a redirect listener timed out to receive a HTTP
    // redirect response.
    OSU_FAILURE_TIMED_OUT_REDIRECT_LISTENER = 13;

    // The reason code for provisioning failure when there is no OSU activity to listen to intent.
    OSU_FAILURE_NO_OSU_ACTIVITY_FOUND = 14;

    // The reason code for provisioning failure when the status of a SOAP message is not the
    // expected message status.
    OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_STATUS = 15;

    // The reason code for provisioning failure when there is no PPS MO.
    OSU_FAILURE_NO_PPS_MO = 16;

    // The reason code for provisioning failure when there is no AAAServerTrustRoot node in a PPS
    // MO.
    OSU_FAILURE_NO_AAA_SERVER_TRUST_ROOT_NODE = 17;

    // The reason code for provisioning failure when there is no TrustRoot node for remediation
    // server in a PPS MO.
    OSU_FAILURE_NO_REMEDIATION_SERVER_TRUST_ROOT_NODE = 18;

    // The reason code for provisioning failure when there is no TrustRoot node for policy server in
    // a PPS MO.
    OSU_FAILURE_NO_POLICY_SERVER_TRUST_ROOT_NODE = 19;

    // The reason code for provisioning failure when failing to retrieve trust root certificates
    // used for validating server certificate for AAA, Remediation and Policy server.
    OSU_FAILURE_RETRIEVE_TRUST_ROOT_CERTIFICATES = 20;

    // The reason code for provisioning failure when there is no trust root certificate for AAA
    // server.
    OSU_FAILURE_NO_AAA_TRUST_ROOT_CERTIFICATE = 21;

    // The reason code for provisioning failure when a {@link PasspointConfiguration} is failed to
    // install.
    OSU_FAILURE_ADD_PASSPOINT_CONFIGURATION = 22;

    // The reason code for provisioning failure when an {@link OsuProvider} is not found for
    // provisioning.
    OSU_FAILURE_OSU_PROVIDER_NOT_FOUND = 23;
  }

  // Number of passpoint provisioning success
  optional int32 num_provision_success = 1;

  // Count for passpoint provisioning failure
  repeated ProvisionFailureCount provision_failure_count = 2;

  // Number of occurrences of a specific passpoint provision failure code
  message ProvisionFailureCount {
    // Failure code
    optional ProvisionFailureCode failure_code = 1;

    // Number of failure for the failure_code.
    optional int32 count = 2;
  }
}

// Counts number of networks on the device that are metered.
message MeteredNetworkStats {
  // Number of networks that are set or detected as metered.
  optional int32 num_metered = 1 [default = 0];

  // Number of networks that are set or detected as unmetered.
  optional int32 num_unmetered = 2;

  // Number of networks that have meteredOverride set to metered.
  optional int32 num_override_metered = 3;

  // Number of networks that have meteredOverride set to unmetered.
  optional int32 num_override_unmetered = 4;
}

// An event capturing user action on wifi
message UserActionEvent {
  enum EventType {
    // The default and unused event
    EVENT_UNKNOWN = 0;
    // User forgets the network
    EVENT_FORGET_WIFI = 1;
    // User manually triggers disconnect
    EVENT_DISCONNECT_WIFI = 2;
    // User changes the metered setting to "metered"
    EVENT_CONFIGURE_METERED_STATUS_METERED = 3;
    // User changes the metered setting to "unmetered"
    EVENT_CONFIGURE_METERED_STATUS_UNMETERED = 4;
    // User changes the mac randomization setting to use random MAC
    EVENT_CONFIGURE_MAC_RANDOMIZATION_ON = 5;
    // User changes the mac randomization setting to use factory MAC
    EVENT_CONFIGURE_MAC_RANDOMIZATION_OFF = 6;
    // User sets auto-connect to on
    EVENT_CONFIGURE_AUTO_CONNECT_ON = 7;
    // User sets auto-connect to off
    EVENT_CONFIGURE_AUTO_CONNECT_OFF = 8;
    // User toggles wifi on
    EVENT_TOGGLE_WIFI_ON = 9;
    // User toggles wifi off
    EVENT_TOGGLE_WIFI_OFF = 10;
    // User manually connects to a network
    EVENT_MANUAL_CONNECT = 11;
    // User changes the metered setting to "detect automatically"
    EVENT_CONFIGURE_METERED_STATUS_AUTO = 12;
    // User adds a new network or updates configurations for an existing network.
    EVENT_ADD_OR_UPDATE_NETWORK = 13;
    // User sets the adaptive connectivity to on
    EVENT_CONFIGURE_ADAPTIVE_CONNECTIVITY_ON = 14;
    // User sets the adaptive connectivity to off
    EVENT_CONFIGURE_ADAPTIVE_CONNECTIVITY_OFF = 15;
    // User restarts wifi subsystem
    EVENT_RESTART_WIFI_SUB_SYSTEM = 16;
  }

  // The type of user action
  optional EventType event_type = 1;

  // The start time of the event in milliseconds since boot.
  optional int64 start_time_millis = 2;

  // Additional information on the target network for the action. This is not applicable and will
  // be null for some actions such as EVENT_TOGGLE_WIFI_ON.
  optional TargetNetworkInfo target_network_info = 3;

  // Information about the currently connected network.
  optional WifiStatus wifi_status = 4;

  // Reasons why the network applicable for this user action is disabled.
  // Normally this should be referring to the currently connected network.
  // For a manual connection, this is referring to the user selected networks.
  optional NetworkDisableReason network_disable_reason = 5;
}

message WifiStatus {
  // Wifi is connected.
  optional bool is_connected = 1;

  // Wifi is validated
  optional bool is_validated = 2;

  // The last observed RSSI
  optional sint32 last_rssi = 3;

  // Estimated TX
  optional int32 estimated_tx_kbps = 4;

  // Estimated RX
  optional int32 estimated_rx_kbps = 5;

  // There is another candidate with better score, but user connect choice is preventing the switch.
  optional bool is_stuck_due_to_user_connect_choice = 6;
}

// Additional information on a network
message TargetNetworkInfo {
  // Whether the network is an ephemeral network.
  optional bool is_ephemeral = 1;

  // Whether the target is a passpoint network.
  optional bool is_passpoint = 2;
}

// Reasons why a configuration or BSSID is disabled.
message NetworkDisableReason {
  enum DisableReason {
    // Default value, should not be used.
    REASON_UNKNOWN = 0;
    // AP unable to accept more clients, a special kind of association rejection failure.
    REASON_AP_UNABLE_TO_HANDLE_NEW_STA = 1;
    // No internet
    REASON_NETWORK_VALIDATION_FAILURE = 2;
    // Password is incorrect, a special kind of authentication failure.
    REASON_WRONG_PASSWORD = 3;
    // Incorrect EAP credentials.
    REASON_EAP_FAILURE = 4;
    // Other association rejection failures.
    REASON_ASSOCIATION_REJECTION = 5;
    // Associated timeout failures.
    REASON_ASSOCIATION_TIMEOUT = 6;
    // Other authentication failures.
    REASON_AUTHENTICATION_FAILURE = 7;
    // DHCP failures.
    REASON_DHCP_FAILURE = 8;
    // Device disconnected shortly after connection.
    REASON_ABNORMAL_DISCONNECT = 9;
    // AP initiated disconnect for a given duration.
    REASON_FRAMEWORK_DISCONNECT_MBO_OCE = 10;
    // Avoid connecting to the failed AP when trying to reconnect on other available candidates.
    REASON_FRAMEWORK_DISCONNECT_FAST_RECONNECT = 11;
    // The connected scorer has disconnected this network.
    REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE = 12;
    // The network is disabled due to absence of user credentials
    REASON_AUTHENTICATION_NO_CREDENTIALS = 13;
    // The network is disabled because service is not subscribed, a special kind of EAP failure.
    REASON_AUTHENTICATION_NO_SUBSCRIPTION = 14;
    // User disabled auto-join for this network.
    REASON_AUTO_JOIN_DISABLED = 15;
  }

  // The reason for disabling a network.
  optional DisableReason disable_reason = 1;

  // The configuration is temporarily disabled.
  optional bool config_temporarily_disabled = 2;

  // The configuration is disabled until the user manually re-enables it.
  optional bool config_permanently_disabled = 3;

  // Reasons why 1 or more BSSIDs are temporarily disabled.
  repeated DisableReason bssid_disable_reasons = 4;
}

// Number of networks with a large change of connection/disconnection
// failure rate or high failure rate at high RSSI
message HealthMonitorFailureStats {
  // Number of networks with a large change of (or high) association rejection rate
  optional int32 cnt_assoc_rejection = 1;
  // Number of networks with a large change of (or high) association timeout rate
  optional int32 cnt_assoc_timeout = 2;
  // Number of networks with a large change of (or high) auth failure rate
  optional int32 cnt_auth_failure = 3;
  // Number of networks with a large change of (or high) connection failure rate
  optional int32 cnt_connection_failure = 4;
  // Number of networks with a large change of (or high) nonlocal disconnection rate
  optional int32 cnt_disconnection_nonlocal = 5;
  // Number of networks with a large change of (or high) short disconnection rate
  optional int32 cnt_short_connection_nonlocal = 6;
  // Number of networks with a large change of (or high) disconnection-during-connecting rate
  optional int32 cnt_disconnection_nonlocal_connecting = 7;
}

// Metrics collected by health monitor
message HealthMonitorMetrics {
  // Number of networks with a large increase (compared to stats of previous build) of
  // connection/disconnection failure rate
  optional HealthMonitorFailureStats failure_stats_increase = 1;
  // Number of networks with a large decrease (compared to stats of previous build) of
  // connection/disconnection failure rate
  optional HealthMonitorFailureStats failure_stats_decrease = 2;
  // Number of networks with high connection/disconnection failure rate for
  // current build but without sufficient connection attempts for previous build
  optional HealthMonitorFailureStats failure_stats_high = 3;
  // Number of networks with sufficient connection attempts for current build
  // but without suffcient connection attempts for previous build
  optional int32 num_network_sufficient_recent_stats_only = 4;
  // Number of networks with sufficient connection attempts for both current and previous builds
  optional int32 num_network_sufficient_recent_prev_stats = 5;
}

// Connection duration statistics collected under various health conditions
// while Wifi link layer stats report are on
message ConnectionDurationStats {
  // Total time with sufficient Wifi throughput and with cellular data on
  optional int32 total_time_sufficient_throughput_ms = 1;
  // Total time with insufficient Wifi throughput and with cellular data on
  optional int32 total_time_insufficient_throughput_ms = 2;
  // Total time with cellular data off
  optional int32 total_time_cellular_data_off_ms = 3;
  // Total time with insufficient Wifi throughput and with cellular data on
  // while wifi is the default network
  optional int32 total_time_insufficient_throughput_default_wifi_ms = 4;
}

// Wi-Fi off metrics
// Keeps track of Wi-Fi off stats
message WifiOffMetrics {
  // Total number of Wi-Fi off
  optional int32 num_wifi_off = 1;

  // Total number of Wi-Fi off with deferring
  optional int32 num_wifi_off_deferring = 2;

  // Total number of Wi-Fi off deferring timeout
  optional int32 num_wifi_off_deferring_timeout = 3;

  // Histogram of wifi off deferring time
  repeated Int32Count wifi_off_deferring_time_histogram = 4;
}

// SoftAp Config  Limitation Metrics
message SoftApConfigLimitationMetrics {
  // Total number of softap security configuration reset to default because
  // hardware limitation when restore configuration from cloud
  optional int32 num_security_type_reset_to_default = 1;

  // Total number of softap max client setting reset to default because
  // hardware limitation when restore configuration from cloud
  optional int32 num_max_client_setting_reset_to_default = 2;

  // Total number of softap client control by user reset to default because
  // hardware limitation when restore configuration from cloud
  optional int32 num_client_control_by_user_reset_to_default = 3;

  // Histogram of max client count when client connection fail because
  // setting limitation
  repeated Int32Count max_client_setting_when_reach_histogram = 4;
}

// Channel utilization histogram
// The valid utilization range is between 0 and 255 corresponding to
// utilization ratio between 0 and 1
message ChannelUtilizationHistogram {
  // Histogram at 2G
  repeated HistogramBucketInt32 utilization_2g = 1;
  // Histogram above 2G
  repeated HistogramBucketInt32 utilization_above_2g = 2;
}

// Throughput histogram
message ThroughputMbpsHistogram {
  // Tx histogram at 2G
  repeated HistogramBucketInt32 tx_2g = 1;
  // Tx histogram above 2G
  repeated HistogramBucketInt32 tx_above_2g = 2;
  // Rx histogram at 2G
  repeated HistogramBucketInt32 rx_2g = 3;
  // Rx histogram above 2G
  repeated HistogramBucketInt32 rx_above_2g = 4;
}

// Initial Partial Scan stats
message InitPartialScanStats {
  // Total number of partial scans
  optional int32 num_scans = 1;

  // Number of instances a partial scan results in finding a network
  optional int32 num_success_scans = 2;

  // Number of instances a patial scan does not result in finding a network
  // and a follow up full scan finds a network.
  optional int32 num_failure_scans = 3;

  // Histogram of number of channels used in a successful partial scan
  repeated HistogramBucketInt32 successful_scan_channel_count_histogram = 4;

  // Histogram of number of channels used in a failed partial scan
  repeated HistogramBucketInt32 failed_scan_channel_count_histogram = 5;
}

// User reaction to the carrier IMSI protection exemption UI
message UserReactionToApprovalUiEvent {
  enum UserActionCode {
    // UNKNOWN user action.
    ACTION_UNKNOWN = 0;
    // Action user allowed.
    ACTION_ALLOWED = 1;
    // Action user disallowed.
    ACTION_DISALLOWED = 2;
    // Action user dismiss.
    ACTION_DISMISS = 3;
  }
  message UserReaction {
    // User action to the UI.
    optional UserActionCode user_action = 1;
    // Is UI a dialog or notification.
    optional bool is_dialog = 2;
  }

  // Event of user reaction to the app approval UI.
  repeated UserReaction user_approval_app_ui_reaction = 1;

  // Event of user reaction to the carrier approval UI.
  repeated UserReaction user_approval_carrier_ui_reaction = 2;
}

message CarrierWifiMetrics {
  // Number of successful network connection using Carrier ID
  optional int32 num_connection_success = 1;
  // Number of failed authentication from network connection using Carrier ID
  optional int32 num_connection_auth_failure = 2;
  optional int32 num_connection_non_auth_failure = 3;
}

message FirstConnectAfterBootStats {
  message Attempt {
    // The attempt completion timestamp, in milliseconds since boot.
    optional int64 timestamp_since_boot_millis = 1;

    // whether the attempt was successful.
    optional bool is_success = 2;
  }

  // Info about whether Wifi was enabled at boot time.
  // `is_success` is true if Wifi is toggled ON at boot, false otherwise.
  // This field will never be null.
  optional Attempt wifi_enabled_at_boot = 1;

  // Info about the first network selection attempt for auto-join.
  // `is_success` is true if a network candidate was found, false otherwise.
  // This field is null if `wifi_enabled_at_boot.is_success` is false.
  optional Attempt first_network_selection = 2;

  // Info about the first successful L2 connection.
  // `is_success` is true if the L2 connection was successfully established, false otherwise.
  // This field is null if `first_network_selection.is_success` is false.
  optional Attempt first_l2_connection = 3;

  // Info about the first successful L3 connection.
  // `is_success` is true if the L3 connection was successfully established, false otherwise.
  // This field is null if `first_l2_connection.is_success` is false.
  optional Attempt first_l3_connection = 4;
}

// Stats for Autojoin switches between Wifi networks. Does not include user/app-initiated switches.
message WifiToWifiSwitchStats {
  // Whether Make Before Break is supported by the hardware and enabled.
  optional bool is_make_before_break_supported = 1;

  // Number of times Wifi to Wifi switch was triggered. This includes Make Before Break and Break
  // Before Make.
  optional int32 wifi_to_wifi_switch_trigger_count = 2;

  // Number of times Wifi to Wifi switch was triggered using Make Before Break (MBB).
  // Note that MBB may not always be used for various reasons e.g. no additional iface available due
  // to ongoing SoftAP, both old and new network have MAC randomization disabled, etc.
  // TODO(b/180974604): also add metrics for the various reasons to not use MBB even when it is
  //  supported by the device.
  optional int32 make_before_break_trigger_count = 3;

  // TODO(b/180974604): add metrics for L2 failure and L3 failure

  // Number of times Make Before Break was aborted due to the new network not having internet.
  optional int32 make_before_break_no_internet_count = 4;

  // Number of times where, for some reason, Make Before Break resulted in the loss of the primary
  // ClientModeManager, and we needed to recover by making one of the SECONDARY_TRANSIENT
  // ClientModeManagers primary.
  optional int32 make_before_break_recover_primary_count = 5;

  // Number of times the new network in Make Before Break had its internet connection validated.
  optional int32 make_before_break_internet_validated_count = 6;

  // Number of times the new network was made primary in Make Before Break.
  // TODO(b/180974604): add metrics for the various ways this could fail.
  optional int32 make_before_break_success_count = 7;

  // Number of times the old network in Make Before Break completed lingering and was disconnected.
  optional int32 make_before_break_linger_completed_count = 8;

  // Histogram of lingering duration caused by make before break in seconds.
  repeated Int32Count make_before_break_linger_duration_seconds = 9;
}

// Network layer bandwidth estimator stats
message BandwidthEstimatorStats {
  // Bandwidth stats of each signal level
  message PerLevel {
    // Signal level derived by RssiUtil.calculateSignalLevel based on RSSI
    optional uint32 signal_level = 1;
    // Accumulated bandwidth sample count
    optional uint32 count = 2;
    // Average network layer bandwidth in kbps based on TrafficStats byte count and radio on time
    // of link layer stats.
    optional uint32 avg_bandwidth_kbps = 3;
    // Error of layer 2 link bandwidth in percent
    optional uint32 l2_error_percent = 4;
    // Error of network layer bandwidth estimation in percent
    optional uint32 bandwidth_est_error_percent = 5;
  }

  // Bandwidth stats of each link
  message PerLink {
    repeated PerLevel level = 1;
  }

  // Bandwidth stats of each band
  message PerBand {
    // Tx bandwidth stats
    optional PerLink tx = 1;
    // Rx bandwidth stats
    optional PerLink rx = 2;
  }

  // Stats of 2g band
  optional PerBand stats_2g = 1;
  // Stats of above-2g band
  optional PerBand stats_above_2g = 2;
}

