Data Process Analysis of phone calls in Android

Source: Internet
Author: User

1. the starting point of all the processes is to press the dialing key after dialing. The code for this step is TwelveKeyDialer in the/android sourcecode/packages/Contacts/src/com/android/contacts/directory. in the java file, the related code is as follows: Copy codeThe Code is as follows: dialButtonPressed (){
.........
Final String number = mDigits. getText (). toString ();
StartActivity (newDialNumberIntent (number ));
MDigits. getText (). clear ();
Finish ();
}

The newDialNumberIntent () method in the Code is defined as follows::Copy codeThe Code is as follows: private Intent newDialNumberIntent (String number ){
Final Intent intent = new Intent (Intent. ACTION_CALL_PRIVILEGED, Uri. fromParts ("tel", number, null ));
.............
}

From the definition of newDialNumberIntent, we can see that when the dialing key is pressed, TwelveKeyDial starts a specific component whose ACTION is ACTION_CALL_PRIVILEGED. After searching, the component started by this ACTION is under the following: a/android sourcecode/packeges/Phone/file under which AndroidMenifest. in xml, we can find that the name of the Activity started by "ACTION_CALL_PRIVILEGED" is PrivilegedOutgoingCallBroadcast, but we can find it in/android sourcecode/packeges/Phone/src /.... the file cannot be found because the file is stored inAndroidMenifest. xml is a bit special:
<Activity-alias/>. This label indicates that this Activity is the alias of another Activity. The actual Activity is marked with "android: targetActivity = OutgoingCallBroadcast" in the tag, therefore, the actual "Identity" of the PrivilegedOutgoingCallBroadcast started by "ACTION_CALL_PRIVILEGED" is "OutgoingCallBroadcast ".

