/*
 * Copyright (C) 2023 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 android.os.statsd.telephony;

import "frameworks/proto_logging/stats/atom_field_options.proto";
import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/enums/telephony/enums.proto";
import "frameworks/proto_logging/stats/enums/telephony/satellite/enums.proto";

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

extend Atom {
  optional SatelliteController satellite_controller = 10182
  [(module) = "telephony"];
  optional SatelliteSession satellite_session = 10183
  [(module) = "telephony"];
  optional SatelliteIncomingDatagram satellite_incoming_datagram = 10184
  [(module) = "telephony"];
  optional SatelliteOutgoingDatagram satellite_outgoing_datagram = 10185
  [(module) = "telephony"];
  optional SatelliteProvision satellite_provision = 10186
  [(module) = "telephony"];
  optional SatelliteSosMessageRecommender satellite_sos_message_recommender = 10187
  [(module) = "telephony"];
  optional CarrierRoamingSatelliteSession carrier_roaming_satellite_session = 10211
  [(module) = "telephony"];
  optional CarrierRoamingSatelliteControllerStats carrier_roaming_satellite_controller_stats = 10212
  [(module) = "telephony"];
  optional ControllerStatsPerPackage controller_stats_per_package = 10213
  [(module) = "telephony"];
  optional SatelliteEntitlement satellite_entitlement = 10214
  [(module) = "telephony"];
  optional SatelliteConfigUpdater satellite_config_updater = 10215
  [(module) = "telephony"];
  optional SatelliteAccessController satellite_access_controller = 10219
  [(module) = "telephony"];
}

/**
 * One data point of this metric is logged per day if the satellite is enabled
 * or provisioned/deprovisioned at least once
 */
message SatelliteController {
  // Total count of successful attempts for turning on satellite service.
  optional int32 count_of_satellite_service_enablements_success = 1;
  // Total count of failed attempts for turning on satellite service.
  optional int32 count_of_satellite_service_enablements_fail = 2;
  // Total count of successful attempt for outgoing datagrams.
  optional int32 count_of_outgoing_datagram_success = 3;
  // Total count of failed attempts for outgoing datagrams.
  optional int32 count_of_outgoing_datagram_fail = 4;
  // Total count of successful attempt for incoming datagrams.
  optional int32 count_of_incoming_datagram_success = 5;
  // Total count of failed attempts for incoming datagrams.
  optional int32 count_of_incoming_datagram_fail = 6;
  // Total count of successful attempts for transferring SOS SMS.
  optional int32 count_of_datagram_type_sos_sms_success = 7;
  // Total count of failed attempts for transferring SOS SMS.
  optional int32 count_of_datagram_type_sos_sms_fail = 8;
  // Total count of successful attempts for transferring location sharing.
  optional int32 count_of_datagram_type_location_sharing_success = 9;
  // Total count of failed attempts for transferring location sharing.
  optional int32 count_of_datagram_type_location_sharing_fail = 10;
  // Total count of successful attempt for provisioning.
  optional int32 count_of_provision_success = 11;
  // Total count of failed attempts for provisioning.
  optional int32 count_of_provision_fail = 12;
  // Total count of successful attempts for deprovisioning.
  optional int32 count_of_deprovision_success = 13;
  // Total count of failed attempts for deprovisioning.
  optional int32 count_of_deprovision_fail = 14;
  // The sum of all duration from the satellite is turned on until it is turned off in seconds.
  optional int32 total_service_uptime_sec = 15;
  // The amount of battery consumption, while the satellite state is on.
  // excluded while in charging state rounded to percent.
  optional int32 total_battery_consumption_percent = 16;
  // The total duration of the battery being charged while satellite modem is on
  optional int32 total_battery_charged_time_sec = 17;
  // Count of successful satellite service enablement in demo mode
  // Demo mode is a service that allows users to practise in a safe environment,
  // considering that the first use of the satellite service is likely to be in
  // an emergency.
  optional int32 count_of_demo_mode_satellite_service_enablements_success = 18;
  // Count of failed satellite service enablement in demo mode
  optional int32 count_of_demo_mode_satellite_service_enablements_fail = 19;
  // Total count of successful outgoing datagrams in demo mode.
  optional int32 count_of_demo_mode_outgoing_datagram_success = 20;
  // Total count of failed attempts for outgoing datagrams in demo mode.
  optional int32 count_of_demo_mode_outgoing_datagram_fail = 21;
  // Total count of successful incoming datagrams in demo mode.
  optional int32 count_of_demo_mode_incoming_datagram_success = 22;
  // Total count of failed attempts for incoming datagrams in demo mode.
  optional int32 count_of_demo_mode_incoming_datagram_fail = 23;
  // Total count of successful DATAGRAM_TYPE_KEEP_ALIVE request.
  optional int32 count_of_datagram_type_keep_alive_success = 24;
  // Total count of failed DATAGRAM_TYPE_KEEP_ALIVE request.
  optional int32 count_of_datagram_type_keep_alive_fail = 25;
  // Total count of allowed satellite access.
  optional int32 count_of_allowed_satellite_access = 26;
  // Total count of disallowed satellite access.
  optional int32 count_of_disallowed_satellite_access = 27;
  // Total count of failed checking event for satellite access.
  optional int32 count_of_satellite_access_check_fail = 28;
  // Whether this device is provisioned or not.
  optional bool is_provisioned = 29;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 30;
  // Count of satellite allowed state changed events
  optional int32 count_of_satellite_allowed_state_changed_events = 31;
  // Count of successful location queries
  optional int32 count_of_successful_location_queries = 32;
  // Count of failed location queries
  optional int32 count_of_failed_location_queries = 33;
  // Number of times the notification indicating P2P SMS availability was shown.
  optional int32 count_of_p2p_sms_available_notification_shown = 34;
  // Number of times the notification indicating P2P SMS availability was removed.
  optional int32 count_of_p2p_sms_available_notification_removed = 35;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 36;
  // Version of satellite access config data.
  optional int32 version_of_satellite_access_config = 37;
  // Total count of successful attempts for receiving SOS SMS.
  optional int32 count_of_incoming_datagram_type_sos_sms_success = 38;
  // Total count of failed attempts for receiving SOS SMS.
  optional int32 count_of_incoming_datagram_type_sos_sms_fail = 39;
  // Total count of successful attempts for transferring P2P SMS.
  optional int32 count_of_outgoing_datagram_type_sms_success = 40;
  // Total count of failed attempts for transferring P2P SMS.
  optional int32 count_of_outgoing_datagram_type_sms_fail = 41;
  // Total count of successful attempts for receiving P2P SMS.
  optional int32 count_of_incoming_datagram_type_sms_success = 42;
  // Total count of failed attempts for receiving P2P SMS.
  optional int32 count_of_incoming_datagram_type_sms_fail = 43;
  // Version of carrier roaming satellite config data.
  optional int32 carrier_roaming_satellite_config_version = 44;
  // Max allowed data mode for satellite data.
  optional int32 max_allowed_data_mode = 45;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 46;
}

