B2G/gecko/dom/system/gonk/RadioInterfaceLayer.js
/**
   * Process the incoming message from the RIL worker. This roughly
   * works as follows:
   * (1) Update local state.
   * (2) Update state in related systems such as the audio.
   * (3) Multiplex the message to callbacks / listeners (typically the DOM).
   */
Process the incoming message from the RIL worker. This roughly
works as follows:
(1) Update local state.
(2) Update state in related systems such as the audio.
(3) Multiplex the message to callbacks / listeners (typically the DOM).
Process the incoming message from the RIL worker . This roughly works as follows : ( 1 ) Update local state . ( 2 ) Update state in related systems such as the audio . ( 3 ) Multiplex the message to callbacks / listeners ( typically the DOM ) .
function onmessage(event) {
    let message = event.data;
    debug("Received message from worker: " + JSON.stringify(message));
    switch (message.rilMessageType) {
      case "callRing":
        this.handleCallRing();
        break;
      case "callStateChange":
        this.handleCallStateChange(message.call);
        break;
      case "callDisconnected":
        this.handleCallDisconnected(message.call);
        break;
      case "enumerateCalls":
        this.handleEnumerateCalls(message);
        break;
      case "callError":
        this.handleCallError(message);
        break;
      case "getAvailableNetworks":
        this.handleGetAvailableNetworks(message);
        break;
      case "selectNetwork":
        this.handleSelectNetwork(message);
        break;
      case "selectNetworkAuto":
        this.handleSelectNetworkAuto(message);
        break;
      case "networkinfochanged":
        this.updateNetworkInfo(message);
        break;
      case "networkselectionmodechange":
        this.updateNetworkSelectionMode(message);
        break;
      case "voiceregistrationstatechange":
        this.updateVoiceConnection(message);
        break;
      case "dataregistrationstatechange":
        this.updateDataConnection(message);
        break;
      case "datacallerror":
        this.handleDataCallError(message);
        break;
      case "signalstrengthchange":
        this.handleSignalStrengthChange(message);
        break;
      case "operatorchange":
        this.handleOperatorChange(message);
        break;
      case "radiostatechange":
        this.handleRadioStateChange(message);
        break;
      case "cardstatechange":
        this.rilContext.cardState = message.cardState;
        this._sendTargetMessage("mobileconnection", "RIL:CardStateChanged", message);
        break;
      case "sms-received":
        let ackOk = this.handleSmsReceived(message);
        if (ackOk) {
          this.worker.postMessage({
            rilMessageType: "ackSMS",
            result: RIL.PDU_FCS_OK
          });
        }
        return;
      case "sms-sent":
        this.handleSmsSent(message);
        return;
      case "sms-delivery":
        this.handleSmsDelivery(message);
        return;
      case "sms-send-failed":
        this.handleSmsSendFailed(message);
        return;
      case "cellbroadcast-received":
        message.timestamp = Date.now();
        this._sendTargetMessage("cellbroadcast", "RIL:CellBroadcastReceived",
                                message);
        break;
      case "datacallstatechange":
        this.handleDataCallState(message);
        break;
      case "datacalllist":
        this.handleDataCallList(message);
        break;
      case "nitzTime":
        this.handleNitzTime(message);
        break;
      case "iccinfochange":
        this.handleICCInfoChange(message);
        break;
      case "iccGetCardLock":
      case "iccSetCardLock":
      case "iccUnlockCardLock":
        this.handleICCCardLockResult(message);
        break;
      case "icccontacts":
        if (!this._contactsCallbacks) {
          return;
        }
        let callback = this._contactsCallbacks[message.requestId];
        if (callback) {
          delete this._contactsCallbacks[message.requestId];
          callback.receiveContactsList(message.errorMsg,
                                       message.contactType,
                                       message.contacts);
        }
        break;
      case "iccmbdn":
        this.handleICCMbdn(message);
        break;
      case "USSDReceived":
        debug("USSDReceived " + JSON.stringify(message));
        this.handleUSSDReceived(message);
        break;
      case "sendMMI":
      case "sendUSSD":
        this.handleSendMMI(message);
        break;
      case "cancelMMI":
      case "cancelUSSD":
        this.handleCancelMMI(message);
        break;
      case "stkcommand":
        this.handleStkProactiveCommand(message);
        break;
      case "stksessionend":
        this._sendTargetMessage("mobileconnection", "RIL:StkSessionEnd", null);
        break;
      case "setPreferredNetworkType":
        this.handleSetPreferredNetworkType(message);
        break;
      case "queryCallForwardStatus":
        this.handleQueryCallForwardStatus(message);
        break;
      case "setCallForward":
        this.handleSetCallForward(message);
        break;
      case "queryCallWaiting":
        this.handleQueryCallWaiting(message);
        break;
      case "setCallWaiting":
        this.handleSetCallWaiting(message);
        break;
      case "setCellBroadcastSearchList":
        this.handleSetCellBroadcastSearchList(message);
        break;
      case "setRadioEnabled":
        let lock = gSettingsService.createLock();
        lock.set("ril.radio.disabled", !message.on, null, null);
        break;
      default:
        throw new Error("Don't know about this message type: " +
                        message.rilMessageType);
    }
  }
