Data flow analysis of phone calls in Android _android

Source: Internet
Author: User
Tags abstract gettext
1. The starting point for all processes is to start by pressing the dialing key after dialing, the code for this step is/android sourcecode/packages/contacts/src/com/android/contacts/ In the Twelvekeydialer.java file for the directory, the relevant code is as follows:
Copy Code code 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 Code code as follows:

Private Intent Newdialnumberintent (String number) {
Final Intent Intent = new Intent (intent.action_call_privileged, Uri.fromparts ("tel", number, null));
.............
}

As you can see from the definition of newdialnumberintent, when the dialing key is pressed, Twelvekeydial starts a particular component that has the ACTION: action_call_privileged, after the lookup, The component that the ACTION starts is a file from/android sourcecode/packeges/phone/, which can be found in Androidmenifest.xml under the file: "Action_call_privileged "The name of the activity that starts is: privilegedoutgoingcallbroadcast, but we go to/android sourcecode/packeges/phone/src/...." The file cannot be found at this time because the file is the mark in the Androidmenifest.xml is a little special
<activity-alias/&gt, this label means that the activity is an alias for another activity, and the real activity is used in the label "android:targetactivity = Outgoingcallbroadcast "marked out, so" action_call_privileged "initiated by the privilegedoutgoingcallbroadcast corresponding to the true" identity "is" Outgoingcallbroadcast ".

2. This time the phone data has been streaming into the Outgoingcallbroadcast.java.
In the OnCreate () method of Outgoingcallbroadcast.java, there are:
Copy Code code 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 (numbers);
.......
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 action received is "action_call_privileged", the conversion is based on whether the number entered is an emergency number, and if it is an emergency number, then the action = Intent.action_call_ Emergency, otherwise ACTION = Intent.action_call, and start conversion Activity:InCallScreen.java
<P></P>
<p>3. Incallscreen.java is still under the/packeges/phone/src/com/android/phone of the catalogue. </P>
Call the Initincallscreen initialization call interface in <p>incallscreen's OnCreate, and call registerforphonestates registered phone status monitor .<br>
</P>
<P> has:</p> in the Onnewintent () method
<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 (...);
The Placecall method in}</pre>incallscreen.java invokes the Placecall method of the Phoneutils.java file. <BR>
<P></P>
<p>4. Phoneutils.java is still under the/packeges/phone/src/com/android/phone of the catalogue. </P>
<p><pre Class=java name= "code" >public static int Placecall (...) {
Connection Connection;
Connection = Phoneapp.getinstance (). Mcm.dial (phone, numbertodial);
}</pre> continues to follow, In Phoneapp.java, MCM is an object of the Callmanager.java class, and Callmanager.java belongs to the frameworks layer, so this time the data stream has entered the 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 (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 tracking will find: </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 Gsmphone.java implements the abstract class Phonebase, so: </span></ Pre>
<P></P>
<P> in the above code: Phone.getforegroundcall () is actually equivalent to the Gsmphone object executing the Getforegroundcall () method. </P>
<p>6. Continue tracking Gsmphone.java, which is located under/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> can see that the Getforegroundcall () function continues to invoke the Foregroundcall property of the 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 Getphone () method, find:</p>
<p><pre Class=java name= "code" >gsmcalltracker owner;
Public Phone Getphone () {
return owner.phone;
}</pre><p></p>
The <P> in Gsmcalltracker.java has the following statement:</p>
<p><pre class=cpp name= "code" >gsmphone phone;</pre><p></p>
<p><span style= "COLOR: #ff0000" > Here we come to the conclusion that the code marked red in part 5th returns Gsmphone objects, </span><span style= "COLOR: #3333ff" > Further, the code in the 5th blue tag is the dial method that invokes the Gsmphone object. </SPAN></P>
<p>8. In the 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 invoke 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> traces MCM and finds:<p></p>
<p>public Commandsinterface mcm;</p>
<P> so Gsmcalltracker holds commandsinterface objects, i.e. objects of Ril.java classes, so "cm.dial (...)" That is, the dial () method that invokes the Ril class object. </P>
<p>9. Ril.java</p>
<p>boss appeared. </P>
<p>ril object is responsible for the client call request in accordance with a certain format sent to the "rild" socket, so far, the request process completed. </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.