//
// 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 clearcut.connectivity;

option java_package = "com.android.internal.telephony";
option java_outer_classname = "TelephonyProto";

// The information about Telephony events.
message TelephonyLog {

  // Events logged by telephony services
  repeated TelephonyEvent events = 1;

  // Voice/Video call sessions
  repeated TelephonyCallSession call_sessions = 2;

  // Send/Receive SMS sessions
  repeated SmsSession sms_sessions = 3;

  // Telephony Histograms
  repeated TelephonyHistogram histograms = 4;

  // Indicating some telephony events are dropped
  optional bool events_dropped = 5;

  // The start time of this log
  optional Time start_time = 6;

  // The end time of this log
  optional Time end_time = 7;
}

// The time information
message Time {
  // The system time in milli seconds. This represents the actual
  // time of the events.
  optional int64 system_timestamp_millis = 1;

  // The time since boot in milli seconds.
  // This is used for calculating the time interval between events. Different
  // from the system time, this won't be affected by time changed by the network or users.
  optional int64 elapsed_timestamp_millis = 2;
}

// Telephony Histogram
message TelephonyHistogram {

  // Type of histogram
  optional int32 category = 1;

  // Unique Id identifying a sample within
  // particular category of the histogram.
  optional int32 id = 2;

  // Min time taken in millis.
  optional int32 min_time_millis = 3;

  // Max time taken in millis.
  optional int32 max_time_millis = 4;

  // Average time taken in millis.
  optional int32 avg_time_millis = 5;

  // Total count of histogram samples.
  optional int32 count = 6;

  // Total number of time ranges expected
  // (must be greater than 1).
  optional int32 bucket_count = 7;

  // Array storing endpoints of range buckets.
  repeated int32 bucket_end_points = 8;

  // Array storing counts for each time range
  // starting from smallest value range.
  repeated int32 bucket_counters = 9;
}

// Telephony related user settings
message TelephonySettings {

  // NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
  enum RilNetworkMode {

    // Mode is unknown.
    NETWORK_MODE_UNKNOWN = 0;

    // GSM/WCDMA (WCDMA preferred)
    NETWORK_MODE_WCDMA_PREF = 1;

    // GSM only
    NETWORK_MODE_GSM_ONLY = 2;

    // WCDMA only
    NETWORK_MODE_WCDMA_ONLY = 3;

    // GSM/WCDMA (auto mode, according to PRL)
    NETWORK_MODE_GSM_UMTS = 4;

    // CDMA and EvDo (auto mode, according to PRL)
    NETWORK_MODE_CDMA = 5;

    // CDMA only
    NETWORK_MODE_CDMA_NO_EVDO = 6;

    // EvDo only
    NETWORK_MODE_EVDO_NO_CDMA = 7;

    // GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL)
    NETWORK_MODE_GLOBAL = 8;

    // LTE, CDMA and EvDo
    NETWORK_MODE_LTE_CDMA_EVDO = 9;

    // LTE, GSM/WCDMA
    NETWORK_MODE_LTE_GSM_WCDMA = 10;

    // LTE, CDMA, EvDo, GSM/WCDMA
    NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA = 11;

    // LTE Only mode
    NETWORK_MODE_LTE_ONLY = 12;

    // LTE/WCDMA
    NETWORK_MODE_LTE_WCDMA = 13;

    // TD-SCDMA only
    NETWORK_MODE_TDSCDMA_ONLY = 14;

    // TD-SCDMA and WCDMA
    NETWORK_MODE_TDSCDMA_WCDMA = 15;

    // TD-SCDMA and LTE
    NETWORK_MODE_LTE_TDSCDMA = 16;

    // TD-SCDMA and GSM
    NETWORK_MODE_TDSCDMA_GSM = 17;

    // TD-SCDMA,GSM and LTE
    NETWORK_MODE_LTE_TDSCDMA_GSM = 18;

    // TD-SCDMA, GSM/WCDMA
    NETWORK_MODE_TDSCDMA_GSM_WCDMA = 19;

    // TD-SCDMA, WCDMA and LTE
    NETWORK_MODE_LTE_TDSCDMA_WCDMA = 20;

    // TD-SCDMA, GSM/WCDMA and LTE
    NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA = 21;

    // TD-SCDMA,EvDo,CDMA,GSM/WCDMA
    NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 22;

    // TD-SCDMA/LTE/GSM/WCDMA, CDMA, and EvDo
    NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 23;
  }

  // Constants for WiFi Calling mode
  enum WiFiCallingMode {

    // Calling mode is unknown.
    WFC_MODE_UNKNOWN = 0;

    WFC_MODE_WIFI_ONLY = 1;

    WFC_MODE_CELLULAR_PREFERRED = 2;

    WFC_MODE_WIFI_PREFERRED = 3;
  }

  // If the device is in airplane mode.
  optional bool is_airplane_mode = 1;

  // If cell-data has been enabled.
  optional bool is_cellular_data_enabled = 2;

  // If cell-roaming has been enabled.
  optional bool is_data_roaming_enabled = 3;

  // Preferred network mode.
  optional RilNetworkMode preferred_network_mode = 4;

  // If enhanced mode enabled.
  optional bool is_enhanced_4g_lte_mode_enabled = 5;

  // If wifi has been enabled.
  optional bool is_wifi_enabled = 6;

  // If wifi-calling has been enabled.
  optional bool is_wifi_calling_enabled = 7;

  // Wifi-calling Mode.
  optional WiFiCallingMode wifi_calling_mode = 8;

  // If video over LTE enabled.
  optional bool is_vt_over_lte_enabled = 9;

  // If video over wifi enabled.
  optional bool is_vt_over_wifi_enabled = 10;
}