2. At this time, the phone data has been transferred to OutgoingCallBroadcast. java.
The onCreate () method of OutgoingCallBroadcast. java includes:Copy codeThe code is as follows: <PRE class = java name = "code"> protected void onCreate (Bundle icicle ){
.......
Intent intent = getIntent ();
........
String action = intent. getAction ();
.......
Final boolean emergencyNum = (number! = Null) & PhoneNumUtils. isEmergencyNumber (number); // determines whether the number is an emergency number.
.......
If (Intent. ACTION_CALL_PRIVILEGED.equals (action )){
Action = emergencyNum? Intent. ACTION_CALL_EMERGENCY: Intent. ACTION_CALL;
Intent. setAction (action );
}
.......
Intent. setClass (this, InCallScreen. class );
StartActivity (intent );
} </PRE> <P> </P>
<PRE> </PRE>
In this method, if the received ACTION is "ACTION_CALL_PRIVILEGED", convert the value based on whether the entered number is an emergency number. If it is an emergency number, ACTION = Intent. ACTION_CALL_EMERGENCY; otherwise, ACTION = Intent. ACTION_CALL, and start the conversion Activity: InCallScreen. java
<P> </P>
<P> 3. InCallScreen. java is still in the/packeges/Phone/src/com/android/phone directory. </P>
<P> call initInCallScreen in onCreate of InCallScreen to initialize the call interface, and call registerForPhoneStates to register the call status listener. <BR>
</P>
<P> the onNewIntent () methods include: </P>
<P> <PRE class = java name = "code"> protected void onNewIntent (Intent intent ){
..........
String action = intent. getAction ();
..........
Else if (action. equals (Intent. ACTION_CALL) | action. equals (Intent. ACTION_CALL_EMERGENCY )){
..........
InCallInitStatus status = placeCall (intent );
}
}
// PlaceCall
Private InCallInitStatus placeCall (Intent intent ){
..............
Int callStatus = PhoneUtils. placeCall (........);
} </PRE> the placeCall method in InCallScreen. java calls the placeCall method of the PhoneUtils. java file. <BR>
<P> </P>
<P> 4. PhoneUtils. java is still in the/packeges/Phone/src/com/android/phone directory. </P>
<P> <PRE class = java name = "code"> public static int placeCall (...){
Connection connection;
Connection = PhoneApp. getInstance (). mCM. dial (phone, numberToDial );
} </PRE> continue tracing. in java, we found that mCM is CallManager. an object of the java class, while CallManager. java belongs to the frameworks layer. Therefore, the data stream has already entered frameworks. <P> </P>
<P> 5. Enter the/frameworks/base/telephony/java/com/android/internal/telephony directory. </P>
<P> In the dial () method of CallManager. java, there are: </P>
<P> <PRE class = java name = "code"> <SPAN style = "BACKGROUND-COLOR: rgb (255,255,255); FONT-FAMILY: Arial, Verdana, sans-serif; WHITE-SPACE: normal "> </SPAN> <PRE class = java name =" code "> public Connection dial (Phone phone, String dialNumber) throws CallStateException {
Phone basePhone = getPhoneBase (phone );
Connection result;
<SPAN style = "COLOR: # 3333ff"> result = basePhone. dial (dialString); </SPAN>
........
}
Private static Phone getPhoneBase (Phone phone ){
If (phone instanceof PhoneProxy ){
<SPAN style = "COLOR: # ff0000"> return phone. getForegroundCall (). getPhone (); </SPAN>
}
Return phone;
} </PRE> <P> </P>
<PRE> </PRE>
<PRE class = java name = "code"> <SPAN style = "BACKGROUND-COLOR: rgb (255,255,255); FONT-FAMILY: Arial, Verdana, sans-serif; WHITE-SPACE: normal "> continue tracing: </SPAN> </PRE> <PRE class = java name =" code "> <SPAN style =" BACKGROUND-COLOR: rgb (255,255,255); FONT-FAMILY: Arial, Verdana, sans-serif; WHITE-SPACE: normal "> PhoneBase. java Abstract class implements the interface Phone. java, while GSM phone. java implements the abstract class PhoneBase, so: </SPAN> </PRE>
<P> </P>
<P> in the above Code: phone. getForegroundCall () is equivalent to the getForegroundCall () method executed by the GSMPhone object. </P>
<P> 6. Continue to trace GSMPhone. java, which is located in/frameworks/base/telephony/java/com/android/internal/telephony/gsm. </P>
<P> <PRE class = java name = "code"> GSMPhone. java:
GsmCallTracker mCT;
Public GsmCall getForegroundCall (){
Return mCT. foregroundCall;
} </PRE> it can be seen that the getForegroundCall () function continues to call the foregroundCall attribute of GsmCallTracker. java. <P> </P>
<P> 7. GsmCallTracker. java is located under/frameworks/base/telephony/java/com/android/internal/telephony/gsm/. </P>
<P> <PRE class = cpp name = "code"> GsmCallTracker. java:
GSMCall foregroundCall = new GSMCall (this); </PRE> <P> </P>
<P> open GSMCall. java, find the getPhone () method, and find: </P>
<P> <PRE class = java name = "code"> GSMCallTracker owner;
Public Phone getPhone (){
Return owner. phone;
} </PRE> <P> </P>
<P> the GSMCallTracker. java statement is as follows: </P>
<P> <PRE class = cpp name = "code"> GSMPhone phone; </PRE> <P> </P>
<P> <SPAN style = "COLOR: # ff0000"> at this point, we come to the conclusion that Part 1 of the Code marked red returns the object of GSMPhone, </SPAN> <SPAN style = "COLOR: # 3333ff"> we can conclude that Part 1 of the Code marked in blue calls the dial method of the GSMPhone object. </SPAN> </P>
<P> 8. In GSMPhone. java: </P>
<P> <PRE class = java name = "code"> GSMCallTracker mCT;
Public Connection dial (String dialString) throws CallStateException {
Return dial (dialString, null );
}
Public Connection dial (String dialString, UUSInfo uusInfo) throws CallStateException {
.......
MCT. dial (.......);
} </PRE> <P> </P>
<P> continue to call the dial () method in GSMCallTracker. java: </P>
<P> <PRE class = cpp name = "code"> GSMCallTracker. java:
GSMCallTracker (GSMPhone phone ){
Cm = phone. mCM;
}
Connection dial (String dialString, int clirMode, UUSInfo uusInfo ){
<SPAN style = "COLOR: # ff0000"> cm. dial (...); </SPAN>
} </PRE> tracked mCM and found: <P> </P>
<P> public CommandsInterface mCM; </P>
<P> therefore, GSMCallTracker holds the CommandsInterface object, that is, the RIL. Java class object. Therefore, "cm. dial (...)" is to call the dial () method of the RIL class object. </P>
<P> 9. RIL. java </P>
<P> the BOSS is displayed. </P>
<P> the RIL object is responsible for sending client call requests to the "rild" socket in a certain format. At this point, the request process is complete. </P>
</PRE>

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.