KaiOS 搜网功能 selectNetwork 流程和代码逻辑

25 篇文章 0 订阅
21 篇文章 0 订阅

文件和关键API

  • gaia/apps/settings/js/panels/carrier_operator_settings/panel.js 进入界面,关闭自动选网开始手动搜网
    • initSoftkey
    • scan()
  • gecko/dom/mobileconnection/gonk/MobileConnectionService.jsm
    • getNetworks
  • gecko/dom/system/gonk/radio/RadioInterfaceLayer.jsm
    • getAvailableNetworks
  • gecko/dom/system/gonk/radio/nsRilWorker.cpp
    • getAvailableNetworks
  • gecko/dom/system/gonk/radio/nsRilResponse.cpp
    • getAvailableNetworksResponse
    • updateAvailableNetworks
  • gecko/dom/system/gonk/radio/RadioInterfaceLayer.jsm
    • GetAvailableNetworks
    • handleAvailableNetworks
  • gaia/apps/settings/js/panels/carrier_operator_settings/panel.js 搜网完成,更新界面网络列表
    • scan()—>onSucess

代码细节

手动搜网

carrier_manual_select/panel.js

gaia/apps/settings/elements/carrier_manual_select.html  界面结构定义

<element name="carrier_manual_select" extends="section">
  <template>

    <gaia-header>
      <h1 slot="text" data-l10n-id="carrier_manual_select_title"></h1>
    </gaia-header>


    <div> 
      <!-- 会在UI显示的title -->
      <header id="availableOperatorsHeader">
        <h2 role="heading" data-l10n-id="availableOperators">Network Operators in the Area</h2>
      </header>
     
      <!-- 可用的网络列表,ul无序,li有序 -->
      <ul role="menu" id="availableOperators" data-state="off">
        <li role="menuitem" id="operators-info" class="description explanation non-focus" data-state="off">
        </li>
        <li role="menuitem" class="non-focus" data-state="on">
          <progress id="searching-progress" class="pack-activity" value="0" max="100"></progress>
         </li>
        <li role="menuitem" id="search-again" data-state="ready" class="button" aria-disabled="true" class="hidden">
          <button data-l10n-id="scanNetworks">Search Again</button>
        </li>
      </ul>
    </div>

    <panel data-path="panels/carrier_manual_select/panel"></panel>
  </template>
</element>

 gaia/apps/settings/js/panels/carrier_manual_select/panel.js 界面加载逻辑(数据)

    // 开始搜网
    function scan() {
      clear();
      elements.availableOperators.dataset.state = 'on'; // "Searching..."
      scanFlag = true;

      elements.operatorsInfo.setAttribute('data-state', 'on');
      elements.operatorsInfo.setAttribute('data-l10n-id', 'scanning');
      disableAutomaticSelectionState(true);

      // Invalidate the original request if it exists
      invalidateRequest(scanRequest);
      scanRequest = mobileConnection.getNetworks();

      scanRequest.onsuccess = function onsuccess() {
        scanFlag = false;
        const networks = scanRequest.result;
        for (let i = 0; i < networks.length; i++) {
          const network = networks[i];
          const listItem = newListItem(network, selectOperator);
          elements.availableOperators.insertBefore(
            listItem,
            elements.searchAgain
          );

          operatorItemMap[`${network.mcc}.${network.mnc}`] = listItem;
        }
        elements.searchAgain.classList.remove('hidden');
        elements.availableOperators.dataset.state = 'ready'; // "Search Again" button

        scanRequest = null;
        disableAutomaticSelectionState(false);
        setAutoTimeOut();
      };

      scanRequest.onerror = error => {
        scanFlag = false;
        if (error.currentTarget.error.name === 'RequestNotSupported') {
                  ToastHelper.showToast('request-not-supported');
        }
        DebugHelper.debug('carrier: could not retrieve any network operator. ');
        elements.searchAgain.classList.remove('hidden');
        elements.availableOperators.dataset.state = 'ready'; // "Search Again" button
        scanRequest = null;
        disableAutomaticSelectionState(false);
      };
    }

日志

手动搜网

下发搜网请求消息 RILJ -> RILC

04-05 12:35:20.562 I/Gecko   (  690): -*- RadioInterface[0]: sendWorkerMessage: rilMessageType: getAvailableNetworks: nullsendWorkerMessage@resource://gre/modules/RadioInterfaceLayer.jsm:1324:2

04-05 12:35:20.563 I/Gecko   (  690): -*- RadioInterface[0]: RILJ: [340] > RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
04-05 12:35:20.563 I/RilWorker(  690): nsRilWorker: [340] > RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
04-05 12:35:20.569 D/RILC    (  933): getAvailableNetworks: serial 340

下发SIM INFO 用于搜网,MD处理“selectNetwork”消息

04-05 12:38:27.114 I/Gecko   (  690): -*- RadioInterface[0]: RILJ: [467] > RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL numeric = 310410+3
04-05 12:38:27.114 I/RilWorker(  690): nsRilWorker: [467] > RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL operatorNumeric = 310410+3
04-05 12:38:31.407 I/Gecko   (  690): -*- RadioInterface[0]: Received message from worker handleRilResponse:"selectNetwork"
04-05 12:38:31.407 I/Gecko   (  690): -*- RadioInterface[0]: RILJ: [467] < RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL error = InternalError (38)

