Android source code analysis-call and text message

Source: Internet
Author: User

1. in our android application, the itelephony interface, ISMs interface, and aidl call itelephony phone = (itelephony) as follows to implement dialing. stub. asinterface (servicemanager. getservice ("Phon") phone. dial ("10086"); For text message applications, we need to call smsmanager. The Code is as follows: smsmanager manager = smsmanager. getdefault (); manager. sendtextmessage ("10086", null, "Hi, this is SMS", null, null); here, smsmanager encapsulates ISMs by calling ISMs simisms = isms. stub. asinterface (Servic Emanager. getservice ("isms"); simisms. sendrawpdu... you can see that applications use aidl to implement cross-process scheduling of IPC. For aidl applications, the caller has a proxy object that implements the interface. The proxy object communicates with the stub object in the called process to implement cross-process scheduling of IPC. Therefore, there must be an itelephony at the end of the called process. stub and isms. stub class implementation.

2. phoneinterfacemanager and simsmsinterfacemanager itelephony. the implementation class of stub is com. android. phone. phoneinterfacemanager isms. the implementation class of stub is com. android. internal. telephony. GSM. simsmsinterfacemanager clearly shows the service registration from the call code of the constructor of these two classes. servicemanager. addservice ("phone", this); servicemanager. addservice ("isms", this );

3. phoneapp, incallscreen, phoneutils, and other related classes can be seen from the implementation of simsmsintefermanager related methods, specifically by calling the smsdispatcher instance of gsmphone for related operations. The phoneinterfacemanager maintains a reference of the phone object. When a dial-up application is used, phoneinterfacemanager will pass the constructed intent to the phoneapp. The classname of the intent is specified as incallscreen, we can see that incallscreen is implemented by calling the phone method in phoneutils. How does phoneinterfacemanager obtain the corresponding phone object and then transfer the phone object to incallscreen? The phoneapp class is involved here. This class maintains a phoneinterfacemanager reference (phonemgr) and a phone reference (phone). We can clearly see from the oncreate method of this class, phoneapp obtains a phone instance through phonefactory and implements the phoneinterfacemanager object through the instance. Therefore, we only need to pay attention to the phone instance provided by phonefactory. In addition, the phoneapp class also provides a static method getinstance for incallscreen to call. incallscreen obtains the phoneapp instance by calling this method to obtain the corresponding phone instance. Next, we can see through the phonefactory method that the phone object corresponds to a gsmphone instance.

4. According to the GSM constructor, gsmphone and rIL depend on a commandinterface instance. Through the makedefaphphones method of phonefactory, we can see that Ro depends on the system environment variable. radio. noril is used to determine whether the RIL framework is used for implementation. If this parameter is not empty, simultedcommands is used (mainly to test the required simulation implementation ). otherwise, use RIL. Through Google to know, RIL is actually a smart phone on the Implementation of AP and BP communication between a design idea, specific you can refer to this article http://www.eetchina.com/ARTICLES/2006OCT/PDF/CPCOL_2006OCT26_EMB_TA_170.PDF? Sources = download we are pleasantly surprised to see in RIL. Java that RIL processes messages by sending messages to a famous port named rild through localsocket. This famous socket is created in the RIL. cpp code. S_fdlisten = android_get_control_socket (socket_name_ril) the original Android call and text message application is implemented through socket connection between Java and C ++ code to transmit messages.

5. The interaction between the C code and the hardware is actually that the C code sends at commands through the serial port to dial and send and receive text messages. I am a little tired today. I will analyze the specific implementation next time.

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.