B2G/gecko/dom/system/gonk/RadioInterfaceLayer.js
/**
   * Process a message from the content process.
   */
Process a message from the content process.
Process a message from the content process .
function receiveMessage(msg) {
    debug("Received '" + msg.name + "' message from content process");
    if (msg.name == "child-process-shutdown") {
      this.unregisterMessageTarget(null, msg.target);
      return;
    }
    if (RIL_IPC_TELEPHONY_MSG_NAMES.indexOf(msg.name) != -1) {
      if (!msg.target.assertPermission("telephony")) {
        debug("Telephony message " + msg.name +
              " from a content process with no 'telephony' privileges.");
        return null;
      }
    } else if (RIL_IPC_MOBILECONNECTION_MSG_NAMES.indexOf(msg.name) != -1) {
      if (!msg.target.assertPermission("mobileconnection")) {
        debug("MobileConnection message " + msg.name +
              " from a content process with no 'mobileconnection' privileges.");
        return null;
      }
    } else if (RIL_IPC_VOICEMAIL_MSG_NAMES.indexOf(msg.name) != -1) {
      if (!msg.target.assertPermission("voicemail")) {
        debug("Voicemail message " + msg.name +
              " from a content process with no 'voicemail' privileges.");
        return null;
      }
    } else if (RIL_IPC_CELLBROADCAST_MSG_NAMES.indexOf(msg.name) != -1) {
      if (!msg.target.assertPermission("cellbroadcast")) {
        debug("Cell Broadcast message " + msg.name +
              " from a content process with no 'cellbroadcast' privileges.");
        return null;
      }
    } else {
      debug("Ignoring unknown message type: " + msg.name);
      return null;
    }
    switch (msg.name) {
      case "RIL:GetRilContext":
        return this.rilContext;
      case "RIL:EnumerateCalls":
        this.saveRequestTarget(msg);
        this.enumerateCalls(msg.json);
        break;
      case "RIL:GetMicrophoneMuted":
        return this.microphoneMuted;
      case "RIL:SetMicrophoneMuted":
        this.microphoneMuted = msg.json;
        break;
      case "RIL:GetSpeakerEnabled":
        return this.speakerEnabled;
      case "RIL:SetSpeakerEnabled":
        this.speakerEnabled = msg.json;
        break;
      case "RIL:StartTone":
        this.startTone(msg.json);
        break;
      case "RIL:StopTone":
        this.stopTone();
        break;
      case "RIL:Dial":
        this.dial(msg.json);
        break;
      case "RIL:DialEmergency":
        this.dialEmergency(msg.json);
        break;
      case "RIL:HangUp":
        this.hangUp(msg.json);
        break;
      case "RIL:AnswerCall":
        this.answerCall(msg.json);
        break;
      case "RIL:RejectCall":
        this.rejectCall(msg.json);
        break;
      case "RIL:HoldCall":
        this.holdCall(msg.json);
        break;
      case "RIL:ResumeCall":
        this.resumeCall(msg.json);
        break;
      case "RIL:RegisterTelephonyMsg":
        this.registerMessageTarget("telephony", msg.target);
        break;
      case "RIL:GetAvailableNetworks":
        this.saveRequestTarget(msg);
        this.getAvailableNetworks(msg.json.requestId);
        break;
      case "RIL:SelectNetwork":
        this.saveRequestTarget(msg);
        this.selectNetwork(msg.json);
        break;
      case "RIL:SelectNetworkAuto":
        this.saveRequestTarget(msg);
        this.selectNetworkAuto(msg.json.requestId);
        break;
      case "RIL:GetCardLock":
        this.saveRequestTarget(msg);
        this.getCardLock(msg.json);
        break;
      case "RIL:UnlockCardLock":
        this.saveRequestTarget(msg);
        this.unlockCardLock(msg.json);
        break;
      case "RIL:SetCardLock":
        this.saveRequestTarget(msg);
        this.setCardLock(msg.json);
        break;
      case "RIL:SendMMI":
        this.saveRequestTarget(msg);
        this.sendMMI(msg.json);
        break;
      case "RIL:CancelMMI":
        this.saveRequestTarget(msg);
        this.cancelMMI(msg.json);
        break;
      case "RIL:SendStkResponse":
        this.sendStkResponse(msg.json);
        break;
      case "RIL:SendStkMenuSelection":
        this.sendStkMenuSelection(msg.json);
        break;
      case "RIL:SendStkTimerExpiration":
        this.sendStkTimerExpiration(msg.json);
        break;
      case "RIL:SendStkEventDownload":
        this.sendStkEventDownload(msg.json);
        break;
      case "RIL:RegisterMobileConnectionMsg":
        this.registerMessageTarget("mobileconnection", msg.target);
        break;
      case "RIL:RegisterVoicemailMsg":
        this.registerMessageTarget("voicemail", msg.target);
        break;
      case "RIL:SetCallForwardingOption":
        this.saveRequestTarget(msg);
        this.setCallForwardingOption(msg.json);
        break;
      case "RIL:GetCallForwardingOption":
        this.saveRequestTarget(msg);
        this.getCallForwardingOption(msg.json);
        break;
      case "RIL:SetCallWaitingOption":
        this.saveRequestTarget(msg);
        this.setCallWaitingOption(msg.json);
        break;
      case "RIL:GetCallWaitingOption":
        this.saveRequestTarget(msg);
        this.getCallWaitingOption(msg.json);
        break;
      case "RIL:RegisterCellBroadcastMsg":
        this.registerMessageTarget("cellbroadcast", msg.target);
        break;
      case "RIL:GetVoicemailInfo":
        return this.voicemailInfo;
    }
  }
function receiveMessage ( msg ) { debug ( "Received '" + msg . name + "' message from content process" ) ; if ( msg . name == "child-process-shutdown" ) { this . unregisterMessageTarget ( null , msg . target ) ; return ; } if ( RIL_IPC_TELEPHONY_MSG_NAMES . indexOf ( msg . name ) != - 1 ) { if ( ! msg . target . assertPermission ( "telephony" ) ) { debug ( "Telephony message " + msg . name + " from a content process with no 'telephony' privileges." ) ; return null ; } } else if ( RIL_IPC_MOBILECONNECTION_MSG_NAMES . indexOf ( msg . name ) != - 1 ) { if ( ! msg . target . assertPermission ( "mobileconnection" ) ) { debug ( "MobileConnection message " + msg . name + " from a content process with no 'mobileconnection' privileges." ) ; return null ; } } else if ( RIL_IPC_VOICEMAIL_MSG_NAMES . indexOf ( msg . name ) != - 1 ) { if ( ! msg . target . assertPermission ( "voicemail" ) ) { debug ( "Voicemail message " + msg . name + " from a content process with no 'voicemail' privileges." ) ; return null ; } } else if ( RIL_IPC_CELLBROADCAST_MSG_NAMES . indexOf ( msg . name ) != - 1 ) { if ( ! msg . target . assertPermission ( "cellbroadcast" ) ) { debug ( "Cell Broadcast message " + msg . name + " from a content process with no 'cellbroadcast' privileges." ) ; return null ; } } else { debug ( "Ignoring unknown message type: " + msg . name ) ; return null ; } switch ( msg . name ) { case "RIL:GetRilContext" : return this . rilContext ; case "RIL:EnumerateCalls" : this . saveRequestTarget ( msg ) ; this . enumerateCalls ( msg . json ) ; break ; case "RIL:GetMicrophoneMuted" : return this . microphoneMuted ; case "RIL:SetMicrophoneMuted" : this . microphoneMuted = msg . json ; break ; case "RIL:GetSpeakerEnabled" : return this . speakerEnabled ; case "RIL:SetSpeakerEnabled" : this . speakerEnabled = msg . json ; break ; case "RIL:StartTone" : this . startTone ( msg . json ) ; break ; case "RIL:StopTone" : this . stopTone ( ) ; break ; case "RIL:Dial" : this . dial ( msg . json ) ; break ; case "RIL:DialEmergency" : this . dialEmergency ( msg . json ) ; break ; case "RIL:HangUp" : this . hangUp ( msg . json ) ; break ; case "RIL:AnswerCall" : this . answerCall ( msg . json ) ; break ; case "RIL:RejectCall" : this . rejectCall ( msg . json ) ; break ; case "RIL:HoldCall" : this . holdCall ( msg . json ) ; break ; case "RIL:ResumeCall" : this . resumeCall ( msg . json ) ; break ; case "RIL:RegisterTelephonyMsg" : this . registerMessageTarget ( "telephony" , msg . target ) ; break ; case "RIL:GetAvailableNetworks" : this . saveRequestTarget ( msg ) ; this . getAvailableNetworks ( msg . json . requestId ) ; break ; case "RIL:SelectNetwork" : this . saveRequestTarget ( msg ) ; this . selectNetwork ( msg . json ) ; break ; case "RIL:SelectNetworkAuto" : this . saveRequestTarget ( msg ) ; this . selectNetworkAuto ( msg . json . requestId ) ; break ; case "RIL:GetCardLock" : this . saveRequestTarget ( msg ) ; this . getCardLock ( msg . json ) ; break ; case "RIL:UnlockCardLock" : this . saveRequestTarget ( msg ) ; this . unlockCardLock ( msg . json ) ; break ; case "RIL:SetCardLock" : this . saveRequestTarget ( msg ) ; this . setCardLock ( msg . json ) ; break ; case "RIL:SendMMI" : this . saveRequestTarget ( msg ) ; this . sendMMI ( msg . json ) ; break ; case "RIL:CancelMMI" : this . saveRequestTarget ( msg ) ; this . cancelMMI ( msg . json ) ; break ; case "RIL:SendStkResponse" : this . sendStkResponse ( msg . json ) ; break ; case "RIL:SendStkMenuSelection" : this . sendStkMenuSelection ( msg . json ) ; break ; case "RIL:SendStkTimerExpiration" : this . sendStkTimerExpiration ( msg . json ) ; break ; case "RIL:SendStkEventDownload" : this . sendStkEventDownload ( msg . json ) ; break ; case "RIL:RegisterMobileConnectionMsg" : this . registerMessageTarget ( "mobileconnection" , msg . target ) ; break ; case "RIL:RegisterVoicemailMsg" : this . registerMessageTarget ( "voicemail" , msg . target ) ; break ; case "RIL:SetCallForwardingOption" : this . saveRequestTarget ( msg ) ; this . setCallForwardingOption ( msg . json ) ; break ; case "RIL:GetCallForwardingOption" : this . saveRequestTarget ( msg ) ; this . getCallForwardingOption ( msg . json ) ; break ; case "RIL:SetCallWaitingOption" : this . saveRequestTarget ( msg ) ; this . setCallWaitingOption ( msg . json ) ; break ; case "RIL:GetCallWaitingOption" : this . saveRequestTarget ( msg ) ; this . getCallWaitingOption ( msg . json ) ; break ; case "RIL:RegisterCellBroadcastMsg" : this . registerMessageTarget ( "cellbroadcast" , msg . target ) ; break ; case "RIL:GetVoicemailInfo" : return this . voicemailInfo ; } }
Process a message from the content process.
Process a message from the content process .
// By the time we receive child-process-shutdown, the child process has // already forgotten its permissions so we need to unregister the target // for every permission. // This message is sync. // This message is sync. // This message is sync. // This message is sync.