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層了。
所調用的架構圖:
文章轉載自:點擊開啟連結