04-05 12:35:51.407 I/Gecko   (  690): -*- RadioInterface[0]: RILJ: [340] < RIL_REQUEST_QUERY_AVAILABLE_NETWORKS

MD返回搜网得到的网络个数

04-05 12:35:51.406 D/nsRilResponse(  690): getAvailableNetworks numNetworks= 5

自动搜网

05-20 11:39:21.581   707   707 I Gecko   : -*- RadioInterface[0]: sendWorkerMessage: rilMessageType: getAvailableNetworks: "null"sendWorkerMessage@resource://gre/modules/RadioInterfaceLayer.jsm:1327:2
05-20 11:39:21.581   707   707 I Gecko   : getNetworks@resource://gre/modules/MobileConnectionService.jsm:137:751
05-20 11:39:21.581   707   707 I Gecko   : 
05-20 11:39:21.581   707   707 I Gecko   : -*- RadioInterface[0]: sendWorkerMessage: hasCallback content:function handleResponse() {

查询可用网络

05-20 11:39:21.581   707   707 I Gecko   : -*- RadioInterface[0]: sendRilRequest enter
05-20 11:39:21.581   707   707 I Gecko   : -*- RadioInterface[0]: RILJ: [233] > RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
05-20 11:39:21.581   707   707 I RilWorker: nsRilWorker: [233] > RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
05-20 11:39:21.582   970  1079 D RILC    : getAvailableNetworks: serial 233

进入carrier界面及按键操作

05-20 11:39:21.687  2438  2438 I Gecko   : console.log: "***open new page operation, previous panel --> #carrier_detail"

05-20 11:39:21.691  2438  2438 I FocusManager:    trying to set focus on, tag: LI, id: , class: automatic-on none-select focus, src: 

05-20 11:39:21.696  2438  2438 I FocusManager:    current focused element, tag: LI, id: operator-autoSelect, class: , src: 
05-20 11:39:21.696  2438  2438 I FocusManager: <- blur on, tag: LI, id: operator-autoSelect, class: , src: 
05-20 11:39:21.696  2438  2438 I FocusManager: -> focus is now on, tag: LI, id: , class: automatic-on none-select focus, src: 

可用网络的结果

05-20 11:39:40.871   707  1318 D nsRilResponse: getAvailableNetworks numNetworks= 10

05-20 11:39:40.872   707  1318 D nsRilResponseResult: updateAvailableNetworks
05-20 11:39:40.872   707  1318 I RilWorker: nsRilWorker: [233] < getAvailableNetworks
05-20 11:39:40.872   707   707 I Gecko   : -*- RadioInterface[0]: Received message from worker handleRilResponse:"getAvailableNetworks"
05-20 11:39:40.873   707   707 I Gecko   : -*- RadioInterface[0]: RILJ: [233] < RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
05-20 11:39:40.875   707   707 I Gecko   : -*- RadioInterface[0]: MyTag handleRilResponse comes to the end: function(response){return callback.handleResponse(response);}
05-20 11:39:40.887  2438  2438 I GeckoDump: [settings] show mccmnc: 23432

自动请求选网

05-20 11:40:16.459   707   707 I Gecko   : -*- RadioInterface[0]: sendWorkerMessage: rilMessageType: selectNetworkAuto: "null"sendWorkerMessage@resource://gre/modules/RadioInterfaceLayer.jsm:1327:2
05-20 11:40:16.459   707   707 I Gecko   : selectNetworkAutomatically@resource://gre/modules/MobileConnectionService.jsm:143:57
05-20 11:40:16.459   707   707 I Gecko   : 
05-20 11:40:16.459   707   707 I Gecko   : -*- RadioInterface[0]: sendWorkerMessage: hasCallback content:function handleResponse() {
05-20 11:40:16.459   707   707 I Gecko   :     [native code]
05-20 11:40:16.459   707   707 I Gecko   : }
05-20 11:40:16.459   707   707 I Gecko   : -*- RadioInterface[0]: sendRilRequest enter
05-20 11:40:16.459   707   707 I Gecko   : -*- RadioInterface[0]: RILJ: [266] > RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC
05-20 11:40:16.460   707   707 I RilWorker: nsRilWorker: [266] > RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC
05-20 11:40:16.460   970  1079 D RILC    : setNetworkSelectionModeAutomatic: serial 266

05-20 11:40:16.885   707  1318 I RilWorker: processResponse, type= 0
05-20 11:40:16.886   707  1318 D nsRilResult: init nsRilResult for response.
05-20 11:40:16.886   707  1318 D nsRilResponseResult: init nsRilResponseResult
05-20 11:40:16.886   707  1318 D nsRilResponse: lqss defaultResponse rilmessageType: s
05-20 11:40:16.886   707  1318 I RilWorker: nsRilWorker: [266] < selectNetworkAuto
05-20 11:40:16.886   707   707 I Gecko   : -*- RadioInterface[0]: Received message from worker handleRilResponse:"selectNetworkAuto"
05-20 11:40:16.886   707   707 I Gecko   : -*- RadioInterface[0]: RILJ: [266] < RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC
05-20 11:40:16.886   707   707 I Gecko   : -*- RadioInterface[0]: handleNetworkSelectionMode false
05-20 11:40:16.886   707   707 I Gecko   : -*- RadioInterface[0]: Queuing networkSelectionMode network info message: {"rilMessageType":"networkselectionmodechange","mode":0}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值