function onmessage ( event ) { let message = event . data ; debug ( "Received message from worker: " + JSON . stringify ( message ) ) ; switch ( message . rilMessageType ) { case "callRing" : this . handleCallRing ( ) ; break ; case "callStateChange" : this . handleCallStateChange ( message . call ) ; break ; case "callDisconnected" : this . handleCallDisconnected ( message . call ) ; break ; case "enumerateCalls" : this . handleEnumerateCalls ( message ) ; break ; case "callError" : this . handleCallError ( message ) ; break ; case "getAvailableNetworks" : this . handleGetAvailableNetworks ( message ) ; break ; case "selectNetwork" : this . handleSelectNetwork ( message ) ; break ; case "selectNetworkAuto" : this . handleSelectNetworkAuto ( message ) ; break ; case "networkinfochanged" : this . updateNetworkInfo ( message ) ; break ; case "networkselectionmodechange" : this . updateNetworkSelectionMode ( message ) ; break ; case "voiceregistrationstatechange" : this . updateVoiceConnection ( message ) ; break ; case "dataregistrationstatechange" : this . updateDataConnection ( message ) ; break ; case "datacallerror" : this . handleDataCallError ( message ) ; break ; case "signalstrengthchange" : this . handleSignalStrengthChange ( message ) ; break ; case "operatorchange" : this . handleOperatorChange ( message ) ; break ; case "radiostatechange" : this . handleRadioStateChange ( message ) ; break ; case "cardstatechange" : this . rilContext . cardState = message . cardState ; this . _sendTargetMessage ( "mobileconnection" , "RIL:CardStateChanged" , message ) ; break ; case "sms-received" : let ackOk = this . handleSmsReceived ( message ) ; if ( ackOk ) { this . worker . postMessage ( { rilMessageType : "ackSMS" , result : RIL . PDU_FCS_OK } ) ; } return ; case "sms-sent" : this . handleSmsSent ( message ) ; return ; case "sms-delivery" : this . handleSmsDelivery ( message ) ; return ; case "sms-send-failed" : this . handleSmsSendFailed ( message ) ; return ; case "cellbroadcast-received" : message . timestamp = Date . now ( ) ; this . _sendTargetMessage ( "cellbroadcast" , "RIL:CellBroadcastReceived" , message ) ; break ; case "datacallstatechange" : this . handleDataCallState ( message ) ; break ; case "datacalllist" : this . handleDataCallList ( message ) ; break ; case "nitzTime" : this . handleNitzTime ( message ) ; break ; case "iccinfochange" : this . handleICCInfoChange ( message ) ; break ; case "iccGetCardLock" : case "iccSetCardLock" : case "iccUnlockCardLock" : this . handleICCCardLockResult ( message ) ; break ; case "icccontacts" : if ( ! this . _contactsCallbacks ) { return ; } let callback = this . _contactsCallbacks [ message . requestId ] ; if ( callback ) { delete this . _contactsCallbacks [ message . requestId ] ; callback . receiveContactsList ( message . errorMsg , message . contactType , message . contacts ) ; } break ; case "iccmbdn" : this . handleICCMbdn ( message ) ; break ; case "USSDReceived" : debug ( "USSDReceived " + JSON . stringify ( message ) ) ; this . handleUSSDReceived ( message ) ; break ; case "sendMMI" : case "sendUSSD" : this . handleSendMMI ( message ) ; break ; case "cancelMMI" : case "cancelUSSD" : this . handleCancelMMI ( message ) ; break ; case "stkcommand" : this . handleStkProactiveCommand ( message ) ; break ; case "stksessionend" : this . _sendTargetMessage ( "mobileconnection" , "RIL:StkSessionEnd" , null ) ; break ; case "setPreferredNetworkType" : this . handleSetPreferredNetworkType ( message ) ; break ; case "queryCallForwardStatus" : this . handleQueryCallForwardStatus ( message ) ; break ; case "setCallForward" : this . handleSetCallForward ( message ) ; break ; case "queryCallWaiting" : this . handleQueryCallWaiting ( message ) ; break ; case "setCallWaiting" : this . handleSetCallWaiting ( message ) ; break ; case "setCellBroadcastSearchList" : this . handleSetCellBroadcastSearchList ( message ) ; break ; case "setRadioEnabled" : let lock = gSettingsService . createLock ( ) ; lock . set ( "ril.radio.disabled" , ! message . on , null , null ) ; break ; default : throw new Error ( "Don't know about this message type: " + message . rilMessageType ) ; } }
Process the incoming message from the RIL worker.
Process the incoming message from the RIL worker .
// This one will handle its own notifications. // This one will handle its own notifications. // This one will handle its own notifications.