Android-cuttlefish cvd tool
|
#include <network_service.h>
Classes | |
class | KeepSignalStrengthChangingLoop |
struct | NetworkOperator |
struct | NetworkRegistrationStatus |
struct | SignalStrength |
Public Types | |
enum | RegistrationState { NET_REGISTRATION_UNREGISTERED = 0 , NET_REGISTRATION_HOME = 1 , NET_REGISTRATION_SEARCHING = 2 , NET_REGISTRATION_DENIED = 3 , NET_REGISTRATION_UNKNOWN = 4 , NET_REGISTRATION_ROAMING = 5 , NET_REGISTRATION_EMERGENCY = 8 } |
Private Types | |
enum | RadioState : int32_t { RADIO_STATE_OFF , RADIO_STATE_ON } |
enum | OperatorSelectionMode { OPER_SELECTION_AUTOMATIC = 0 , OPER_SELECTION_MANUAL , OPER_SELECTION_DEREGISTRATION , OPER_SELECTION_SET_FORMAT , OPER_SELECTION_MANUAL_AUTOMATIC } |
Private Member Functions | |
void | InitializeServiceState () |
std::vector< CommandHandler > | InitializeCommandHandlers () |
void | InitializeNetworkOperator () |
void | InitializeSimOperator () |
bool | WakeupFromSleep () |
bool | IsHasNetwork () |
void | UpdateRegisterState (RegistrationState state) |
void | AdjustSignalStrengthValue (int &value, const std::pair< int, int > &range) |
SignalStrength | GetCurrentSignalStrength () |
NetworkRegistrationStatus::AccessTechnoloy | getNetworkTypeFromTech (ModemTechnology modemTech) |
int | getModemTechFromPrefer (int preferred_mask) |
ModemTechnology | getTechFromNetworkType (NetworkRegistrationStatus::AccessTechnoloy act) |
void | HandleIdentifierDisclosure (const std::string &command) |
void | HandleSecurityAlgorithmUpdate (const std::string &command) |
Static Private Member Functions | |
static int | GetValueInRange (const std::pair< int, int > &range, int percent) |
static std::string | BuildCSQCommandResponse (const SignalStrength &signal_strength) |
Private Attributes | |
MiscService * | misc_service_ = nullptr |
SimService * | sim_service_ = nullptr |
DataService * | data_service_ = nullptr |
RadioState | radio_state_ |
std::vector< NetworkOperator > | operator_list_ |
std::string | current_operator_numeric_ = "" |
OperatorSelectionMode | oper_selection_mode_ |
int | signal_strength_percent_ {80} |
NetworkRegistrationStatus | voice_registration_status_ |
NetworkRegistrationStatus | data_registration_status_ |
ModemTechnology | current_network_mode_ |
int | preferred_network_mode_ |
int | modem_radio_capability_ |
std::atomic< bool > | first_signal_strength_request_ |
std::atomic< time_t > | android_last_signal_time_ |
KeepSignalStrengthChangingLoop | keep_signal_strength_changing_loop_ |
Additional Inherited Members | |
![]() | |
static constexpr char | kCmeErrorOperationNotAllowed [] = "+CME ERROR: 3" |
static constexpr char | kCmeErrorOperationNotSupported [] = "+CME ERROR: 4" |
static constexpr char | kCmeErrorSimNotInserted [] = "+CME ERROR: 10" |
static constexpr char | kCmeErrorSimPinRequired [] = "+CME ERROR: 11" |
static constexpr char | kCmeErrorSimPukRequired [] = "+CME ERROR: 12" |
static constexpr char | kCmeErrorSimBusy [] = "+CME ERROR: 14" |
static constexpr char | kCmeErrorIncorrectPassword [] = "+CME ERROR: 16" |
static constexpr char | kCmeErrorMemoryFull [] = "+CME ERROR: 20" |
static constexpr char | kCmeErrorInvalidIndex [] = "+CME ERROR: 21" |
static constexpr char | kCmeErrorNotFound [] = "+CME ERROR: 22" |
static constexpr char | kCmeErrorInvalidCharactersInTextString [] |
static constexpr char | kCmeErrorNoNetworkService [] = "+CME ERROR: 30" |
static constexpr char | kCmeErrorNetworkNotAllowedEmergencyCallsOnly [] |
static constexpr char | kCmeErrorInCorrectParameters [] = "+CME ERROR: 50" |
static constexpr char | kCmeErrorNetworkNotAttachedDueToMTFunctionalRestrictions [] |
static constexpr char | kCmeErrorFixedDialNumberOnlyAllowed [] |
static constexpr char | kCmsErrorOperationNotAllowed [] = "+CMS ERROR: 302" |
static constexpr char | kCmsErrorOperationNotSupported [] = "+CMS ERROR: 303" |
static constexpr char | kCmsErrorInvalidPDUModeParam [] = "+CMS ERROR: 304" |
static constexpr char | kCmsErrorSCAddressUnknown [] = "+CMS ERROR: 304" |
static constexpr std::pair< int, int > | kRemotePortRange {6520, 6527} |
![]() | |
ModemService (int32_t service_id, std::vector< CommandHandler > command_handlers, ChannelMonitor *channel_monitor, ThreadLooper *thread_looper) | |
void | HandleCommandDefaultSupported (const Client &client) |
void | SendUnsolicitedCommand (std::string unsol_command) |
cuttlefish::SharedFD | ConnectToRemoteCvd (std::string port) |
void | SendCommandToRemote (ClientId remote_client, std::string response) |
![]() | |
static std::string | GetHostId () |
![]() | |
int32_t | service_id_ |
const std::vector< CommandHandler > | command_handlers_ |
ThreadLooper * | thread_looper_ |
ChannelMonitor * | channel_monitor_ |
|
private |
|
private |
cuttlefish::NetworkService::NetworkService | ( | int32_t | service_id_, |
ChannelMonitor * | channel_monitor, | ||
ThreadLooper * | thread_looper | ||
) |
|
default |
|
delete |
|
private |
|
staticprivate |
|
private |
|
private |
Preferred mode bitmask. This is actually 4 byte-sized bitmasks with different priority values, in which the byte number from LSB to MSB give the priority.
|MSB| | |LSB
value: |00 |00 |00 |00 byte #: |3 |2 |1 |0
Higher byte order give higher priority. Thus, a value of 0x0000000f represents a preferred mode of GSM, WCDMA, CDMA, and EvDo in which all are equally preferable, whereas 0x00000201 represents a mode with GSM and WCDMA, in which WCDMA is preferred over GSM
|
private |
|
private |
|
staticprivate |
NetworkService::RegistrationState cuttlefish::NetworkService::GetVoiceRegistrationState | ( | ) | const |
void cuttlefish::NetworkService::HandleDataNetworkRegistration | ( | const Client & | client, |
std::string & | command | ||
) |
AT+CGREG The set command controls the presentation of an unsolicited result code +CGREG: <stat> when <n>=1 and there is a change in the MT's GPRS network registration status, or code +CGREG: <stat>[,<lac>, <ci>[,<AcT>]] when <n>=2 and there is a change of the network cell.
command Possible response(s) +CGREG=[<n>] +CME ERROR: <err>
+CGREG? when <n>=0, 1, 2 or 3 and command successful: +CGREG: <n>,<stat>[,[<lac>],[<ci>],[<AcT>], [<rac>][,<cause_type>,<reject_cause>]] when <n>=4 or 5 and command successful: +CGREG: <n>,<stat>[,[<lac>],[<ci>],[<AcT>], [<rac>][,[<cause_type>],[<reject_cause>][, [<Active-Time>],[<Periodic-RAU>], [<GPRS-READY-timer>]]]] [,<cause_type>,<reject_cause>]]
note: see AT+CREG
see RIL_REQUEST_DATA_REGISTRATION_STATE in RIL
void cuttlefish::NetworkService::HandleGetPreferredNetworkType | ( | const Client & | client | ) |
|
private |
void cuttlefish::NetworkService::HandleNetworkRegistration | ( | cuttlefish::SharedFD | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleQueryAvailableNetwork | ( | const Client & | client | ) |
void cuttlefish::NetworkService::HandleQueryNetworkSelectionMode | ( | const Client & | client | ) |
AT+COPS Set command forces an attempt to select and register to the GSM/UMTS/EPS/5GS network operator using the SIM/USIM card installed in the currently selected card slot.
command Possible response(s) +COPS=[<mode>[,<format> +CME ERROR: <err> [,<oper>[,<AcT>]]]]
+COPS? +COPS: <mode>[,<format>,<oper>[,<AcT>]] +CME ERROR: <err>
+COPS=? +COPS: [list of supported (<stat>, long alphanumeric <oper>, short alphanumeric <oper>, numeric <oper>[,<AcT>])s] [,,(list of supported <mode>s), (list of supported <format>s)] +CME ERROR: <err>
<mode>: integer type 0 automatic (<oper> field is ignored) 1 manual (<oper> field shall be present, and <AcT> optionally) 2 deregister from network 3 set only <format> (for read command +COPS?), do not attempt registration/deregistration (<oper> and <AcT> fields are ignored); this value is not applicable in read command response 4 manual/automatic (<oper> field shall be present); if manual selection fails, automatic mode (<mode>=0) is entered <format>: integer type 0 long format alphanumeric <oper> 1 short format alphanumeric <oper> 2 numeric <oper> <oper>: string type; <format> indicates if the format is alphanumeric or numeric; <stat>: integer type 0 unknown 1 available 2 current 3 forbidden <AcT>: integer type; access technology selected 0 GSM 1 GSM Compact 2 UTRAN 3 GSM w/EGPRS (see NOTE 1) 4 UTRAN w/HSDPA (see NOTE 2) 5 UTRAN w/HSUPA (see NOTE 2) 6 UTRAN w/HSDPA and HSUPA (see NOTE 2) 7 E-UTRAN 8 EC-GSM-IoT (A/Gb mode) (see NOTE 3) 9 E-UTRAN (NB-S1 mode) (see NOTE 4) 10 E-UTRA connected to a 5GCN (see NOTE 5) 11 NR connected to a 5GCN (see NOTE 5) 12 NG-RAN 13 E-UTRA-NR dual connectivity (see NOTE 6)
see RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC or RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE or RIL_REQUEST_OPERATOR in RIL
void cuttlefish::NetworkService::HandleQuerySupportedTechs | ( | const Client & | client | ) |
void cuttlefish::NetworkService::HandleRadioPower | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleRadioPowerReq | ( | const Client & | client | ) |
AT+CFUN Set command selects the level of functionality <fun> in the MT. Level "full functionality" is where the highest level of power is drawn. "Minimum functionality" is where minimum power is drawn. Level of functionality between these may also be specified by manufacturers. When supported by manufacturers, MT resetting with <rst> parameter may be utilized
Command Possible response(s) +CFUN=[<fun>[,<rst>]] +CME ERROR: <err> +CFUN? +CFUN: <fun> +CME ERROR: <err>
<fun>: integer type 0 minimum functionality 1 full functionality. Enable (turn on) the transmit and receive RF circuits for all supported radio access technologies. 2 disable (turn off) MT transmit RF circuits only 3 disable (turn off) MT receive RF circuits only 4 disable (turn off) both MT transmit and receive RF circuits 5...127 reserved for manufacturers as intermediate states between full and minimum functionality 128 Full functionality with radio access support according to the setting of +CSRA. 129 Prepare for shutdown.
see RIL_REQUEST_RADIO_POWER in RIL
void cuttlefish::NetworkService::HandleReceiveRemoteCTEC | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleReceiveRemoteSignal | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleReceiveRemoteVoiceDataReg | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleRequestOperator | ( | const Client & | client | ) |
|
private |
void cuttlefish::NetworkService::HandleSetNetworkSelectionMode | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleSetPreferredNetworkType | ( | const Client & | client, |
std::string & | command | ||
) |
void cuttlefish::NetworkService::HandleSignalStrength | ( | const Client & | client | ) |
IMPORTANT NOTE: Current implementation of AT+CSQ differs from standards described in TS 27.007 8.5 which only only supports RSSI and BER.
TODO(b/206814247): Rename AT+CSQ command.
AT+CSQ Execution command returns received signal strength indication. This is a Cuttlefish specific command.
Command Possible response(s) AT+CSQ +CSQ: <gsm_rssi>,<gsm_ber>,<cdma_dbm>, <cdma_ecio>,<evdo_dbm>,<evdo_ecio>,<evdo_snr>, <lte_rssi>,<lte_rsrp>,<lte_rsrq>,<lte_rssnr>, <lte_cqi>,<lte_ta>,<tdscdma_rscp>,<wcdma_rssi>, <wcdma_ber>,<nr_ss_rsrp>,<nr_ss_rsrq>,<nr_ss_sinr>, <nr_csi_rsrp>,<nr_csi_rsrq>,<nr_csi_sinr> +CME ERROR: <err>
<gsm_rssi>: Valid values are (0-31, 99) as defined in TS 27.007 8.5. <gsm_ber>: Bit error rate (0-7, 99) as defined in TS 27.007 8.5. <cdma_dbm>: Valid values are positive integers. This value is the actual RSSI value multiplied by -1. Example: If the actual RSSI is -75, then this response value will be 75. <cdma_ecio>: Valid values are positive integers. This value is the actual Ec/Io multiplied by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value will be 125. <evdo_dbm>: Refer cdma_dbm. <evdo_ecio>: Refer cdma_ecio. <evdo_snr>: Valid values are 0-8. 8 is the highest signal to noise ratio. <lte_rssi>: Refer gsm_rssi. <lte_rsrp>: The current Reference Signal Receive Power in dBm multiplied by -1. Range: 44 to 140 dBm. INT_MAX: 0x7FFFFFFF denotes invalid value. Reference: 3GPP TS 36.133 9.1.4. <lte_rsrq>: The current Reference Signal Receive Quality in dB multiplied by -1. Range: 20 to 3 dB. INT_MAX: 0x7FFFFFFF denotes invalid value. Reference: 3GPP TS 36.133 9.1.7. <lte_rssnr>: The current reference signal signal-to-noise ratio in 0.1 dB units. Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). INT_MAX : 0x7FFFFFFF denotes invalid value. Reference: 3GPP TS 36.101 8.1.1. <lte_cqi>: The current Channel Quality Indicator. Range: 0 to 15. INT_MAX : 0x7FFFFFFF denotes invalid value. Reference: 3GPP TS 36.101 9.2, 9.3, A.4. <lte_ta>: Timing advance in micro seconds for a one way trip from cell to device. Approximate distance can be calculated using 300m/us * timingAdvance. Range: 0 to 0x7FFFFFFE. INT_MAX : 0x7FFFFFFF denotes invalid value. Reference: 3GPP 36.321 section 6.1.3.5. <tdscdma_rscp>: P-CCPCH RSCP as defined in TS 25.225 5.1.1. Valid values are (0-96, 255) as defined in TS 27.007 8.69. INT_MAX denotes that the value is invalid/unreported. <wcdma_rssi>: Refer gsm_rssi. <wcdma_ber>: Refer gsm_ber. <nr_ss_rsrp>: SS reference signal received power, multiplied by -1. Reference: 3GPP TS 38.215. Range [44, 140], INT_MAX means invalid/unreported. <nr_ss_rsrq>: SS reference signal received quality, multiplied by -1. Reference: 3GPP TS 38.215. Range [3, 20], INT_MAX means invalid/unreported. <nr_ss_sinr>: SS signal-to-noise and interference ratio. Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. Range [-23, 40], INT_MAX means invalid/unreported. <nr_csi_rsrp>: CSI reference signal received power, multiplied by -1. Reference: 3GPP TS 38.215. Range [44, 140], INT_MAX means invalid/unreported. <nr_csi_rsrq>: CSI reference signal received quality, multiplied by -1. Reference: 3GPP TS 38.215. Range [3, 20], INT_MAX means invalid/unreported. <nr_csi_sinr>: CSI signal-to-noise and interference ratio. Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. Range [-23, 40], INT_MAX means invalid/unreported.
see RIL_REQUEST_SIGNAL_STRENGTH in RIL
void cuttlefish::NetworkService::HandleVoiceNetworkRegistration | ( | const Client & | client, |
std::string & | command | ||
) |
AT+CREG Set command controls the presentation of an unsolicited result code +CREG: <stat> when <n>=1 and there is a change in the MT’s circuit mode network registration status in GERAN/UTRAN/E-UTRAN, or unsolicited result code +CREG: <stat>[,[<lac>],[<ci>],[<AcT>]] when <n>=2 and there is a change of the network cell in GERAN/UTRAN/E-UTRAN. The parameters <AcT>, <lac> and <ci> are sent only if available. The value <n>=3 further extends the unsolicited result code with [,<cause_type>, <reject_cause>], when available, when the value of <stat> changes.
command Possible response(s) +CREG=[<n>] +CME ERROR: <err>
+CREG? +CREG: <n>,<stat>[,[<lac>],[<ci>],[<AcT>] [,<cause_type>,<reject_cause>]]
<n>: integer type 0 disable network registration unsolicited result code 1 enable network registration unsolicited result code +CREG: <stat> 2 enable network registration and location information unsolicited result code +CREG: <stat>[,[<lac>],[<ci>],[<AcT>]] 3 enable network registration, location information and cause value information unsolicited result code +CREG: <stat>[,[<lac>],[<ci>], [<AcT>][,<cause_type>,<reject_cause>]]
<stat>: integer type; 0 not registered, MT is not currently searching a new operator to register to 1 registered, home network 2 not registered, but MT is currently searching a new operator to register to 3 registration denied 4 unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage) 5 registered, roaming
<lac>: string type; two byte location area code (when <AcT> indicates value 0 to 6), or tracking area code (when <AcT> indicates value 7). In hexadecimal format <ci>: string type; four byte GERAN/UTRAN/E-UTRAN cell ID in hexadecimal format <AcT>: refer line 190
see RIL_REQUEST_VOICE_REGISTRATION_STATE or in RIL
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
void cuttlefish::NetworkService::OnDataRegisterStateChanged | ( | ) |
void cuttlefish::NetworkService::OnSignalStrengthChanged | ( | ) |
void cuttlefish::NetworkService::OnSimStatusChanged | ( | SimService::SimStatus | sim_status | ) |
void cuttlefish::NetworkService::OnVoiceRegisterStateChanged | ( | ) |
|
delete |
void cuttlefish::NetworkService::SetupDependency | ( | MiscService * | misc, |
SimService * | sim, | ||
DataService * | data | ||
) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |