android 拨号上网流程

android 网络拨号流程:

frameworks\base\services\java\com\android\server\ ConnectivityService.java
->[MyHandler ->handleMessage ->case EVENT_SET_MOBILE_DATA ->handleSetMobileData]
frameworks\base\services\java\com\android\server\ ConnectivityService.java
->[mNetTrackers[ConnectivityManager.TYPE_MOBILE].reconnect()]
frameworks/base/core/java/android/net/MobileDataStateTracker.java
extends NetworkStateTracker
->[reconnect()]
frameworks/base/core/java/android/net/MobileDataStateTracker.java
->[setEnableApn]

..\base\telephony\java\com\android\internal\telephony\ITelephony.java
->[enableApnType]
packages\apps\phone\src\com\android\phone\
PhoneInterfaceManager.java (extends ITelephony.Stub ) 实现
->[enableApnType-> mPhone.enableApnType(type)]
{那么这个mPhone是哪里来的,通过源代码我们发现在PhoneInterfaceManger的构造函数传进去的。在PhoneApp.java 的OnCreate 函数里创建了一个PhoneInterfaceManger对象, PhoneFactory.makeDefaultPhones(this);
phone = PhoneFactory.getDefaultPhone(); 也就是说这里的Phone要么是CDMAPhone 的实例要么是GSMPhone 的实例,因为CDMAPhone extends PhoneBase,GSMPhone extends PhoneBase.}
frameworks\base\telephony\java\com\android\internal\telephony\
PhoneBase.java extends Handler implements Phone
->[enableApnType]
frameworks\base\telephony\java\com\android\internal\telephony\
DataConnectionTracker.java
->[enableApnType() -> setEnabled() -> handleMessage -> case EVENT_ENABLE_NEW_APN -> onEnableApn()]
{这里稍微解释下, CDMAPhone ,GSMPhone 都是继承 PhoneBase. 而DataConnectionTracker 是PhoneBase 的一个成员字段,该对象的初始化分别是在CDMAPhone ,GSMPhone 类里,对应CdmaDataConnectionTracker, GsmDataConnectionTracker ,因为此二类分别继承DataConnectionTracker,所以具体是调用那个类的函数,要根据前面传进的是CDMAPhone 或者GSMPhone ,这个流程以GSMPhone 示例。}
frameworks\base\telephony\java\com\android\internal\telephony\gsm\
GsmDataConnectionTracker .java extends DataConnectionTracker
->[onEnableNewApn() -> cleanUpConnection() -> conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE, reason))]



frameworks\base\telephony\java\com\android\internal\telephony\
DataConnectionTracker.java
->[handleMessage ->case EVENT_DISCONNECT_DONE -> onDisconnectDone()]
frameworks\base\telephony\java\com\android\internal\telephony\gsm\
GsmDataConnectionTracker.java
->[onDisconnectDone() -> trySetupData(reason) -> setupData(reason)]
frameworks\base\telephony\java\com\android\internal\telephony\
DataConnection.java
->[processMessage -> case EVENT_CONNECT -> onConnect(cp)]

frameworks\base\telephony\java\com\android\internal\telephony\gsm\
GsmDataConnection .java
->[phone.mCM.setupDataCall()]
{phone.mCM 类型为CommandsInterface,也是根据CMDAPhone 或者GSMPhone 决定的,那么两者都是RIL 的实例,RIL implements CommandsInterface , 其实是根据RIL的构造函数,根据参数int networkMode 来决定。 注意:如果是Sip 就另当别论了,那么phone.mCM 就是通过SipPhoneBase 构造函数传给父类PhoneBase的构造函数,参数CommandsInterface,其实现 SipCommandInterface ,因为SipPhoneBase implements Phone, SipCommandInterface implements CommandsInterface }
RIL
->[setupDataCall()]
到这里, java层的pppd请求就通过RIL发到C层了。


所调用的框架图:

 

 

 

 

你可能感兴趣的:(转载,Android)