移动开发 之 手动搜网过程.docx
- 文档编号:23692387
- 上传时间:2023-05-19
- 格式:DOCX
- 页数:18
- 大小:99.98KB
移动开发 之 手动搜网过程.docx
《移动开发 之 手动搜网过程.docx》由会员分享,可在线阅读,更多相关《移动开发 之 手动搜网过程.docx(18页珍藏版)》请在冰豆网上搜索。
移动开发之手动搜网过程
移动开发系列
之
手动搜网流程
简介
在手机的移动网络设置里,有一项搜网网络的功能,如下图所示:
通过搜索网络,可以把手机所在环境的网络给搜索出来,如上图的下半部分。
那么搜索网络的功能是如何实现的呢?
这就是本文所要重点阐述的内容。
本文主要基于Android+Qualcomm的平台来描述搜索网络的步骤,每一步都有函数的调用关系,以及每一步的关键Log。
因此要阅读本文,最好有Android的源码和高通平台的代码。
搜索网络,原理其实就是对所有的频段,以某种制式(比如LTE)进行扫描,检查到同步信号后,读取相应的系统参数,如PLMN。
只要知道PLMN,就可以确定是哪个运营商的网络。
但是这都是物理层做的事情,本文这一部分要忽略掉,要想对搜索的过程有一个详细的了解,可以参考本系列的《LTE小区搜索过程》
本文主要描述从应用层开始,如果把搜索网络的请求下发的RRC层,RRC层把搜网的请求发给物理层,得到结果后又是如何上报给上层应用的。
步骤
Step1:
应用调用phone的接口getAvailableNetworks,该接口在GSMPhone和CDMAPhone都有实现,下面以GSMPhone为例。
Step2:
GSMPhone:
getAvailableNetworks
调用的是Ril层的getAvailableNetworks。
Step3:
RIL:
getAvailableNetworks
向底层发送消息RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,如下面的ril的log
09-1711:
24:
13.614D/RILJ(6268):
[9730]>QUERY_AVAILABLE_NETWORKS[SUB0]
Step4:
qcril_qmi_nas:
qcril_qmi_nas_query_available_networks
发送QMI消息QMI_NAS_PERFORM_NETWORK_SCAN_REQ_MSG_V01到modem
QMI
2015Sep1703:
24:
16.037[7B]0x138EQMILink1RXPDU
IFType=1
QmiLength=16
QmiCtlFlags=0
QmiType=NAS
Service_Nas{
ClientId=1
SduCtlFlags=REQ
TxId=244
MsgType=QMI_NAS_PERFORM_NETWORK_SCAN_MSG
MsgLength=4
QmiNasPerformNetworkScan{
QmiNasPerformNetworkScanReqTlvs[0]{
Type=16
Length=1
NetworkTypeTlv{
network_type=GSM|UMTS|LTE|TD-SCDMA
}
}
}
}
Step5:
qmi_nas:
qmi_nasi_perform_network_scan
调用cm_ph_cm_get_network_extn
Cm:
cm_ph_cm_get_network_extn
调用cm_ph_cm_get_network_per_subs_extn这里发送命令CM_PH_CMD_GET_NETWORKS
MSG03:
24:
16.037MMODEQMI/Mediumqmi_nas.c09851StartingNetScan,waitingforresponse
Step6:
cmph_client_cmd_proc
cmph_client_cmd_proc
cmph_client_cmd_forward_mmll处理CM_PH_CMD_GET_NETWORKS消息,处理函数为:
cmph_cmd_get_networks_poc:
调用mmoc_cmd_get_network_gw
MSG03:
24:
16.037CallManager/Highcmph.c14139=CM=CM_PH_CMD_GET_NETWORKSsys_mode5
MSG03:
24:
16.038CallManager/Highcmph.c20439=CM=GET_NETmodepref39uemodecapability1704
MSG03:
24:
16.038CallManager/Highcmph.c20443=CM=GET_NET.bands(MSB):
cgw0x00020000,lte0x00000180tds0x00000000
MSG03:
24:
16.038CallManager/Highcmph.c20447=CM=GET_NET.bands(LSB):
cgw0x00680180,lte0x00000005tds0x00000000
Step7:
mmoc:
mmoc_cmd_get_network_gw
发送命令PROT_GEN_CMD_GET_NETWORKS_GW,处理该命令也在mmoc的
Mmoc_proc_prot_gen_cmd,调用sd_ss_ind_user_get_net_gw_ss
Step8:
sd:
sd_ss_ind_user_get_net_gw_ss
调用sdcmd_user_get_net_gw_ss
Step9:
sdcmd:
sdcmd_user_get_net_gw_ss
根据不同的情况发送下面其中一个命令
SDSS_EVT_USER_GET_NET_GW
SDSS_EVT_HYBR_2_USER_GET_NET_GW
SDSS_EVT_HYBR_3_USER_GET_NET_GW
Step10:
sdss:
sdss_get_net
创建action:
SDSS_IACT_GET_NET_GWL
Step11:
sdcmd:
sd_ss_event_proc
处理上一步的SDSS_IACT_GET_NET_GWL:
在这里发送actionSD_SS_ACT_GET_NET_GW到cmregprx模块。
Step12:
cmregprx:
cmregprx_process_sd_action
处理命令SD_SS_ACT_GET_NET_GW
处理函数cmregprx_send_reg_net_list_req:
发送命令CM_NETWORK_LIST_REQ
MSG03:
24:
16.042CallManager/Mediumcmregprx.c06072=CMREGPRX=cmregprx_process_sd_action():
is_gwl_mode_supp1,is_1x_hdr_mode_supp0sd_mode_pref3752
MSG03:
24:
16.042CallManager/Highcmregprx.c03797=CMREGPRX=AS_ID=0,stack=0,SendNETWORK_LIST_REQ
MSG03:
24:
16.042CallManager/Highcmregprx.c03800=CMREGPRX=mode_pref5
MSG03:
24:
16.042CallManager/Highcmregprx.c03803=CMREGPRX=band_pref0680180
MSG03:
24:
16.042CallManager/Highcmregprx.c03806=CMREGPRX=srv_domain3
MSG03:
24:
16.042CallManager/Highcmregprx.c03809=CMREGPRX=nw_list_req0
MSG03:
24:
16.042CallManager/Highcmregprx.c03813=CMREGPRX=rat_pri_listnum=3
MSG03:
24:
16.042CallManager/Highcmregprx.c03815=CMREGPRX=mode/bandfilternum=0
Step13:
reg_state:
reg_state_main
处理CM_NETWORK_LIST_REQ:
调用当前状态的process_cm_network_list_req
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c08103DS:
SUB1=REG=CM_NETWORK_LIST_REQ
Step14:
Reg_state:
reg_state_process_cm_network_list_req
调reg_send_mmr_plmn_search_req进行下一步
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01293DS:
SUB1=REG=Ratprioritylistnum_items=3
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01298DS:
SUB1=REG=sys_mode=9band_cap=0x5
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01298DS:
SUB1=REG=sys_mode=5band_cap=0x680180
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01298DS:
SUB1=REG=sys_mode=3band_cap=0x680180
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01301DS:
SUB1=REG=MCCmodebandfilternum_items=0
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_state.c01389DS:
SUB1=REG=LIST_REQTYPE0
Step15:
Reg_send:
reg_send_mmr_plmn_search_req
发送消息MMR_PLMN_SEARCH_REQ,从下面的log可以看出搜索的是哪个网络
MSG03:
24:
16.043NASREG/High/Error/Fatalreg_send.c01228DS:
SUB1=REG=MMR_PLMN_SEARCH_REQRAT(UMTS)TI
(1)scanscope0
Step16:
mmcoord:
mmcoord_process_mmr_plmn_search_req
调用mm_send_mmr_plmn_search_cnf发送MMR_PLMN_SEARCH_CNF
MSG03:
24:
16.045NASMM/High/Error/Fatalmmcoord.c01185DS:
SUB1=MM=MMreceivedMMR_PLMN_SEARCH_REQ
MSG03:
24:
16.045NASMM/High/Error/Fatalmmcoord.c01219DS:
SUB1=MM=ReceivedCSGSearchType-0
MSG03:
24:
16.045NASMM/High/Error/Fatalmmcoord.c01232DS:
SUB1=MM=DualMode.SendingrequestonActiveRAT1
Step17:
mmplmnserch:
mm_get_plmn_list
调用mm_request_list_from_rr发送RRC_PLMN_LIST_REQ到RRC层
MSG03:
24:
16.045NASMM/High/Error/Fatalmmplmnsrch.c00200DS:
SUB1=MM=PLMNLISTREQ:
Manualselection
MSG03:
24:
16.045NASMM/High/Error/Fatalmmplmnsrch.c00721DS:
SUB1=MM=ManualPLMNTimervalueFIRST0MORE0MAX0
MSG03:
24:
16.045NASMM/High/Error/Fatalmmplmnsrch.c00724DS:
SUB1=MM=BSTchangeslengthofmccmodefilter=0
MSG03:
24:
16.045NASMM/High/Error/Fatalmmplmnsrch.c00736DS:
SUB1=MM=MMsentRRC_PLMN_LIST_REQ
Step18:
RrcDispatcher:
rrc_dispatch_mm_commands
调用rrcm_event_handler进一步处理
MSG03:
24:
16.045WCDMARRC/Highrrcdispatcher.c04724Rx:
RRC_PLMN_LIST_REQ
Step19:
Rrcmcm:
rrcmcm_event_handler
调rrcmcm_initial_substate_event_handler,这里继续下一步rrc_cell_selection_procedure
MSG03:
24:
16.045WCDMARRC/Highrrcmcm.c05848functionrrcmcm_event_handleriscalledinrrcmcm_state=rrcmcm_state_e_type_value0/EventisreceivedbyMCM:
5000007
MSG03:
24:
16.045WCDMARRC/Highrrcmcm.c03763Rx:
RRC_PLMN_LIST_REQ
Step20:
rrccsp:
rrc_cell_selection_procedure
MSG03:
24:
16.045WCDMARRC/Highrrccsp.c31483functionrrc_cell_selection_procedureiscalledinrrc_csp_substaterrc_csp_substate_e_type_value13
MSG03:
24:
16.046WCDMARRC/Highrrccsputil.c22136RATSearchorderforPLMNListReq
MSG03:
24:
16.046WCDMARRC/Highrrccsputil.c22141>0---GSMRAT------
MSG03:
24:
16.046WCDMARRC/Highrrccsputil.c22150>1---LTERAT------
MSG03:
24:
16.046WCDMARRC/Highrrccsputil.c22145>2---UMTSRAT------
MSG03:
24:
16.046WCDMARRC/Highrrccsputil.c22110DoWTOGsearchfirst
到这里主要是向L1层请求搜索频点获取网络的过程
搜索完成,向上层返回结果
搜索结果回来
MSG03:
24:
48.004WCDMARRC/Highrrcllc.c36280Rcv'dCPHY_ACQ_CNFfromL1
MSG03:
24:
48.004WCDMARRC/Highrrccspfscan.c01791Freqscan-nomorefrequency
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c05262Allbandsexhausted
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c14034WTOW:
nomorefreqfnd.WSearchcompleted
MSG03:
24:
48.004WCDMARRC/Highrrccsp.c27440BPLMN:
StartingManualPLMNFreqScantimer
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c09001CPHYGOTOSLEEPINDsenttoL1
Step21:
Rrccsptuil:
rrc_csp_bplmn_send_mm_plmn_list_cnf_cmd
发送命令RRC_PLMN_LIST_CNF
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11019CSG:
AddingWCDMAPLMN460-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11037AddingGSMPLMN460-0
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11037AddingGSMPLMN460-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11056CSG:
AddingLTECSGID-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11060AddingLTEPLMN460-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11056CSG:
AddingLTECSGID-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11060AddingLTEPLMN460-0
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11056CSG:
AddingLTECSGID-1
MSG03:
24:
48.004WCDMARRC/Highrrccsputil.c11060AddingLTEPLMN460-11
MSG03:
24:
48.005NASMM/High/Error/Fatalmmcoord.c08312DS:
SUB1=MM=MMreceivedRRC_PLMN_LIST_CNF
MSG03:
24:
48.005NASMM/High/Error/Fatalmmplmnsrch.c00446DS:
SUB1=MM=ReceivedRRC_PLMN_LIST_CNFTI
(1)
MSG03:
24:
48.005NASMM/High/Error/Fatalmmsend.c01250DS:
SUB1=MM=MMsentMMR_PLMN_SEARCH_CNF
Step22:
Reg_state:
reg_state_main
处理MMR_PLMN_SEARCH_CNF,调用的是
Reg_State_manual_search:
process_mmr_plmn_search_cnf
这里调用reg_send_cm_network_list_cnf
Step23:
Reg_send:
reg_send_cm_network_list_cnf
发送CM_NETWORK_LIST_CNF
MSG03:
24:
48.007NASREG/High/Error/Fatalreg_state.c08530DS:
SUB1=REG=MMR_PLMN_SEARCH_CNF
MSG03:
24:
48.014NASREG/High/Error/Fatalreg_send.c00538DS:
SUB1=REG=CM_NETWORK_LIST_CNF
Step24:
Sd_si_net_list_rpt_cb
MSG03:
24:
48.018CDMASystemDetermination/Highsdcmd.c06659=SD=Getnetworklistresultposted
Step25:
cmtask:
cm_si_network_list_cb
发送命令CM_SI_NETWORK_LIST_F,
Step26:
cmph:
cmph_rpt_proc
处理命令CM_SI_NETWORK_LIST_F调用cmph_process_network_list_cnf发送CM_PH_EVENT_AVAILABLE_NETWORKS_CONF消息
MSG03:
24:
48.025CallManager/Highcmph.c28718=CM=cmph_process_network_list_cnf:
net_list_cnf_ptr->status=0
Step27:
qmi_nas:
qmi_nas_process_cmph_evt
处理CM_PH_EVENT_AVAILABLE_NETWORKS_CONF消息,调用
qmi_nas_generate_net_scan_resp_ext来处理
NAS_CMD_PERFORM_NETWORK_SCAN
qmi_nasi_generate_perform_network_scan_resp
Step28:
qmi_nas:
qmi_nasi_send_response
MSG03:
24:
48.028MMODEQMI/Highqmi_nas.c07048generate_net_scanresp/ind(list_cnf=0,length=6,incrementalstatus=0)
------------------
QMI数据回来
2015Sep1703:
24:
48.036[37]0x138FQMILink1TXPDU
IFType=1
QmiLength=225
QmiCtlFlags=128
QmiType=NAS
Service_Nas{
ClientId=1
SduCtlFlags=RSP
TxId=244
MsgType=QMI_NAS_PERFORM_NETWORK_SCAN_MSG
MsgLength=213
QmiNasPerformNetworkScan{
QmiNasPerformNetworkScanRespTlvs[0]{
Type=2
Length
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 移动开发 手动搜网过程 移动 开发 手动 过程