Address: http://yangyangzhao.blog.163.com/blog/static/17581636620101163758306/
In the non-startup interface networking practice of the android RIL module (I), we finally found that we only need to call the radiooptions program to achieve the goal of networking. Everything seems simple.
Actually how? Call radiooptions In the android shell to obtain its usage
Bash-4.1 # radiooptions
Usage: radiooptions [Option] [extra_socket_args]
0-radio_reset,
1-radio_off,
2-unsol_network_state_change,
3-qxdm_enable,
4-qxdm_disable,
5-radio_on,
6 APN-setup_pdp APN,
7-deactive_pdp,
8 number-dial_call number,
9-answer_call,
10-end_call
: Unknown error: 0
First, call radio on (in fact, I tried the experiment when the interface has been started, so I don't need to call it specifically). I found that the log is as follows:
Bash-4.1 # radiooptions 5
I/rilc (110): debug port: Radio on
D/rilc (110): c [locl]> radio_power
Bash-4.1 # D/rilc (110): c [locl] <radio_power
D/rilc (110): c [locl]> set_network_selection_automatic
D/rilj (1673): [unsl] <unsol_response_network_state_changed
D/rilj (1673): [0233]> Operator
D/rilc (110): c [locl] <set_network_selection_automatic
It seems that libril will try to find a network operator after receiving the radio on message, and then try to connect to setup data call. I am using a mobile card, so the APN name is cmnet, so we try to pass in the cmnet Parameter
Bash-4.1 # radiooptions 6 cmnet
I/rilc (110): debug port: setup data call, APN: cmnet
D/rilc (110): c [locl]> setup_data_call
Bash-4.1 # E/rilj (190): Hit EOS reading message length
I/rilj (190): disconnected from 'rild' socket
D/rilb (190): policying: Radio not available
D/rilb (190): policying: radio off or not available
D/GSM (190): poll servicestate done: oldss = [0 home (n/a) 46000 edge CSS not supported-1-1 roamind: -1 defroamind:-1] newss = [1 home null unknown CSS not supported-1-1 roamind:-1 defroamind: -1] oldgprs = 0 newgprs = 0 oldtype = edge newtype = edge
D/rilj (190): [0000]> get_current_cils
D/rilj (190): [0000] <get_current_callerror: COM. Android. Internal. telephony. commandexception: radio_not_available
D/GSM (190): gsmdataconntrack handlemessage {What = 12 when = 547391 OBJ = Android. OS. asyncresult @ 45ce59c8}
D/GSM (190): [gsmdataconnectiontracker] radio is off and clean up all connection
D/GSM (190): [gsmdataconnectiontracker] Clean Up Connection due to radioturnedoff
D/GSM (190): [gsmdataconnectiontracker] setstate: Disconnecting
D/GSM (190): [pdpconnection] dataconnection. clearsettings ()
D/GSM (190): [dataconnection] Stop poll netstat
D/GSM (190): [gsmdataconnectiontracker] setstate: idle
D/GSM (190): [icccard] broadcasting intent action_sim_state_changed not_ready reason null
D/rilj (190): [0001]> request_get_neighboring_cell_ids
D/rilj (190): [0001] <request_get_neighboring_cell_ids error: COM. Android. Internal. telephony. commandexception: radio_not_available
I/rilj (190): connected to 'rild' socket
I/rilc (468): libril: New Connection
I/rilc (468): RIL daemon version: HTC-RIL 1.6.1053g (Feb 2 2010,21: 48: 07)
D/rilj (190): [unsl] <unsol_response_radio_state_changed radio_unavailable
After the above log is output, the cell phone signal is gone ........... -_-| After the phone is restarted, the signal can finally be found.
It seems that using radiooptions to setup data call is not feasible. Let's see how to connect to GPRS on the interface. I opened the mobile network option and found that it is connected to the network in this way.
D/rilj (190): [0079]> setup_data_call 1 0 cmnet none 3
D/GSM (190): [gsmdataconnectiontracker] setstate: initing
D/rilj (190): [unsl] <unsol_data_call_list_changed [datacallstate: {CID: 1, active: 2, type: IP, APN: cmnet, address: 10.129.168.228}, datacallstate: {CID:-1, active: 0, type:, APN:, address:}, datacallstate: {CID:-1, active: 0, type:, APN:
, Address:}]
D/GSM (190): gsmdataconntrack handlemessage {What = 6 when = 466064 OBJ = Android. OS. asyncresult @ 45c701b8}
D/rilj (190): [0079] <setup_data_call {1, rmnet0, 10.129.168.228}
What is the difference between connecting to the network with radiooptions? There are many more parameters. setup_data_call 1 0 cmnet none 3. Here there are 6 parameters, while radiooptions only has one parameter, of course it won't work. Let's look at the libril and refrence-RIL code.
- static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) //refrence-ril
- {
- const char *apn;
- char *cmd;
- int err;
- ATResponse *p_response = NULL;
- char *response[2] = { "1", PPP_TTY_PATH };
-
- apn = ((const char **)data)[2];
-
- static void debugCallback (int fd, short flags, void *param) { //libril
- int acceptFD, option;
- struct sockaddr_un peeraddr;
- socklen_t socklen = sizeof (peeraddr);
- int data;
- unsigned int qxdm_data[6];
- const char *deactData[1] = {"1"};
- char *actData[1];
- RIL_Dial dialData;
- int hangupData[1] = {1};
- int number;
- char **args;
-
- //blabla
- case 6:
- LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
- actData[0] = args[1];
- issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
- sizeof(actData));
- break;
-
Note that only one parameter is passed in libril, And the APN parameter in reference-RIL is obtained from the second parameter. In this way, the reference-RIL will be crash if it is forcibly converted, it's no wonder that after I call it that way, there will be no signal on the phone...
After finding out the error, it will be much easier to change it. First, you need to change the parameter passed to reference-RIL in libril. Here I changed it directly.
- issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, /*&actData,
- sizeof(actData));*/
- &args[1], 6*sizeof(args[1]));
-
Then, remove the setup data call Parameter Restriction in radiooptions.
Therefore, this problem is completely solved. I don't know if this is a bug in RIL?