// Contains phone state and service related information.
message TelephonyServiceState {

  // The information about cellular network operator
  message TelephonyOperator {

    // Name in long alphanumeric format
    optional string alpha_long = 1;

    // Name in short alphanumeric format
    optional string alpha_short = 2;

    // Numeric id.
    // In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
    // network code. Same as MCC/MNC.
    optional string numeric = 3;
  }

  // Roaming type
  enum RoamingType {

    // In home network
    ROAMING_TYPE_NOT_ROAMING = 0;

    // In a roaming network, but we can not tell
    // if it's domestic or international
    ROAMING_TYPE_UNKNOWN = 1;

    // In domestic roaming network
    ROAMING_TYPE_DOMESTIC = 2;

    // In international roaming network
    ROAMING_TYPE_INTERNATIONAL = 3;
  }

  // Current registered operator
  optional TelephonyOperator voice_operator = 1;

  // Current registered data network operator
  optional TelephonyOperator data_operator = 2;

  // Current voice network roaming type
  optional RoamingType voice_roaming_type = 3;

  // Current data network roaming type
  optional RoamingType data_roaming_type = 4;

  // Current voice radio technology
  optional RadioAccessTechnology voice_rat = 5;

  // Current data radio technology
  optional RadioAccessTechnology data_rat = 6;
}

// Radio access families
enum RadioAccessTechnology {

  RAT_UNKNOWN = 0;

  RAT_GPRS = 1;

  RAT_EDGE = 2;

  RAT_UMTS = 3;

  RAT_IS95A = 4;

  RAT_IS95B = 5;

  RAT_1XRTT = 6;

  RAT_EVDO_0 = 7;

  RAT_EVDO_A = 8;

  RAT_HSDPA = 9;

  RAT_HSUPA = 10;

  RAT_HSPA = 11;

  RAT_EVDO_B = 12;

  RAT_EHRPD = 13;

  RAT_LTE = 14;

  RAT_HSPAP = 15;

  RAT_GSM = 16;

  RAT_TD_SCDMA = 17;

  RAT_IWLAN = 18;

  RAT_LTE_CA = 19;
}

// The information about IMS errors
// https://cs.corp.google.com/#android/frameworks/base/telephony/java/com/android/ims/ImsReasonInfo.java
message ImsReasonInfo {

  // Main reason code.
  optional int32 reason_code = 1;

  // Extra code value; it depends on the code value.
  optional int32 extra_code = 2;

  // Additional message of the reason info. We get this from the modem.
  optional string extra_message = 3;
}

