Bug 855643 - B2G RIL: actively update networkSelectionMode at the first time querying. r=allstars.chh
authorHsin-Yi Tsai <htsai@mozilla.com>
Fri, 29 Mar 2013 10:56:07 +0800
changeset 133125 75759f66b7162de66c82cf6ebb76510907245c7d
parent 133124 ac2c4d7eb56d82af615d30f60b3f215d296511e3
child 133126 fef1ee969a6124fb1a4e8347f2005473dd54c1b0
push id3582
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 20:50:56 +0000
treeherdermozilla-aurora@400370bbc9fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars.chh
bugs855643
milestone22.0a1
Bug 855643 - B2G RIL: actively update networkSelectionMode at the first time querying. r=allstars.chh
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/nsIRadioInterfaceLayer.idl
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -305,16 +305,17 @@ CellBroadcastEtwsInfo.prototype = {
   warningType: null,
   emergencyUserAlert: null,
   popup: null
 };
 
 function RILContentHelper() {
   this.rilContext = {
     cardState:            RIL.GECKO_CARDSTATE_UNKNOWN,
+    networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
     iccInfo:              new MobileICCInfo(),
     voiceConnectionInfo:  new MobileConnectionInfo(),
     dataConnectionInfo:   new MobileConnectionInfo()
   };
   this.voicemailInfo = new VoicemailInfo();
 
   this.initRequests();
   this.initMessageListener(RIL_IPC_MSG_NAMES);
@@ -377,34 +378,33 @@ RILContentHelper.prototype = {
       network = destInfo.network = new MobileNetworkInfo();
     }
 
     this.updateInfo(srcNetwork, network);
  },
 
   // nsIRILContentHelper
 
-  networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
-
   rilContext: null,
 
   getRilContext: function getRilContext() {
     // Update ril context by sending IPC message to chrome only when the first
     // time we require it. The information will be updated by following info
     // changed messages.
     this.getRilContext = function getRilContext() {
       return this.rilContext;
     };
 
     let rilContext = cpmm.sendSyncMessage("RIL:GetRilContext")[0];
     if (!rilContext) {
       debug("Received null rilContext from chrome process.");
       return;
     }
     this.rilContext.cardState = rilContext.cardState;
+    this.rilContext.networkSelectionMode = rilContext.networkSelectionMode;
     this.updateInfo(rilContext.iccInfo, this.rilContext.iccInfo);
     this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
     this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
 
     return this.rilContext;
   },
 
   get iccInfo() {
@@ -418,16 +418,20 @@ RILContentHelper.prototype = {
   get dataConnectionInfo() {
     return this.getRilContext().dataConnectionInfo;
   },
 
   get cardState() {
     return this.getRilContext().cardState;
   },
 
+  get networkSelectionMode() {
+    return this.getRilContext().networkSelectionMode;
+  },
+
   /**
    * The network that is currently trying to be selected (or "automatic").
    * This helps ensure that only one network is selected at a time.
    */
   _selectingNetwork: null,
 
   getNetworks: function getNetworks(window) {
     if (window == null) {
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -221,16 +221,17 @@ function RadioInterfaceLayer() {
   debug("Starting RIL Worker");
   this.worker = new ChromeWorker("resource://gre/modules/ril_worker.js");
   this.worker.onerror = this.onerror.bind(this);
   this.worker.onmessage = this.onmessage.bind(this);
 
   this.rilContext = {
     radioState:     RIL.GECKO_RADIOSTATE_UNAVAILABLE,
     cardState:      RIL.GECKO_CARDSTATE_UNKNOWN,
+    networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
     iccInfo:        null,
     imsi:           null,
 
     // These objects implement the nsIDOMMozMobileConnectionInfo interface,
     // although the actual implementation lives in the content process. So are
     // the child attributes `network` and `cell`, which implement
     // nsIDOMMozMobileNetworkInfo and nsIDOMMozMobileCellInfo respectively.
     voice:          {connected: false,
@@ -1436,16 +1437,17 @@ RadioInterfaceLayer.prototype = {
     this._sendRequestResults("RIL:GetAvailableNetworks", message);
   },
 
   /**
    * Update network selection mode
    */
   updateNetworkSelectionMode: function updateNetworkSelectionMode(message) {
     debug("updateNetworkSelectionMode: " + JSON.stringify(message));
+    this.rilContext.networkSelectionMode = message.mode;
     this._sendMobileConnectionMessage("RIL:NetworkSelectionModeChanged", message);
   },
 
   /**
    * Handle "manual" network selection request.
    */
   handleSelectNetwork: function handleSelectNetwork(message) {
     debug("handleSelectNetwork: " + JSON.stringify(message));
--- a/dom/system/gonk/nsIRadioInterfaceLayer.idl
+++ b/dom/system/gonk/nsIRadioInterfaceLayer.idl
@@ -72,25 +72,27 @@ interface nsIRILContactCallback : nsISup
 [scriptable, uuid(c0c5cb9f-6372-4b5a-b74c-baacc2da5e4f)]
 interface nsIVoicemailInfo : nsISupports
 {
   readonly attribute DOMString number;
 
   readonly attribute DOMString displayName;
 };
 
-[scriptable, uuid(a09c42c3-1063-42f6-8022-268c6a0fe5e8)]
+[scriptable, uuid(f7ff9856-5c55-4ba2-9b64-bfc0ace169e7)]
 interface nsIRilContext : nsISupports
 {
   readonly attribute DOMString radioState;
 
   readonly attribute DOMString cardState;
 
   readonly attribute DOMString imsi;
 
+  readonly attribute DOMString networkSelectionMode;
+
   readonly attribute nsIDOMMozMobileICCInfo iccInfo;
 
   readonly attribute nsIDOMMozMobileConnectionInfo voice;
 
   readonly attribute nsIDOMMozMobileConnectionInfo data;
 };
 
 [scriptable, uuid(9a914550-8f7a-11e2-9e96-0800200c9a66)]