Android core analysis-Android phone system-Overview

Source: Internet
Author: User

Android phone system overview

First, let alone all the concepts of Android to study the most basic descriptions of the telephone system. Our mobile phone was first used for phone calls, followed by a phone book, followed by PIM, followed by network applications, followed by cloud computing, followed by the idea that our mobile phone can do anything to replace PC. However, the basic functions of a phone call are as follows:

0) dialing, answering, hanging up, sending SMS, network connection, and PIM Management

1) Since telephone operators provide us with additional services such as call waiting and teleconference, how should we manage multiple calls on our mobile phones?

2) When we call, we want to broadcast the incoming call ringtone. When we connect, we need to switch the voice channel. This has dealt with the multimedia system. For example, we have plugged in a headset and connected a Bluetooth headset, how should the system manage and switch?

3) How do I connect to and connect to the LinuxSocket channel through PPP when establishing a network path (such as GSM GPRS) for Internet access? How does the system manage data connections?

4) when the AP communicates with the Modem, how does one change the AT command into a specific operation function, how does one manage the response sent by the Modem to us, how does one manage the AT command channel and Data Channel?

5) how to manage the SIM card phone book?

Android phone system designers must answer the above basic questions about mobile phones. What is the management framework of the design and what concepts are proposed to express it? Therefore, to analyze the phone number of Android, we still need to understand the background of telephone implementation, communication protocols, and general framework.

Back to the basic structure of the telephone system, let's first take a look at the general framework of the telephone module from the air. The figure I provided is a framework of a general smartphone. This framework can summarize the composition of all phone modules, including the Android phone system.

The smart machine architecture is generally an application processor + Modem. The application processor and Modem are connected using a serial port or USB. To achieve data transmission and control Modem at the same time in a hardware serial port path, the multiplexing protocol (GSM TS07.10) must be implemented ), at the underlying layer, we virtualize two serial ports, one for the CMD channel and the other for the DATA channel. All telephone control channels are on this channel.

RIL, Radio Interface Layer. This layer is a protocol transfer layer, and the mobile phone framework needs to adapt to multiple types of Modem access to the system. For different Modem features, the AT command format or response varies, however, this feature cannot be fully considered and compatible during application design. Therefore, when designing a telephone system, the designer establishes a virtual telephone system and sets out standard functions for the virtual telephone system. The upper-layer telephone management is based on these standard functions. RIL converts the Standard Functions of the virtual phone system into the AT commands of the Modem in use.

Android designers have designed the telephone system into three parts.

The Phone Service of Andoird is actually a PhoneApp. GSMPhone (CDMAPhone) is the core object of the Phone Service. It contains the following related objects.