// The information about state connection between IMS service and IMS server
message ImsConnectionState {

  // Current state
  optional State state = 1;

  // If DISCONNECTED then this field may have additional information about
  // connection problem.
  optional ImsReasonInfo reason_info = 2;

  // Posible states
  enum State {

    // State is unknown.
    STATE_UNKNOWN = 0;

    CONNECTED = 1;

    PROGRESSING = 2;

    DISCONNECTED = 3;

    RESUMED = 4;

    SUSPENDED = 5;
  }
}

// The information about current capabilities of IMS service
message ImsCapabilities {

  optional bool voice_over_lte = 1;

  optional bool voice_over_wifi = 2;

  optional bool video_over_lte = 3;

  optional bool video_over_wifi = 4;

  optional bool ut_over_lte = 5;

  optional bool ut_over_wifi = 6;
}

// Errors returned by RIL
enum RilErrno {

  // type is unknown.
  RIL_E_UNKNOWN = 0;

  RIL_E_SUCCESS = 1;

  // If radio did not start or is resetting
  RIL_E_RADIO_NOT_AVAILABLE = 2;

  RIL_E_GENERIC_FAILURE = 3;

  // for PIN/PIN2 methods only!
  RIL_E_PASSWORD_INCORRECT = 4;

  // Operation requires SIM PIN2 to be entered
  RIL_E_SIM_PIN2 = 5;

  // Operation requires SIM PIN2 to be entered
  RIL_E_SIM_PUK2 = 6;

  RIL_E_REQUEST_NOT_SUPPORTED = 7;

  RIL_E_CANCELLED = 8;

  // data ops are not allowed during voice call on a Class C GPRS device
  RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 9;

  // data ops are not allowed before device registers in network
  RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 10;

  // fail to send sms and need retry
  RIL_E_SMS_SEND_FAIL_RETRY = 11;

  // fail to set the location where CDMA subscription shall be retrieved
  // because of SIM or RUIM card absent
  RIL_E_SIM_ABSENT = 12;

  // fail to find CDMA subscription from specified location
  RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 13;

  // HW does not support preferred network type
  RIL_E_MODE_NOT_SUPPORTED = 14;

  // command failed because recipient is not on FDN list
  RIL_E_FDN_CHECK_FAILURE = 15;

  // network selection failed due to illegal SIM or ME
  RIL_E_ILLEGAL_SIM_OR_ME = 16;

  // no logical channel available
  RIL_E_MISSING_RESOURCE = 17;

  // application not found on SIM
  RIL_E_NO_SUCH_ELEMENT = 18;

  // DIAL request modified to USSD
  RIL_E_DIAL_MODIFIED_TO_USSD = 19;

  // DIAL request modified to SS
  RIL_E_DIAL_MODIFIED_TO_SS = 20;

  // DIAL request modified to DIAL with different data
  RIL_E_DIAL_MODIFIED_TO_DIAL = 21;

  // USSD request modified to DIAL
  RIL_E_USSD_MODIFIED_TO_DIAL = 22;

  // USSD request modified to SS
  RIL_E_USSD_MODIFIED_TO_SS = 23;

  // USSD request modified to different USSD request
  RIL_E_USSD_MODIFIED_TO_USSD = 24;

  // SS request modified to DIAL
  RIL_E_SS_MODIFIED_TO_DIAL = 25;

  // SS request modified to USSD
  RIL_E_SS_MODIFIED_TO_USSD = 26;

  // Subscription not supported by RIL
  RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 27;

  // SS request modified to different SS request
  RIL_E_SS_MODIFIED_TO_SS = 28;

  // LCE service not supported(36 in RILConstants.java)
  RIL_E_LCE_NOT_SUPPORTED = 36;
}

// PDP_type values in TS 27.007 section 10.1.1.
enum PdpType {

  // type is unknown.
  PDP_UNKNOWN = 0;

  PDP_TYPE_IP = 1;

  PDP_TYPE_IPV6 = 2;

