Android phone Functions

Source: Internet
Author: User

The Android mobile operating system is an open-source system based on the Linux platform. Developers can modify and perform other operations based on their needs. There are many important functions in this system that deserve our research. For example, the Android phone function is one of the basic knowledge points.

  • Android plotting application method summary
  • Android Activity lifecycle Overview
  • Summary of key Android development experiences
  • Detailed steps of the Android build Module
  • In-depth analysis of the Android File System

Part 1 Android phone Functions

Android's Radio Interface Layer (RIL) provides an abstraction Layer between the telephone service and the radio hardware.

Radio Interface Layer RIL (Radio Interface Layer) is responsible for reliable data transmission, AT command transmission, and response Parsing. The application processor communicates with the wireless communication module with the GPRS function through the AT command set.

Invented by Hayes, AT command is a modem command language used by a modem manufacturer. Each command starts with the letter ".

JAVA Framework

The code path is:

 
 
  1. Frameworks/base/telephony/java/android/telephony
  2. Android. telephony and android. telephony. gsm

Core native:

In the hardware/ril directory, the local code supported by RIL is provided, including four folders:

 
 
  1. hardware/ril/include   
  2. hardware/ril/libril   
  3. hardware/ril/reference-ril   
  4. hardware/ril/rild 

Kernel Driver

The Linux Kernel Driver provides support for related drivers, which can be built on UART, SDIO, USB, and other high-speed serial buses.

Part 2 Android phone Functions

The ril. h file in the hardware/ril/include/telephony/directory is the basic header file of the ril part.

The struct RIL_RadioFunctions is defined as follows:

 
 
  1. typedef struct {  
  2. int version;  
  3. RIL_RequestFunc onRequest;  
  4. RIL_RadioStateRequest onStateRequest;  
  5. RIL_Supports supports;  
  6. RIL_Cancel onCancel;  
  7. RIL_GetVersion getVersion;  
  8. } RIL_RadioFunctions; 

RIL_RadioFunctions contains the struct of several function pointers. This is actually an interface at the porting layer. After implementation of the underlying library, the rild daemon obtains these function pointers and executes the corresponding functions.

The prototype of several function pointers is:

 
 
  1. typedef void (*RIL_RequestFunc) (int request, void *data,   
  2. size_t datalen, RIL_Token t);  
  3. typedef RIL_RadioState (*RIL_RadioStateRequest)();  
  4. typedef int (*RIL_Supports)(int requestCode);  
  5. typedef void (*RIL_Cancel)(RIL_Token t);  
  6. typedef const char * (*RIL_GetVersion) (void); 

The most important function is onRequest (), which is a function executed by the request.

2.1 rild daemon

The rild daemon file is included in the hardware/ril/rild Directory, which contains rild. c and radiooptions. c files. The files in this directory are compiled to generate an executable program. The installation path of this program in the system is as follows:

 
 
  1. /system/bin/rild 

Rild. c is the entrance of this daemon. It has the main function entry. The execution process is to convert the request to the string of the AT command and run it on the underlying hardware. During running, use dlopen to open the dynamic library named libreference-ril.so in the path/system/lib/, and then extract the RIL_Init symbol to run.

The RIL_Init symbol is a function pointer. After executing this function, a RIL_RadioFunctions type pointer is returned. After obtaining the pointer, call the RIL_register () function, register the pointer to the libril library, and enter the loop.
In fact, this daemon provides a framework for application processing, and the specific features are all done in libril. so and libreference-ril.so.

2.2 libreference-ril.so dynamic library

Libreference-ril.so dynamic library path is:

 
 
  1. hardware/ril/reference-ril  

Among them, Android phone function mainly files are reference-ril.c and atchannel. c. This library must implement a function named RIL_Init. The result of this function is to return a pointer to the RIL_RadioFunctions struct, pointing to the function pointer.
During the execution of this library, you need to create a thread to execute the actual functions. In the execution process, the library will open a/dev/ttySXXX terminal name is passed in from the upper layer), and then use this terminal to control hardware execution.

2.3 libril. so dynamic library

The Directory of the libril. so library is:

 
 
  1. hardware/ril/libril  

The main file is ril. cpp. The following interfaces must be implemented in this library:

 
 
  1. RIL_startEventLoop(void);  
  2. void RIL_setcallbacks (const RIL_RadioFunctions *callbacks);  
  3. RIL_register (const RIL_RadioFunctions *callbacks);  
  4. RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, 
    size_t responselen);  
  5. void RIL_onUnsolicitedResponse(int unsolResponse, void *data,   
  6. size_t datalen);  
  7. RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,   
  8. const struct timeval *relativeTime); 

These functions are also called by the rild daemon. Different vendors can implement these interfaces in their own ways to ensure that RIL can be transplanted to different systems. Here, the RIL_register () function registers the external RIL_RadioFunctions struct into this library and calls the corresponding function at the appropriate time. During the execution of the Android phone function, this library processes some functions that convert requests into strings.

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.