/**
 * One data point of this metric is logged per satellite enablement
 */
message SatelliteSession {
  // The result for satellite modem initialization.
  optional android.telephony.SatelliteError satellite_service_initialization_result = 1;
  // Satellite technology to datagram transfer.
  optional android.telephony.NTRadioTechnology satellite_technology = 2;
  // Total count of times this event has occurred.
  optional int32 count = 3;
  // The result for satellite service disablement
  // set as dimension
  optional android.telephony.SatelliteError satellite_service_termination_result = 4;
  // the processing time to enable satellite session
  optional int64 initialization_processing_time_millis = 5;
  // the processing time to disable satellite session
  optional int64 termination_processing_time_millis = 6;
  // the duration from the satellite service is enabled to satellite is disabled
  optional int32 session_duration_seconds = 7;
  // the number of successful outgoing datagram transmission while the session is enabled
  optional int32 count_of_outgoing_datagram_success = 8;
  // the number of failed outgoing datagram transmission while the session is enabled
  optional int32 count_of_outgoing_datagram_failed = 9;
  // the number of successful incoming datagram transmission while the session is enabled
  optional int32 count_of_incoming_datagram_success = 10;
  // the number of failed incoming datagram transmission while the session is enabled
  optional int32 count_of_incoming_datagram_failed = 11;
  // Whether this session is enabled for demo mode, code {true} if it is demo mode
  // Demo mode is a service that allows users to practise in a safe environment,
  // considering that the first use of the satellite service is likely to be in
  // an emergency.
  optional bool is_demo_mode = 12;
  // Max Ntn signal strength while the satellite session is enabled
  optional int32 max_ntn_signal_strength_level = 13;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 14;
  // Total number of times the user is notified that the device is eligible for satellite service
  optional int32 count_of_satellite_notification_displayed = 15;
  // Total number of times exit P2P message service automatically due to screen is off and timer is expired
  optional int32 count_of_auto_exit_due_to_screen_off = 16;
  // Total number of times exit P2P message service automatically when a TN network is detected during idle scanning mode
  optional int32 count_of_auto_exit_due_to_tn_network = 17;
  // Whether this session is enabled for emergency.
  optional bool is_emergency = 18;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 19;
  // Max user inactivity duration in seconds
  optional int32 max_inactivity_duration_sec = 20;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 21;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 22;
}

/**
 * Snapshot of satellite incoming datagram
 */
message SatelliteIncomingDatagram {
  // Return code in receiving the datagram.
  optional android.telephony.SatelliteError result_code = 1;
  // The size of the datagram in bytes.
  optional int32 datagram_size_bytes = 2;
  // The amount of time took to receive the datagram.
  optional int64 datagram_transfer_time_millis = 3;
  // Whether it is transferred in demo mode or not. if true, transferred in demo mode.
  // Demo mode is a service that allows users to practise in a safe environment,
  // considering that the first use of the satellite service is likely to be in
  // an emergency.
  optional bool is_demo_mode = 4;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 5;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 6;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 7;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 8;
}

/**
 * Snapshot of satellite outgoing datagram
 */
message SatelliteOutgoingDatagram {
  // Feature type of datagram.
  optional android.telephony.DatagramType satellite_datagram_type = 1;
  // Return code in sending the datagram.
  optional android.telephony.SatelliteError result_code = 2;
  // The size of the datagram in bytes.
  optional int32 datagram_size_bytes = 3;
  // The amount of time took to send the datagram.
  optional int64 datagram_transfer_time_millis = 4;
  // Whether it is transferred in demo mode or not. if true, transferred in demo mode.
  // Demo mode is a service that allows users to practise in a safe environment,
  // considering that the first use of the satellite service is likely to be in
  // an emergency.
  optional bool is_demo_mode = 5;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 6;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 7;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 8;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 9;
}

/**
 * Stats about the provision/deprovision result for satellite service
 */
message SatelliteProvision {
  // The result of satellite service provision/deprovision.
  optional android.telephony.SatelliteError result_code = 1;
  // The amount of time in seconds from start to complete provision/deprovision.
  optional int32 processing_time_sec = 2;
  // Indicator whether this is for provision/deprovision.
  // true means a provision request, and false means a deprovision request.
  optional bool is_provision_request = 3;
  // Whether the provisioning request was canceled.
  optional bool is_canceled = 4;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 5;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 6;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 7;
}

/**
 * Snapshot of satellite SOS message recommender
 */
message SatelliteSosMessageRecommender {
  // Whether the Dialer is notified with the event DISPLAY_SOS_MESSAGE.
  optional bool is_display_sos_message_sent = 1;
  // Number of times the timer is started.
  optional int32 count_of_timer_started = 2;
  // Whether IMS is registered.
  optional bool is_ims_registered = 3;
  // The cellular service state.
  optional android.telephony.ServiceStateEnum cellular_service_state = 4;
  // Total count of times this event has occurred.
  optional int32 count = 5;
  // Whether the device supports multiple SIMs.
  optional bool is_multi_sim = 6;
  // Handover type from emergency call to satellite messaging
  optional android.telephony.RecommendingHandoverType recommending_handover_type = 7;
  // Whether satellite communication is allowed in current location.
  optional bool is_satellite_allowed_in_current_location = 8;
  // Whether Wi-Fi is available when the emergency call attempted.
  optional bool is_wifi_connected = 9;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 10;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 11;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 12;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 13;
}

/**
 * Stats about carrier roaming satellite session
 */
