Study Notes on Android RIL source code: FIG (1)

Source: Internet
Author: User
The android source code directory hardware/RIL/libril contains a total of five C/CPP files: ril_commands.h, ril_unsol_commands.h, ril_event.h, ril_event.cpp, and rIL. cpp. This article mainly analyzes the two headers related to commands. These two files mainly define the types of commands or response events that telephony can receive and the corresponding processing functions.

Before analyzing the source code, we must first know that there are two processors in the current hardware architecture of mainstream smartphones: application processor (AP), which is mainly used to run operating systems and applications; it is called baseband processor (BP) and is responsible for the functions related to radio-frequency wireless communication in mobile phones. The AP and BP chips communicate with each other based on the serial port. The communication protocol is a widely used at command.

Next, let's take a look at the two response types in RIL:

First, solicited response (Request Reply). The application scenario is that AP actively sends an AT command to BP, request bp for corresponding processing and reply to an AT command at the end of processing to notify AP of the execution result. The corresponding file in the source code is ril_commands.h.

First, Unsolicited Response (unrequested reply). The application scenario is that BP actively sends an AT command to the AP to notify the AP of telephony-related events in the current system, such as network signal changes, incoming calls. The corresponding file in the source code is ril_unsol_commands.h.

First, take a look at the ril_commands.h file:

// Each column corresponds to: <br/> // The request received by BP-the processing function of the request-the processing function of the AP for the returned result <br/> {0, null, null}, // none </P> <p> // # define ril_request_get_sim_status 1 (in RIL. h) <br/> // obtain the sim interface and SIM card status, the input parameter "data" is null <br/> // The response function "response" is the const ril_cardstatus * <br/> // valid return code: none, this function must be successfully called <br/> {ril_request_get_sim_status, dispatchvoid, responsesimstatus }, </P> <p> // # define ril_request_enter_sim_pin 2 <br/> // enter the request pin code. "data" is const C Har ** <br/> // Where (const char **) data [0] is the PIN code <br/> // "response" is int *, (int *) Response) [0] indicates the number of remaining input Times <br/> // valid return code: success/radio_not_available/generic_failure/password_incorrect <br/> {ril_request_enter_sim_pin, dispatchstrings, responseints }, </P> <p> // # define ril_request_enter_sim_puk 3 <br/> // request the input of the PUK Code and the new PIN code, "data" is const char ** <br/> // (const char **) data) [0] is a pukcode, (const char **) data) [1] is the new PIN Code <br/> // "response" is int *, where (int *) response) [0] is the number of remaining input Times <br/> // valid return code: Success/radio_not_available/generic_failure/password_incorrect <br/> {delimiter, dispatchstrings, responseints }, </P> <p> // # define ril_request_enter_sim_pin2 4 <br/> // request the pin2 code input, "data" is const char ** <br/> // (const char **) data) [0] Is pin2 Code <br/> // "response" is int *, where (int *) response) [0] is the number of remaining input Times <br/> // valid return code: Success /Radio_not_available/generic_failure/password_incorrect <br/> {ril_request_enter_sim_pin2, dispatchstrings, responseints }, </P> <p> // # define ril_request_enter_sim_puk2 5 <br/> // request the puk2 Code and the new pin2 code input, "data" is const char ** <br/> // (const char **) data) [0] Is puk2 Code, (const char **) data) [1] is the new pin2 Code <br/> // "response" is int *, where (int *) response) [0] is the number of remaining input Times <br/> // valid return code: Success/radio_not_available/generic_failure/ Password_incorrect <br/> {delimiter, dispatchstrings, responseints}, </P> <p> // # define ril_request_change_sim_pin 6 <br/> // request to change the PIN code, "data" is const char ** <br/> // Where (const char **) data) [0] is the old PIN code (const char **) data) [1] is the new PIN code <br/> // "response" is int *, where (int *) response) [0] indicates the number of remaining input Times <br/> // valid return code: Success/radio_not_available/generic_failure/password_incorrect <br/> {ril_request_change_sim _ Pin, dispatchstrings, responseints}, </P> <p> // # define ril_request_change_sim_pin2 7 <br/> // request to change the pin2 code, "data" is const char ** <br/> // Where (const char **) data) [0] is the old pin2 Code, (const char **) data) [1] is the new pin2 Code <br/> // "response" is int *, where (int *) response) [0] is the number of remaining input Times <br/> // valid return code: Success/radio_not_available/generic_failure/password_incorrect <br/> {delimiter, dispatchstrings, responseints }, </P> <p> // # Define ril_request_enter_network_depersonalization 8 <br/> // request to enter the personal network code for activation. "data" is a const char ** <br/> // where, (const char **) data) [0] is the personal network code <br/> // "response" is int *, (int *) response) [0] is the remaining number of inputs <br/> // valid return code: Success/radio_not_available/generic_failure/password_incorrect <br/> {delimiter, dispatchstrings, responseints }, </P> <p> // # define ril_request_get_current_call S 9 <br/> // request to obtain the current call list, "data" is null <br/> // "response" type must be const ril_call ** <br/> // The valid return code is: success/radio_not_available/generic_failure <br/> {ril_request_get_current_cils, dispatchvoid, responsecalllist }, </P> <p> // # define ril_request_dial 10 <br/> // initialize a voice call, "data" is of the const ril_dial * type <br/> // "response" is null <br/> // The valid return code is: success/radio_not_available/generic_failure <br/> {ril_request_dial, dispatch Dial, responsevoid}, </P> <p> // # define ril_request_get_imsi 11 <br/> // obtain the imsi from the SIM card, only when radio_state_sim_ready is available <br/> // "data" is null, and "response" is a const char * type containing imsi <br/> // The valid return code is: success/radio_not_available/generic_failure <br/> {ril_request_get_imsi, dispatchvoid, responsestring }, </P> <p> // # define ril_request_hangup 12 <br/> // hangs up an active call, similar to the AT command: At + chld = 1X; when the handup request returns, rIL will be in the <br/> // next ril_re When a quest_get_current_cils request is sent, the connection is unavailable. <br/> // "data" is int *, where (int *) data) [0] contains the connected index, that is, the X value in the above chld <br/> // "response" is null <br/> // The valid return code is success/radio_not_available/generic_failure <br/> {ril_request_hangup, dispatchints, responsevoid}, </P> <p> // # define ril_request_hangup_waiting_or_background 13 <br/> // hangs up all pending or maintained calls, similar to the AT command: at + chld = 0; when the handup request returns, <br/> // RIL will display this in the next ril_request_get_current_cils request Connection unavailable <br/> // "data" and "response" are both null <br/> // The valid return code is: success/radio_not_available/generic_failure <br/> {ril_request_hangup_waiting_or_background, dispatchvoid, responsevoid }, </P> <p> // # define ril_request_hangup_foreground_resume_background 14 <br/> // release all activated calls and enable or wait for the calls, similar to the AT command: at + chld = 1 <br/> // when the handup request returns <br/> // RIL will send the next ril_request_get_current_cils request, show that this connection is unavailable <br/> // "data" and "response" are both NUL L <br/> // valid return code: Success/radio_not_available/generic_failure <br/> {ril_request_hangup_foreground_resume_background, dispatchvoid, responsevoid }, </P> <p> // # define ril_request_switch_waiting_or_holding_and_active 15 <br/> // converts the call connection status to keep or wait for all active calls, you can also change the <br/> // call that is maintained or waiting to the active state, similar to the AT command: At + chld = 2 <br/> // There are several types of status conversion, assume that call 1 is in the waiting state, call in active state <br/> // After conversion <br/> // call 1 call 2 call 1 call 2 <br/> // active holding hold Ing active <br/> // active waiting holding active <br/> // holding waiting holding active <br/> // active idle holding idle <br/> // idle idle idle <br/> // "data" and "response" are both null <br/> // The valid return code is: success/radio_not_available/generic_failure <br/> {ril_request_switch_waiting_or_holding_and_active, dispatchvoid, responsevoid }, </P> <p> // # define ril_request_conference 16 <br/> // request to join the teleconference, similar to the AT command: At + chld = 3 <br/> // "data" and "response" are both null <br/> // valid return code: Success/radio_not_available/generic_failure <br/> {ril1_conference, dispatchvoid, responsevoid}, </P> <p> // # define ril_request_udub 17 <br/> // send the user to confirm that the user is busy with UDub (User determined user busy) signal <br/> // "data" and "response" are both null <br/> // valid return code: Success/radio_not_available/generic_failure <br/> {ril_request_udub, dispatchvoid, responsevoid}, </P> <p> // # define ril_re Quest_last_call_fail_cause 18 <br/> // The error code for the last call interruption. "data" is null, and "response" is int * <br/> // (int *) response) [0] is the ril_lastcallfailcause type. <Br/> // valid return code: Success/radio_not_available/generic_failure <br/> {ril_request_last_call_fail_cause, dispatchvoid, responseints }, </P> <p> // # define ril_request_signal_strength 19 <br/> // request the current signal strength and other information, when the antenna is turned on, a success message must be returned. <br/> // "data" is null, and "response" is const ril_signalstrength. <br/> // The valid return code is: success/radio_not_available <br/> {login, dispatchvoid, responserilsignalstrength}, </P> <p> // # define Limit 20 <br/> // request the current registration status, "data" is null, "response" is of the const char ** type <br/> // (const char **) Response) [0] indicates the registration status. The values are as follows: <br/> // 0-not registered, mobile terminal Mt does not search for a new carrier to register currently <br/> // 1-registered, local Network <br/> // 2-not registered, mobile Terminal MT is currently searching for a new carrier to register <br/> // 3-registration rejected <br/> // 4-unknown <br/> // 5-registered, roaming <br/> // 10-similar to 0, but indicates the Enable of an emergency call <br/> // 12-similar to 2, but indicates the emergency call enable <br/> // 13-similar to 3, but indicates the emergency call enable <br/> // 14-similar to 4, however, it indicates that an emergency call can be enabled <br/> // (const char **) Response) [1]. If it is registered on a GSM/WCDMA network, it indicates a lac, <br/> // otherwise it is null, and the valid LAC value is 0x0000 -- 0 xFFFF <br/> // (const char **) Response) [2], if it is registered on a GSM/WCDMA network, it indicates CID, <br/> // otherwise it is null, the valid CID value is 0x00000000 -- 0 xffffffff <br/> // In the GSM network, CID indicates the cell id, expressed as 16bits <br/> // UMTS network (3G network), CID refers to UMTS cell identity, expressed as 28bits <br/> // (const char **) response) [3], indicating available wireless technology: <br/> // 0-unknown, 1-GPRS, 2-edge, 3-UMTS, 4-is95a, 5-is95b <br/> // 6-1 xrtt, 7-evdo rev.0, 8-evdo rev. a, 9-HSDPA, 10-hsupa <br/> // 11-HSPA, 12-evdo Rev B <br/> // (const char **) response) [4], indicating the base station ID in the CDMA network, otherwise null <br/> // the base station ID is in decimal format <br/> // (const char **) response) [5], indicating the base station latitude in the CDMA network; otherwise, null <br/> // (const char **) Response) [6], the Base Station longitude in the CDMA network; otherwise, null <br/> // (const char **) Response) [7], indicates whether concurrent services are supported in the CDMA network <br/> // 0-not supported, 1-supported <br/> // (const char **) response) [8], indicating the System ID in the CDMA network; otherwise, null <br/> // value range: 0-32767 <br/> // (const char **) response) [9], indicating the network ID in the CDMA network, otherwise null <br/> // value range: 0-65535 <br/> // (const char **) Response) [10], TSB-58 roaming indicator in CDMA and evdo networks <br/> // otherwise null, valid value is 0-255 <br/> // (const char **) response) [11], indicating in CDMA and evdo networks whether the current system is in the top 5 <br/> // otherwise it is null, 0-not in, 1-In <br/> // (const char **) Response) [12], the default TSB-58 roaming indicator in the CDMA and evdo networks <br/> // otherwise null, valid value is 0-255 <br/> // (const char **) response) [13]. If the registration status is 3 (registration denied), this value indicates the reason <br/> // The value is as follows: 0-average, 1-authentication failed, 2-imsi is unknown in HLR, 3-illegal ms, // 4-illegal me, 5-plmn not allowed, 6-Local Network not allowed, 7-roaming is not allowed. <br/> // 8-no cellular site is available on the local network. The 9-network is invalid, 10-continuously locate update rejection // (const char **) Response) [13], the main scrambling code of the current cellular site, in decimal format <br/> // null if it is not registered in the UMTS network or the registration status is unknown <br/> // Note: When the registration status is unknown, cannot be used as a service in the Android phone system <br/> {ril_request_registration_state, dispatchvoid, responsestrings },

To be continued

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.