自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

OpenHarmony 電話子系統(tǒng)源碼解析之Cellular_Data

系統(tǒng) OpenHarmony
APP調(diào)用數(shù)據(jù)業(yè)務(wù)的流程會(huì)依次經(jīng)過Data Service,Core Service,RIL Adapter/RILD,再經(jīng)過AT命令的處理到達(dá)CP處理器。

??想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:??

??51CTO 開源基礎(chǔ)軟件社區(qū)??

??https://ost.51cto.com??

一、電話子系統(tǒng)概述

電話服務(wù)子系統(tǒng)各個(gè)模塊主要作用如下:

核心服務(wù)模塊:主要功能是初始化RIL管理、SIM卡和搜網(wǎng)模塊。

數(shù)據(jù)服務(wù)模塊:主要功能是實(shí)現(xiàn)數(shù)據(jù)上網(wǎng)和路由管理相關(guān)的業(yè)務(wù)。

通話管理模塊:主要功能是管理CS(Circuit Switch,電路交換)、IMS(IP Multimedia Subsystem,IP多媒體子系統(tǒng))和OTT(over the top,OTT解決方案)三種類型的通話,申請通話所需要的音視頻資源,處理多路通話時(shí)產(chǎn)生的各種沖突。

蜂窩通話模塊:主要功能是實(shí)現(xiàn)基于運(yùn)營商網(wǎng)絡(luò)的基礎(chǔ)通話。

短彩信模塊:主要功能是短信收發(fā)和彩信編解碼。

狀態(tài)注冊模塊:主要功能是提供電話服務(wù)子系統(tǒng)各種消息事件的訂閱以及取消訂閱的API。

1、 電話子系統(tǒng)框架圖

二、 Cellular_Data(數(shù)據(jù)服務(wù)模塊)

1、 代碼目錄

\base\telephony\ cellular_data
├─ frameworks # napi接口存放目錄
├─ interfaces # 對外部暴露的接口
├─ services # 服務(wù)內(nèi)部代碼
├─ apn_manager # apn管理
├─ state_machine # data 狀態(tài)機(jī)
├─ utils # 通用邏輯
└─ 外部files
├─ sa_profile # sa文件
├─ ohos.build # 編譯build
└─ test # 測試相關(guān)

2、 流程圖

APP調(diào)用數(shù)據(jù)業(yè)務(wù)的流程會(huì)依次經(jīng)過Data Service,Core Service,RIL Adapter/RILD,再經(jīng)過AT命令的處理到達(dá)CP處理器。

CP處理器處理完數(shù)據(jù)命令后,會(huì)依次將結(jié)果再返回,到達(dá)Data Service,最終將獲得的上網(wǎng)相關(guān)數(shù)據(jù),如ip,interface,gateway,dns等設(shè)置到netmanager/netd,最終配置到kernel中。

流程圖如下:

3、data service初始化流程

Data service的初始化流程如下圖所示:

具體的代碼調(diào)用流程如下:

\telephony\cellular_data\services\src\cellular_data_service.cpp

在OnStart函數(shù)中先等待CoreService啟動(dòng)成功WaitCoreServiceToInit,然后進(jìn)行data service的init初始化流程。

在初始化init流程中,會(huì)依次進(jìn)行InitModule的初始化,主要是生成CellularDataController和netd相關(guān)的對象的初始化.

\telephony\cellular_data\services\src\cellular_data_controller.cpp

在AsynchronousRegister函數(shù)中,會(huì)依次進(jìn)行CellularDataController的初始化、注冊監(jiān)聽事件、注冊database監(jiān)聽。還有要進(jìn)行CellularDataHandler的初始化。

注冊的監(jiān)聽事件包括了網(wǎng)絡(luò)狀態(tài)的監(jiān)聽、radio狀態(tài)的監(jiān)聽和電話狀態(tài)的監(jiān)聽等,這些都會(huì)對數(shù)據(jù)的狀態(tài)產(chǎn)生影響。

\telephony\cellular_data\services\src\cellular_data_handler.cpp

CellularDataHandler的Init函數(shù)中,主要是對apn管理相關(guān)的模塊進(jìn)行初始化,包含ApnManager和ApnHolder等。

\telephony\cellular_data\services\src\apn_manager\ apn_manager.cpp
\telephony\cellular_data\services\src\apn_manager\ apn_holder.cpp.cpp
\telephony\cellular_data\services\src\apn_manager\ apn_item.cpp

apn_manager負(fù)責(zé)對所有apn進(jìn)行管理,包括創(chuàng)建、查找和刪除等操作。

apn_holder就是一個(gè)apn profile。

4、data service建立流程

Data service的建立流程如下圖所示:

具體的代碼調(diào)用流程如下:

\telephony\core_service\interfaces\innerkits\cellular_data\ 
cellular_data_manager.cpp
\telephony\core_service\interfaces\innerkits\cellular_data\
cellular_data_service.cpp
\telephony\core_service\interfaces\innerkits\cellular_data\
cellular_data_controller.cpp
\telephony\core_service\interfaces\innerkits\cellular_data\
cellular_data_handler.cpp

按照上面的時(shí)序圖可以看出,從cellular_data_manager->cellular_data_service-> cellular_data_controller->cellular_data_handler,是直接調(diào)用Enable CellularData。主要的流程在cellular_data_handler中,具體說明EstablishDataConnection過程中比較重要的流程,其中包含了data狀態(tài)機(jī)的創(chuàng)建EstablishDataConnection和connect event的發(fā)送:

\telephony\cellular_data\services\src\state_machine\ cellular_data_state_machine.cpp:

創(chuàng)建default data所需要的狀態(tài)機(jī),類似的,任何類型的數(shù)據(jù),應(yīng)該都會(huì)創(chuàng)建其所對應(yīng)的狀態(tài)機(jī):

std::shared_ptr<CellularDataStateMachine> CellularDataHandler::CreateCellularDataConnect()  
{
auto cellularDataStateMachine =
std::make_shared<CellularDataStateMachine>(connectionManager_, shared_from_this(), GetEventRunner());
if (cellularDataStateMachine == nullptr) {
TELEPHONY_LOGE("cellularDataStateMachine is null");
return nullptr;
}
sequence_++;
intStateMachineMap_[sequence_] = cellularDataStateMachine;
return cellularDataStateMachine;
}

接下來會(huì)進(jìn)行data狀態(tài)機(jī)的init初始化操作,會(huì)依次創(chuàng)建Active、Inactive等狀態(tài)到狀態(tài)機(jī)中,并設(shè)置初始狀態(tài)為Active,為后續(xù)的data connect做好準(zhǔn)備:

void CellularDataStateMachine::Init()  
{
activeState_ = std::make_unique<Active>(
std::weak_ptr<CellularDataStateMachine>(shared_from_this()), "Active").release();
inActiveState_ = std::make_unique<Inactive>(
std::weak_ptr<CellularDataStateMachine>(shared_from_this()), "Inactive").release();
activatingState_ = std::make_unique<Activating>(
std::weak_ptr<CellularDataStateMachine>(shared_from_this()), "Activating").release();
disconnectingState_ = std::make_unique<Disconnecting>(
std::weak_ptr<CellularDataStateMachine>(shared_from_this()), "Disconnecting").release();
defaultState_ = std::make_unique<Default>(
std::weak_ptr<CellularDataStateMachine>(shared_from_this()), "Default").release();
netProviderInfo_ = std::make_unique<NetProviderInfo>().release();
netLinkInfo_ = std::make_unique<NetLinkInfo>().release();
if (activeState_ == nullptr || inActiveState_ == nullptr || activatingState_ == nullptr ||
disconnectingState_ == nullptr || defaultState_ == nullptr || netProviderInfo_ == nullptr ||
netLinkInfo_ == nullptr) {
TELEPHONY_LOGE("memory allocation failed");
return;
}
activeState_->SetParentState(defaultState_);
inActiveState_->SetParentState(defaultState_);
activatingState_->SetParentState(defaultState_);
disconnectingState_->SetParentState(defaultState_);
StateMachine::SetOriginalState(inActiveState_);
StateMachine::Start();
}

在上面狀態(tài)機(jī)創(chuàng)建的過程中,最后會(huì)建立數(shù)據(jù)請求:

這個(gè)流程會(huì)按照狀態(tài)機(jī)當(dāng)前的狀態(tài)來執(zhí)行,會(huì)先走到inactive狀態(tài)中,執(zhí)行真正的DoConnect,并轉(zhuǎn)換狀態(tài)到Activating。

最終是通過狀態(tài)機(jī)的DoConnect來建立數(shù)據(jù)的:

\telephony\cellular_data\services\src\state_machine\ cellular_data_state_machine.cpp:

接下來就會(huì)將建立數(shù)據(jù)的請求發(fā)送給core,最終發(fā)送給ril_adapter,完成數(shù)據(jù)建立的流程。

??想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:??

??51CTO 開源基礎(chǔ)軟件社區(qū)??

??https://ost.51cto.com??。

責(zé)任編輯:jianghua 來源: 鴻蒙社區(qū)
相關(guān)推薦

2022-02-17 20:57:07

OpenHarmon操作系統(tǒng)鴻蒙

2022-01-06 16:17:58

鴻蒙HarmonyOS應(yīng)用

2021-09-18 14:40:37

鴻蒙HarmonyOS應(yīng)用

2021-11-08 15:04:47

鴻蒙HarmonyOS應(yīng)用

2021-12-17 16:42:09

鴻蒙HarmonyOS應(yīng)用

2023-04-12 15:31:11

系統(tǒng)服務(wù)管理鴻蒙

2022-01-10 15:30:11

鴻蒙HarmonyOS應(yīng)用

2021-11-18 10:28:03

鴻蒙HarmonyOS應(yīng)用

2022-05-24 15:46:51

Wi-FiSTA模式

2021-09-13 15:15:18

鴻蒙HarmonyOS應(yīng)用

2023-04-06 09:14:11

多模輸入子系統(tǒng)鴻蒙

2022-01-13 10:11:59

鴻蒙HarmonyOS應(yīng)用

2023-06-28 15:00:02

開源鴻蒙輸入系統(tǒng)架構(gòu)

2021-09-17 14:38:58

鴻蒙HarmonyOS應(yīng)用

2022-01-20 14:33:29

openharmonwayland協(xié)議鴻蒙

2022-02-14 14:47:11

SystemUIOpenHarmon鴻蒙

2022-03-18 16:07:04

Graphic子系統(tǒng)鴻蒙

2022-05-17 10:42:36

reboot源碼解析

2021-09-16 15:08:08

鴻蒙HarmonyOS應(yīng)用

2022-06-13 14:18:39

電源管理子系統(tǒng)耗電量服務(wù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號