Our analysis task is to clarify the relationships between these objects and their data transmission relationships. First, we provide the following Android phone system framework to give a brief understanding of the Android phone system, and then analyze the system from the perspective of data flow and the reference relationship of objects. The following figure shows the overall framework of the android phone system.




  • Android phone system-rild

    Rild is a local service started by the Init process. This local service does not use communication methods such as Binder, but uses socket communication. RIL (Radio Interface Layer)

    Android provides a ril implementation framework. Because the Modem used by Android Developers is different, the various command formats and initialization sequences may be different, and the difference between GSM and CDMA is even greater. to eliminate these differences, android designers abstract ril and use the concept of a virtual phone. The virtual phone object is the GSM phone (CDMAPhone). The functional protocols provided by the Phon object and the underlying supporting environment must have a uniform description, the implementation of this underlying description relies on RIL for adaptation.

    Andoid divides the RIL layer into two code spaces: The RILD management framework and the AT-related xxxril. so Dynamic Link Library. The advantage of separating RIL into a dynamic link library is that the Android system adapts to different Modem, and there can be an independent Ril corresponding to different modes. From this perspective, Rild is more of a management framework.

    Ril is the specific AT command synthesizer and response parser. In terms of the most basic functions, ril establishes a listening Socket, waits for the client connection, and then reads RIL-Java from the connection into the passed command and converts it into the AT command and sends it to the Modem. Wait for the Modem to respond, and then pass the result back to the Ril-Java layer through the socket. Is the basic framework of Ril-D:

    The following data flow transfer description chart describes the 5 steps for the RIL-JAVA layer to issue a telephone instruction.

     

    There are two types of responses in the AT communication process: one is to give a response after a request, and the other is a notification, that is, the response is not sent by yourself, for example, the SMS notification reaches, we call this type of notifications URC. In Rild, URC and general Response are processed separately. In concept, URC is processed by the handleUnsolicited@Atchannel.c, while Response is processed by handleFinalResponse.

    1 Event Loop

    The true essence of Rild management is in ril. cpp, ril_event.cpp. During the study, we can see the designer's efforts in abstraction, and the design is very elegant. The basic task of Event Loop is to wait on the Event port (serial port, Socket). Once data arrives, it is processed according to the registered Event Callback Function. Now let's look at how Ril designers set up a management framework to complete these tasks?

    1.1 Event object

    Composition of Event objects: (fd, index, persist, func, param)

    Fd Event-related device handle. For example, for a serial data event, fd is the device handle of the relevant serial port.
    Index  
    Persist If it is maintained, it is not deleted from watch_list.
    Func Callback event processing function
    Param Callback Parameters

    To manage events in a unified manner, Android uses three Queues: watch_list, timer_list, and pending_list, and uses a device handle pool readFDS.

    ReadFDS: fd_set of Linux. readFDS stores all the device file handles in Rild, so that the select function can be used to uniformly listen events.

    Watch_list: monitoring time queue. All events to be detected are put in this queue.

    Timer_list: timer queue

    Pending_list: the queue of events to be processed. events that have been triggered and need to be called back.

    Operations on the event queue: ril_event_add, ril_event_del, ril_timer_add

    In the add operation, there are two actions:

    (1) Add to watch_list

    (2) Add the handle to the readFDS event handle pool.

    1.2 ril_event_loop ()

    We know that for Linux devices, we can use the select function to wait on FDS. As long as the device recorded in FDS has data, the select function sets the corresponding flag and returns the result. ReadFDS records all event-related device handles. In readFDS, the handle is added in AddEvent. All event listening is based on select readFDS in linux.

    Ril_event_loop uses select to wait on readFDS (fd_set). When the select device has data, ril_event_loop returns from select and places the corresponding Event in watch_list to pend_list, if the Event is persistent, It is not deleted from watch_list. Then ril_event_loop traverses pengding_list to process Event Events and initiate an Event Callback Function.

    1.3 important events

    The above analysis shows the ril-d Framework. What are the running events on this framework?

    (1) s_listen_event-(s_fdListen, listenCallback)

    ListenCallback processing function,

    Receive client connection: s_fdCommand = accepte (..)

    Add s_commands_event ()

    Re-establish s_listen_event and wait for the next connection

    (2) s_command_event (s_fdCommand, ProcessCommandsCallback)

    Read StreamRecord from the fdCommand Socket connection

    Use ProcessCommandBufer to process data

    S_listen_event processes client connections (connect initiated by the Ril-JAVA layer) with large functions, and establishes s_commands_event to process Ril commands sent from Socket connections. ProcessCommandBufer actually contains the downlink process of the Ril command.

    1.4 downstream Command Translation and its organization @ ProcessCommandBuffer

    The Command Format passed by RIL_JAVA: Parcel, which consists of the command number, Token, and content. When RIL_JAVA reaches RIL_C, it is converted to build local RequestInfo and translated into specific AT commands. Because the parameters of each AT command are different, there are different conversion functions for different AT commands. In this Android design, an abstraction is provided here and a distribution framework is developed, use the command number and the sCommand array to obtain the processing function of the command.

    SComand [] = {

    <...>

    }

    SComand exists in Ril_command.h.

    & SComand [] =

    <

    {RIL_REQUEST_GET_IMEI, dispatchVoid, responseString },

    {RIL_REQUEST_DIAL, dispatchDial, responseVoid },

    {....}

    >

    DispatchXxx functions are generally placed in the Reference-ril.c, Reference-ril.c this is what we need to modify according to different Modem files.

    1.5 send_at_command framework

    Send_at_command is synchronous. After the command is sent, send_at_command will wait in s_commandcond until sp_response-> finalResponse exists.

    2 read loop@Atchannel.c

    Read loop resolves the problem by parsing the response sent from the Modem. RIL_JAVA reported by handleUnsolicited in case of URC. If it is a command response, handleFinalResponse is used to notify send_at_command of the response result.

     

    For URC, Rild also uses an abstract array @ Ril. CPP.

    Static UnsolResponseInfo s_unsolResponses [] = {

    # Include "ril_unsol_commands.h"

    };

    And use RIL_onUnsolicitedResponse to send the URC to the upstream layer.


  • Android phone system overview

    First, let alone all the concepts of Android to study the most basic descriptions of the telephone system. Our mobile phone was first used for phone calls, followed by a phone book, followed by PIM, followed by network applications, followed by cloud computing, followed by the idea that our mobile phone can do anything to replace PC. However, the basic functions of a phone call are as follows:

    0) dialing, answering, hanging up, sending SMS, network connection, and PIM Management

    1) Since telephone operators provide us with additional services such as call waiting and teleconference, how should we manage multiple calls on our mobile phones?

    2) When we call, we want to broadcast the incoming call ringtone. When we connect, we need to switch the voice channel. This has dealt with the multimedia system. For example, we have plugged in a headset and connected a Bluetooth headset, how should the system manage and switch?

    3) How do I connect to and connect to the LinuxSocket channel through PPP when establishing a network path (such as GSM GPRS) for Internet access? How does the system manage data connections?

    4) when the AP communicates with the Modem, how does one change the AT command into a specific operation function, how does one manage the response sent by the Modem to us, how does one manage the AT command channel and Data Channel?

    5) how to manage the SIM card phone book?

    Android phone system designers must answer the above basic questions about mobile phones. What is the management framework of the design and what concepts are proposed to express it? Therefore, to analyze the phone number of Android, we still need to understand the background of telephone implementation, communication protocols, and general framework.

    Back to the basic structure of the telephone system, let's first take a look at the general framework of the telephone module from the air. The figure I provided is a framework of a general smartphone. This framework can summarize the composition of all phone modules, including the Android phone system.

    The smart machine architecture is generally an application processor + Modem. The application processor and Modem are connected using a serial port or USB. To achieve data transmission and control Modem at the same time in a hardware serial port path, the multiplexing protocol (GSM TS07.10) must be implemented ), at the underlying layer, we virtualize two serial ports, one for the CMD channel and the other for the DATA channel. All telephone control channels are on this channel.

    RIL, Radio Interface Layer. This layer is a protocol transfer layer, and the mobile phone framework needs to adapt to multiple types of Modem access to the system. For different Modem features, the AT command format or response varies, however, this feature cannot be fully considered and compatible during application design. Therefore, when designing a telephone system, the designer establishes a virtual telephone system and sets out standard functions for the virtual telephone system. The upper-layer telephone management is based on these standard functions. RIL converts the Standard Functions of the virtual phone system into the AT commands of the Modem in use.

    Android designers have designed the telephone system into three parts.

    The Phone Service of Andoird is actually a PhoneApp. GSMPhone (CDMAPhone) is the core object of the Phone Service. It contains the following related objects.

    Our analysis task is to clarify the relationships between these objects and their data transmission relationships. First, we provide the following Android phone system framework to give a brief understanding of the Android phone system, and then analyze the system from the perspective of data flow and the reference relationship of objects. The following figure shows the overall framework of the android phone system.

    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.