Android Core Analytics-----Android phone System Ril-java

Source: Internet
Author: User

Android Ril-java

Ril-java is essentially a RIL agent that plays a forwarding role and is the starting point of the phone system in the Android Java conceptual space. In Ril-d's analysis, we know that Rild set up a listening socket interface, waiting for Ril-java connections. Once the connection is successful, Ril-java can initiate a request, wait for the reply, and send the structure to the target processing object. In Ril-java, this request is called Rilrequest. For the sake of intuition, I still bother to give out Ril-java frame diagram.

The large framework of Ril-java contains four aspects:

Receiver,sender,commandinterface, asynchronous notification mechanism

(1) Command Interface

In the Ril.java source code, we can see that the Ril-java object provides the following command Interface:

...

getlcccardstatus

getcurrrentcalls

dial

acceptcall

rejectcall

SENDDTMF

sendsms

setupdatacall

setradiopower

...

V.25ter at Commands

3GPP 07.07 at Comamnds-general commands

3GPP 07.07 at Comamnds-call Control Commans

3GPP 07.07 at Comamnds-network Service related commands

3GPP 07.07 at comamnds-mt control and Status command

3GPP 07.07 at Comamnds-gprs Commands

3GPP 07.07 Mobile Termination Errors

3GPP 07.05 SMS at Commands

(2) Receiver

Receiver connects to the Rild service socket interface, receiving the response Parcel that the read Rild passes over. There are two types of response, one is URC and the other is command answering. For URC will be distributed directly to the handler in the notification registry. and the command reply is passed to the sender of the command through receiver's asynchronous notification mechanism to handle accordingly.

(3) Sender

Sender should be structured in two parts,

The upper function calls command interface to send the request message to the sender's schema.

After sender receives the event_send message, it sends the request to the schema of the Rild.

(4) Asynchronous Response framework

For asynchronous replies, the initiator of the command is sent, does not wait for the reply to return, the response is asynchronous, and the processing result is returned by the message. From the perspective of the designer, how to design the appropriate framework to complete the function of asynchronous communication? For asynchronous systems The first thing we should consider is how to identify the command and result, have a correspondence between the command and the result, and the command is not responding, how to manage the command timeout? Let's take a look at how Android designers are doing this.

The Android Designer uses the result Message and the Rilrequest object to complete the request and result corresponds to the relationship. When a call is made on the upper layer, the result message object is passed to Ril_java, and after the modem has an answer, the results are brought back through the result message object. How to ensure that the answer is the rilrequest? The Android Designer also provided a token (token) concept. The Mserail rilrequest in the source code is used as token. Token is used to uniquely identify each request sent, and token will be passed to Rild,rild when the assembly answer is to write the token and pass it back to Ril-java,ril-java to find the corresponding request object based on the token.

(4.1) The Send mode of the RIL command

The real implementation of the protocol is in the Rild, Ril-java more is an abstraction and proxy, we in the process of studying the source code will realize that the command function in Ril-java has a common framework.

Sendxxxcmd (incoming parameter data, outgoing parameter result) {

Combination Rilrequest (Request number, Result,mserail)

Data->rr

Send (Rilrequest): <event_send, rr= "" >message

}

1) rilrequest

Request Number:

The request is passed to Rild to identify the command, which represents a feature. For example, the dialed REQUEST number is: Ril_request_dial. There is a definition in libs/telephony/ril_commands.h. [email protected] According to the command request number, the incoming parameter result message,mserail constructs a rilrequest. Result message returns the reply message back to the initiator of the command.

Mserail:

Android uses a Rilrequest object pool to manage Andoird rilrequest. Mserail is a variable that is incremented to uniquely identify a rilrequest. This variable is used as token when it is sent, and tokens seen at the rild layer are the mserail.

Event_end:

[email protected]@[email protected]

2) Send the steps:

The first step:

Generates a rilrequest that will generate m_serial (the requested token) and fill the request number, data, and result Message object into Rilrequest

Step Two:

Use Send to package rilrequest to the event_send message to Ril sender Handler,

Step Three:

Rilsender receives the Event_send message, sends rilrequest through the socket to Rild, and saves Rilrequest in Mrequest in order to reply to the return of the message.

(4.2) Receiving mode

The first step: Analyze the received parcel, according to different types of processing.

The second step: according to the token (mserail) in the data, reverse the mrequest, find the corresponding request information.

The third step: the data will be converted into the result data.

Fourth step: Place the result in the requestmessage and send it back to the initiator of the request.

4.3) detailed Gsmcalltracker,ril-java function control

Android Core Analytics-----Android phone System Ril-java

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.