message CarrierRoamingSatelliteSession {
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 1;
  // Whether device is connected to roaming non-terrestrial network
  optional bool is_ntn_roaming_in_home_country = 2;
  // Total time of satellite session
  optional int32 total_satellite_mode_time_sec = 3;
  // Number of times satellite signal is lost and gained within a session
  optional int32 number_of_satellite_connections = 4;
  // Average duration of a satellite connection
  optional int32 avg_duration_of_satellite_connection_sec = 5;
  // Minimum time gap between satellite connections in a satellite session
  optional int32 satellite_connection_gap_min_sec = 6;
  // Average time gap between satellite connections in a satellite session
  optional int32 satellite_connection_gap_avg_sec = 7;
  // Maximum time gap between satellite connections in a satellite session
  optional int32 satellite_connection_gap_max_sec = 8;
  // Average RSRP of non-terrestrial network
  optional int32 rsrp_avg = 9;
  // Median RSRP of non-terrestrial network
  optional int32 rsrp_median = 10;
  // Average RSSNR of non-terrestrial network
  optional int32 rssnr_avg = 11;
  // Median RSSNR of non-terrestrial network
  optional int32 rssnr_median = 12;
  // Total number of incoming sms received during the session
  optional int32 count_of_incoming_sms = 13;
  // Total number of outgoing sms sent during the session
  optional int32 count_of_outgoing_sms = 14;
  // Total number of incoming mms received during the session
  optional int32 count_of_incoming_mms = 15;
  // Total number of outgoing mms sent during the session
  optional int32 count_of_outgoing_mms = 16;
  // satellite supported services
  repeated int32 supported_satellite_services = 17;
  // Data Supported mode at satellite session
  optional int32 service_data_policy = 18;
  // Total data consumed per satellite session
  optional int64 satellite_data_consumed_bytes = 19;
  // Whether device is in DSDS mode
  optional bool is_multi_sim = 20;
  // Whether the service is Carrier Roaming NB-Iot NTN network or not.
  optional bool is_nb_iot_ntn = 21;
  // Total number of data connections during satellite session
  optional int32 count_of_data_connections = 22;
  // last fail causes at the disconnections during satellite session
  // The value is defined in
  // frameworks/base/telephony/java/android/telephony/DataFailCause.java
  repeated int32 last_fail_causes = 23;
  // Total number of data disconnections during satellite session
  optional int32 count_of_data_disconnections = 24;
  // Total number of data stalls during satellite session
  optional int32 count_of_data_stalls = 25;
  // Average uplink bandwidth for the satellite session
  optional int32 average_uplink_bandwidth_kbps = 26;
  // Average downlink bandwidth for the satellite session
  optional int32 average_downlink_bandwidth_kbps = 27;
   // Minimum uplink bandwidth for the satellite session
  optional int32 min_uplink_bandwidth_kbps = 28;
  // Maximum uplink bandwidth for the satellite session
  optional int32 max_uplink_bandwidth_kbps = 29;
   // Minimum downlink bandwidth for the satellite session
  optional int32 min_downlink_bandwidth_kbps = 30;
  // Maximum downlink bandwidth for the satellite session
  optional int32 max_downlink_bandwidth_kbps = 31;
  // Active Satellite constrained network Applications package name at Satellite session.
  // Note: Application active at satellite constrained network only
  // if PROPERTY_SATELLITE_DATA_OPTIMIZED meta data is set in application
  // manifest file.
  // (Ref: frameworks/base/telephony/java/android/telephony/satellite/SatelliteManager.java)
  // Note: Maximum of Top 5 satellite apps with most data consumed at satellite session 
  // to be captured
  repeated string satellite_supported_apps = 32;
  // Active Satellite constrained network Applications uid at Satellite session.
  // Note: Application active at satellite constrained network only
  // if PROPERTY_SATELLITE_DATA_OPTIMIZED meta data is set in application
  // manifest file.
  // (Ref: frameworks/base/telephony/java/android/telephony/satellite/SatelliteManager.java)
  // Note: Maximum of Top 5 satellite apps with most data consumed at satellite session 
  // to be captured
  repeated int32 satellite_supported_uids = 33 [(is_uid) = true];
  // Satellite Data Consumed in Bytes by satellite network Applications
  // (Ex: Pixel Weather, Accuweather etc) for the satellite session
  // Note: Maximum of Top 5 satellite apps with most data consumed at satellite session 
  // to be captured
  repeated int64 per_app_satellite_data_consumed_bytes = 34;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 35;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 36;
}

/**
 * Stats about usage of carrier roaming satellite network
 */