  PDP_TYPE_IPV4V6 = 3;

  PDP_TYPE_PPP = 4;
}

// The information about packet data connection
message RilDataCall {

  // Context ID, uniquely identifies this call
  optional int32 cid = 1;

  // One of the PDP_type values in TS 27.007 section 10.1.1
  optional PdpType type = 2;

  // The network interface name e.g. wlan0, rmnet_data0.
  optional string iframe = 3;
}

message TelephonyEvent {

  enum Type {

    // Unknown event
    UNKNOWN = 0;

    // Telephony related user settings changed
    SETTINGS_CHANGED = 1;

    // Phone state changed
    RIL_SERVICE_STATE_CHANGED = 2;

    // IMS connected/disconnected
    IMS_CONNECTION_STATE_CHANGED = 3;

    // IMS Voice, Video and Ut capabilities changed
    IMS_CAPABILITIES_CHANGED = 4;

    // Setup a packet data connection
    DATA_CALL_SETUP = 5;

    // RIL request result
    DATA_CALL_SETUP_RESPONSE = 6;

    // Notification that new data call has appeared in the list
    // or old data call has removed.
    DATA_CALL_LIST_CHANGED = 7;

    // Deactivate packet data connection
    DATA_CALL_DEACTIVATE = 8;

    // RIL request result
    DATA_CALL_DEACTIVATE_RESPONSE = 9;

    // Logging a data stall + its action
    DATA_STALL_ACTION = 10;

    // Modem Restarted. Logging a baseband version and reason for restart
    // along with the event if it is available
    MODEM_RESTART = 11;

    // System time overwritten by NITZ (Network time)
    NITZ_TIME = 12;
  }

  // Setup a packet data connection
  message RilSetupDataCall {

    // See ril.h RIL_REQUEST_SETUP_DATA_CALL
    enum RilDataProfile {

      // type is unknown.
      RIL_DATA_UNKNOWN = 0;

      RIL_DATA_PROFILE_DEFAULT = 1;

      RIL_DATA_PROFILE_TETHERED = 2;

      RIL_DATA_PROFILE_IMS = 3;

      RIL_DATA_PROFILE_FOTA = 4;

      RIL_DATA_PROFILE_CBS = 5;

      RIL_DATA_PROFILE_OEM_BASE = 6;

      RIL_DATA_PROFILE_INVALID = 7;
    }

    // Radio technology to use
    optional RadioAccessTechnology rat = 1;

    // optional RIL_DataProfile
    optional RilDataProfile data_profile = 2;

    // APN to connect to if radio technology is GSM/UMTS
    optional string apn = 3;

    // the connection type to request
    optional PdpType type = 4;
  }

  // RIL response to RilSetupDataCall
  message RilSetupDataCallResponse {

    // Copy of enum RIL_DataCallFailCause defined at
    // https://cs.corp.google.com/android/hardware/ril/include/telephony/ril.h
    enum RilDataCallFailCause {

      // Failure reason is unknown.
      PDP_FAIL_UNKNOWN = 0;

      // No error, connection ok
      PDP_FAIL_NONE = 1;

      PDP_FAIL_OPERATOR_BARRED = 8;

      PDP_FAIL_NAS_SIGNALLING = 14;

      PDP_FAIL_LLC_SNDCP = 25;

      PDP_FAIL_INSUFFICIENT_RESOURCES = 26;

      PDP_FAIL_MISSING_UKNOWN_APN = 27;

      PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 28;

      PDP_FAIL_USER_AUTHENTICATION = 29;

      PDP_FAIL_ACTIVATION_REJECT_GGSN = 30;

      PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 31;

      PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 32;

      PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 33;

      PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 34;

      PDP_FAIL_NSAPI_IN_USE = 35;

      // Possibly restart radio, based on framework config
      PDP_FAIL_REGULAR_DEACTIVATION = 36;

      PDP_FAIL_QOS_NOT_ACCEPTED = 37;

      PDP_FAIL_NETWORK_FAILURE = 38;

      PDP_FAIL_UMTS_REACTIVATION_REQ = 39;

      PDP_FAIL_FEATURE_NOT_SUPP = 40;

      PDP_FAIL_TFT_SEMANTIC_ERROR = 41;

      PDP_FAIL_TFT_SYTAX_ERROR = 42;

      PDP_FAIL_UNKNOWN_PDP_CONTEXT = 43;

      PDP_FAIL_FILTER_SEMANTIC_ERROR = 44;

      PDP_FAIL_FILTER_SYTAX_ERROR = 45;

      PDP_FAIL_PDP_WITHOUT_ACTIVE_TFT = 46;

      PDP_FAIL_ONLY_IPV4_ALLOWED = 50;

      PDP_FAIL_ONLY_IPV6_ALLOWED = 51;

      PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 52;

      PDP_FAIL_ESM_INFO_NOT_RECEIVED = 53;

      PDP_FAIL_PDN_CONN_DOES_NOT_EXIST = 54;

      PDP_FAIL_MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED = 55;

      PDP_FAIL_MAX_ACTIVE_PDP_CONTEXT_REACHED = 65;

      PDP_FAIL_UNSUPPORTED_APN_IN_CURRENT_PLMN = 66;

      PDP_FAIL_INVALID_TRANSACTION_ID = 81;

      PDP_FAIL_MESSAGE_INCORRECT_SEMANTIC = 95;

      PDP_FAIL_INVALID_MANDATORY_INFO = 96;

      PDP_FAIL_MESSAGE_TYPE_UNSUPPORTED = 97;

      PDP_FAIL_MSG_TYPE_NONCOMPATIBLE_STATE = 98;

      PDP_FAIL_UNKNOWN_INFO_ELEMENT = 99;

      PDP_FAIL_CONDITIONAL_IE_ERROR = 100;

      PDP_FAIL_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 101;

      PDP_FAIL_PROTOCOL_ERRORS   = 111;

      PDP_FAIL_APN_TYPE_CONFLICT = 112;

      PDP_FAIL_INVALID_PCSCF_ADDR = 113;

      PDP_FAIL_INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN = 114;

      PDP_FAIL_EMM_ACCESS_BARRED = 115;

      PDP_FAIL_EMERGENCY_IFACE_ONLY = 116;

      PDP_FAIL_IFACE_MISMATCH = 117;

      PDP_FAIL_COMPANION_IFACE_IN_USE = 118;

      PDP_FAIL_IP_ADDRESS_MISMATCH = 119;

      PDP_FAIL_IFACE_AND_POL_FAMILY_MISMATCH = 120;

      PDP_FAIL_EMM_ACCESS_BARRED_INFINITE_RETRY = 121;

      PDP_FAIL_AUTH_FAILURE_ON_EMERGENCY_CALL = 122;

      // Not mentioned in the specification
      PDP_FAIL_VOICE_REGISTRATION_FAIL = -1;

      PDP_FAIL_DATA_REGISTRATION_FAIL = -2;

      // Reasons for data call drop - network/modem disconnect
      PDP_FAIL_SIGNAL_LOST = -3;

      // Preferred technology has changed, should retry with parameters
      // appropriate for new technology
      PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4;

      // Data call was disconnected because radio was resetting,
      // powered off - no retry
      PDP_FAIL_RADIO_POWER_OFF = -5;

      // Data call was disconnected by modem because tethered mode was up
      // on same APN/data profile - no retry until tethered call is off
      PDP_FAIL_TETHERED_CALL_ACTIVE = -6;

      // retry silently
      PDP_FAIL_ERROR_UNSPECIFIED = 65535;
    }

    // A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error
    optional RilDataCallFailCause status = 1;

    // If status != 0, this fields indicates the suggested retry back-off timer
    // value RIL wants to override the one pre-configured in FW
    optional int32 suggested_retry_time_millis = 2;

    optional RilDataCall call = 3;
  }

  // Deactivate packet data connection
  message RilDeactivateDataCall {

    // Context ID
    optional int32 cid = 1;

    // Reason for deactivating data call
    optional DeactivateReason reason = 2;

    // Deactivate data call reasons
    enum DeactivateReason {

      // Reason is unknown.
      DEACTIVATE_REASON_UNKNOWN = 0;

      DEACTIVATE_REASON_NONE = 1;

      DEACTIVATE_REASON_RADIO_OFF = 2;

      DEACTIVATE_REASON_PDP_RESET = 3;
    }
  }

  message ModemRestart {
     // The baseband_version is used to identify the particular software version
     // where the modem restarts happened
     optional string baseband_version = 1;

     // Indicates the modem restart reason. The restart reason can be used to
     // categorize any modem crashes and group similar crashes together. This
     // information will be useful to identify the cause of modem crashes,
     // reproduce the issue and confirm that the fix works.
     optional string reason = 2;
  }

  // Time when event happened on device, in milliseconds since epoch
  optional int64 timestamp_millis = 1;

  // In Multi-SIM devices this indicates SIM slot
  optional int32 phone_id = 2;

  // Event type
  optional Type type = 3;

  // User settings
  optional TelephonySettings settings = 4;

  // RIL Service State
  optional TelephonyServiceState service_state = 5;

  // IMS state
  optional ImsConnectionState ims_connection_state = 6;

  // IMS capabilities
  optional ImsCapabilities ims_capabilities = 7;

  // List of data calls when changed
  repeated RilDataCall data_calls = 8;

  // RIL error code
  optional RilErrno error = 9;

  // Setup data call request
  optional RilSetupDataCall setup_data_call = 10;

  // Setup data call response
  optional RilSetupDataCallResponse setup_data_call_response = 11;

  // Deactivate data call request
  optional RilDeactivateDataCall deactivate_data_call = 12;

  // Data call stall recovery action
  optional int32 data_stall_action = 13;

  // Modem restart event
  optional ModemRestart modem_restart = 14;

  // NITZ time in milliseconds
  optional int64 nitz_timestamp_millis = 15;
}