message CarrierRoamingSatelliteControllerStats {
  // Data source of carrier roaming satellite network
  optional android.telephony.ConfigDataSource config_data_source = 1;
  // Total number of times entitlement status query request is sent to server
  optional int32 count_of_entitlement_status_query_request = 2;
  // Total number of times satellite config is updated
  optional int32 count_of_satellite_config_update_request = 3;
  // Total number of times auto-connected to satellite notification is displayed
  optional int32 count_of_satellite_notification_displayed = 4;
  // Minimum gap between satellite sessions
  optional int32 satellite_session_gap_min_sec = 5;
  // Average gap between satellite sessions
  optional int32 satellite_session_gap_avg_sec = 6;
  // Maximum gap between satellite sessions
  optional int32 satellite_session_gap_max_sec = 7;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 8;
  // Whether this device is entitled or not.
  optional bool is_device_entitled = 9;
  // Whether device is in DSDS mode
  optional bool is_multi_sim = 10;
  // Count of how many satellite sessions have been opened
  optional int32 count_of_satellite_sessions = 11;
  // Whether the service is Carrier Roaming NB-Iot NTN network or not.
  optional bool is_nb_iot_ntn = 12;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 13;
  // Total count of Automatic connection type sessions
  optional int32 count_of_session_connection_mode_automatic = 14;
  // Total count of Manual connection type sessions
  optional int32 count_of_session_connection_mode_manual = 15;
  // Data policy of device, configured for carrier roaming satellite network
  optional android.telephony.SatelliteEntitlementServicePolicy service_data_policy = 16;
}

/**
 * Stats about apps using carrier-roaming satellite services such as SMS, MMS and DATA
 */
message ControllerStatsPerPackage {
  optional int32 uid = 1  [(is_uid) = true];
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 2;
}

/**
 * Stats about satellite entitlement query request
 */
message SatelliteEntitlement {
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 1;
  // Result of entitlement query request
  optional int32 result = 2;
  // Entitlement status of the subscription
  optional android.telephony.SatelliteEntitlementStatus  entitlement_status = 3;
  // Retry request for entitlement query
  optional bool is_retry = 4;
  // Total number of times this event has occurred
  optional int32 count = 5;
  // allowed service entitlement status
  optional bool is_allowed_service_entitlement = 6;
  // service type entitlement
  repeated int32 entitlement_service_type = 7;
  // data policy entitlement
  optional android.telephony.SatelliteEntitlementServicePolicy entitlement_data_policy = 8;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 9;
  // The HTTP status code when the entitlement query fails due to an HTTP error.
  // This is only populated when the 'result' field is ERROR_HTTP_STATUS_NOT_SUCCESS.
  optional int32 http_status_code = 10;
}

/**
 * Stats about satellite config update
 */
message SatelliteConfigUpdater {
  // satellite config version used by the device
  optional int32 config_version = 1;
  // Result of OEM config update
  optional android.telephony.ConfigUpdateResult oem_config_result = 2;
  // Result of carrier config update
  optional android.telephony.ConfigUpdateResult carrier_config_result = 3;
  // Total number of times this event has occurred
  optional int32 count = 4;
}

message SatelliteAccessController {
  // Satellite access control type.
  optional android.telephony.AccessControlType access_control_type = 1;
  // The amount of time took to query current location.
  optional int64 location_query_time_millis = 2;
  // The amount of time took to search for the current location in the on-device data.
  optional int64 on_device_lookup_time_millis = 3;
  // The total amount of time took to serve a request for checking if satellite communication is
  // allowed at the current location.
  optional int64 total_checking_time_millis = 4;
  // Whether satellite service is allowed at the current location.
  optional bool is_allowed = 5;
  // Whether request is received in emergency mode.
  optional bool is_emergency = 6;
  // Result code of the request for checking if satellite communication is allowed at the current
  // location.
  optional android.telephony.SatelliteError result_code = 7;
  // ISO 3166-1 alpha-2 uppercase country codes representing the device's
  // location.
  // Country codes are determined based on the device's current location
  // information, obtained from the cellular network.
  // Country code can be obtained only when there is available cellular network,
  // or empty list will be given.
  // Cellular networks may provide multiple codes at locations near country
  // borders.
  repeated string country_codes = 8;
  // Source of geofencing config data
  optional android.telephony.ConfigDataSource config_data_source = 9;
  // Carrier id of the subscription connected to non-terrestrial network
  optional int32 carrier_id = 10;
  // From which reason the Satellite Access Controller operation was triggered.
  optional android.telephony.TriggeringEvent triggering_event = 11;
  // Whether this satellite service is from NTN only carrier.
  optional bool is_ntn_only_carrier = 12;
  // Global connect type of the subscription
  optional android.telephony.SatelliteGlobalConnectType supported_connection_mode = 13;
  // Session connect type
  optional android.telephony.SatelliteSessionConnectType session_connection_mode = 14;
}