enum TimeInterval {
  TI_UNKNOWN = 0;
  TI_10_MILLIS = 1;
  TI_20_MILLIS = 2;
  TI_50_MILLIS = 3;
  TI_100_MILLIS = 4;
  TI_200_MILLIS = 5;
  TI_500_MILLIS = 6;
  TI_1_SEC = 7;
  TI_2_SEC = 8;
  TI_5_SEC = 9;
  TI_10_SEC = 10;
  TI_30_SEC = 11;
  TI_1_MINUTE = 12;
  TI_3_MINUTES = 13;
  TI_10_MINUTES = 14;
  TI_30_MINUTES = 15;
  TI_1_HOUR = 16;
  TI_2_HOURS = 17;
  TI_4_HOURS = 18;
  TI_MANY_HOURS = 19;
}

// Information about CS and/or PS call session.
// Session starts when call is placed or accepted and
// ends when there are no more active calls.
message TelephonyCallSession {

  message Event {

    enum Type {

      // Unknown event
      EVENT_UNKNOWN = 0;

      // Telephony related user settings changed
      SETTINGS_CHANGED = 1;

      // Phone state changed
      RIL_SERVICE_STATE_CHANGED = 2;

      // IMS connected/disconnected
      IMS_CONNECTION_STATE_CHANGED = 3;

      // IMS Voice, Video and Ut capabilities changed
      IMS_CAPABILITIES_CHANGED = 4;

      // Notification that new data call has appeared in the list
      // or old data call has removed.
      DATA_CALL_LIST_CHANGED = 5;

      // Send request to RIL
      RIL_REQUEST = 6;

      // Result of the RIL request
      RIL_RESPONSE = 7;

      // Ring indication for an incoming call
      RIL_CALL_RING = 8;

      // Notification that Single Radio Voice Call Continuity(SRVCC)
      // progress state has changed.
      RIL_CALL_SRVCC = 9;

      // Notification that list of calls has changed.
      RIL_CALL_LIST_CHANGED = 10;

      // Command sent to IMS Service. See ImsCommand.
      IMS_COMMAND = 11;

      // Command sent to IMS Service. See ImsCommand.
      IMS_COMMAND_RECEIVED = 12;

      // Command sent to IMS Service. See ImsCommand.
      IMS_COMMAND_FAILED = 13;

      // Command sent to IMS Service. See ImsCommand.
      IMS_COMMAND_COMPLETE = 14;

      // Notification about incoming voice call
      IMS_CALL_RECEIVE = 15;

      // Notification that state of the call has changed
      IMS_CALL_STATE_CHANGED = 16;

      // Notification about IMS call termination
      IMS_CALL_TERMINATED = 17;

      // Notification that session access technology has changed
      IMS_CALL_HANDOVER = 18;

      // Notification that session access technology has changed
      IMS_CALL_HANDOVER_FAILED = 19;

      // Notification about phone state changed.
      PHONE_STATE_CHANGED = 20;

      // System time overwritten by NITZ (Network time)
      NITZ_TIME = 21;
    }

    enum RilRequest {

      RIL_REQUEST_UNKNOWN = 0;

      // Initiate voice call
      RIL_REQUEST_DIAL = 1;

      // Answer incoming call
      RIL_REQUEST_ANSWER = 2;

      // Hang up a specific line
      RIL_REQUEST_HANGUP = 3;

      // Configure current call waiting state
      RIL_REQUEST_SET_CALL_WAITING = 4;

      RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE = 5;

      // Send FLASH
      RIL_REQUEST_CDMA_FLASH = 6;

      // Conference holding and active
      RIL_REQUEST_CONFERENCE = 7;
    }

    enum ImsCommand {

      // Command is unknown.
      IMS_CMD_UNKNOWN = 0;

      IMS_CMD_START = 1;

      IMS_CMD_ACCEPT = 2;

      IMS_CMD_REJECT = 3;

      IMS_CMD_TERMINATE = 4;

      IMS_CMD_HOLD = 5;

      IMS_CMD_RESUME = 6;

      IMS_CMD_MERGE = 7;

      IMS_CMD_UPDATE = 8;

      IMS_CMD_CONFERENCE_EXTEND = 9;

      IMS_CMD_INVITE_PARTICIPANT = 10;

      IMS_CMD_REMOVE_PARTICIPANT = 11;
    }

    enum PhoneState {

      // State is unknown.
      STATE_UNKNOWN = 0;

      STATE_IDLE = 1;

      STATE_RINGING = 2;

      STATE_OFFHOOK = 3;
    }

    // Telephony call states
    enum CallState {

      // State is unknown.
      CALL_UNKNOWN = 0;

      CALL_IDLE = 1;

      CALL_ACTIVE = 2;

      CALL_HOLDING = 3;

      CALL_DIALING = 4;

      CALL_ALERTING = 5;

      CALL_INCOMING = 6;

      CALL_WAITING = 7;

      CALL_DISCONNECTED = 8;

      CALL_DISCONNECTING = 9;
    }

    // The information about a voice call
    message RilCall {

      enum Type {

        // Scan Type is unknown.
        UNKNOWN = 0;

        // Mobile originated
        MO = 1;

        // Mobile terminated
        MT = 2;
      }

      // Connection Index
      optional int32 index = 1;

      optional CallState state = 2;

      optional Type type = 3;
    }

    // Single Radio Voice Call Continuity(SRVCC) progress state
    enum RilSrvccState {

      // State is unknown.
      HANDOVER_UNKNOWN = 0;

      HANDOVER_STARTED = 1;

      HANDOVER_COMPLETED = 2;

      HANDOVER_FAILED = 3;

      HANDOVER_CANCELED = 4;
    }

    // Event type
    optional Type type = 1;

    // Time since previous event
    optional TimeInterval delay = 2;

    // Settings at the begining of the session or when changed
    optional TelephonySettings settings = 3;

    // State at the beginning of the session or when changed
    optional TelephonyServiceState service_state = 4;

    // State at the beginning of the session or when changed
    optional ImsConnectionState ims_connection_state = 5;

    // Capabilities at the beginning of the session or when changed
    optional ImsCapabilities ims_capabilities = 6;

    // List of data calls at the beginning of the session or when changed
    repeated RilDataCall data_calls = 7;

    // New state
    optional PhoneState phone_state = 8;

    // New state
    optional CallState call_state = 9;

    // CS or IMS Voice call index
    optional int32 call_index = 10;

    // New merged call
    optional int32 merged_call_index = 11;

    // Active CS Voice calls
    repeated RilCall calls = 12;

    // RIL error code
    optional RilErrno error = 13;

    // RIL request
    optional RilRequest ril_request = 14;

    // Numeric ID
    optional int32 ril_request_id = 15;

    // New SRVCC state
    optional RilSrvccState srvcc_state = 16;

    // IMS command
    optional ImsCommand ims_command = 17;

    // IMS Failure reason
    optional ImsReasonInfo reason_info = 18;

    // Original access technology
    optional RadioAccessTechnology src_access_tech = 19;

    // New access technology
    optional RadioAccessTechnology target_access_tech = 20;

    // NITZ time in milliseconds
    optional int64 nitz_timestamp_millis = 21;
  }

  // Time when call has started, in minutes since epoch,
  // with 5 minutes precision
  optional int32 start_time_minutes = 1;

  // In Multi-SIM devices this indicates SIM slot
  optional int32 phone_id = 2;

  // List of events happened during the call
  repeated Event events = 3;

  // Indicating some call events are dropped
  optional bool events_dropped = 4;
}

message SmsSession {

  message Event {

    enum Type {

      // Unknown event
      EVENT_UNKNOWN = 0;

      // Telephony related user settings changed
      SETTINGS_CHANGED = 1;

      // Phone state changed
      RIL_SERVICE_STATE_CHANGED = 2;

      // IMS connected/disconnected
      IMS_CONNECTION_STATE_CHANGED = 3;

      // IMS Voice, Video and Ut capabilities changed
      IMS_CAPABILITIES_CHANGED = 4;

      // Notification that new data call has appeared in the list
      // or old data call has removed.
      DATA_CALL_LIST_CHANGED = 5;

      // Send a SMS message
      SMS_SEND = 6;

      // Message has been sent to network
      SMS_SEND_RESULT = 7;

      // Notification about received SMS
      SMS_RECEIVED = 8;
    }

    // Formats used to encode SMS messages
    enum Format {

      // State is unknown.
      SMS_FORMAT_UNKNOWN = 0;

      // GSM, WCDMA
      SMS_FORMAT_3GPP = 1;

      // CDMA
      SMS_FORMAT_3GPP2 = 2;
    }

    enum Tech {
      SMS_UNKNOWN = 0;

      SMS_GSM = 1;

      SMS_CDMA = 2;

      SMS_IMS = 3;
    }

    // Event type
    optional Type type = 1;

    // Time since previous event
    optional TimeInterval delay = 2;

    // Settings at the begining of the session or when changed
    optional TelephonySettings settings = 3;

    // State at the beginning of the session or when changed
    optional TelephonyServiceState service_state = 4;

    // State at the beginning of the session or when changed
    optional ImsConnectionState ims_connection_state = 5;

    // Capabilities at the beginning of the session or when changed
    optional ImsCapabilities ims_capabilities = 6;

    // List of data calls at the beginning of the session or when changed
    repeated RilDataCall data_calls = 7;

    // Format of the message
    optional Format format = 8;

    // Technology used to send/receive SMS
    optional Tech tech = 9;

    // See 3GPP 27.005, 3.2.5 for GSM/UMTS,
    // 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA,
    // -1 if unknown or not applicable
    optional int32 error_code = 10;

    // RIL error code
    optional RilErrno error = 11;

    // Numeric ID
    optional int32 ril_request_id = 12;
  }

  // Time when session has started, in minutes since epoch,
  // with 5 minutes precision
  optional int32 start_time_minutes = 1;

  // In Multi-SIM devices this indicates SIM slot
  optional int32 phone_id = 2;

  // List of events happened during the call
  repeated Event events = 3;

  // Indicating some sms session events are dropped
  optional bool events_dropped = 4;
}