Bug 786535 - B2G 3G: Handling roaming setting correctly. r=philikon
authorJose Antonio Olivera Ortega <josea.olivera@gmail.com>
Thu, 30 Aug 2012 21:41:46 +0200
changeset 110232 2ff5338aa8c608a875d04c3fc7626363572091de
parent 110231 1d89bc229215fd8477b2068e359f9b9b8c249a18
child 110233 6075cc5dbe31fbe68e26d7bd70fb1487580a5363
push idunknown
push userunknown
push dateunknown
reviewersphilikon
bugs786535
milestone18.0a1
Bug 786535 - B2G 3G: Handling roaming setting correctly. r=philikon
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -584,31 +584,17 @@ RadioInterfaceLayer.prototype = {
       dataInfo.cell = null;
     } else {
       dataInfo.cell = newCell;
     }
 
     if (!newInfo.batch) {
       ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", dataInfo);
     }
-
-    if (!this.dataCallSettings["enabled"]) {
-      return;
-    }
-
-    let isRegistered =
-      newInfo.state == RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
-      (!newInfo.roaming || this._isDataRoamingEnabled());
-    let haveDataConnection =
-      newInfo.type != RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
-
-    if (isRegistered && haveDataConnection) {
-      debug("Radio is ready for data connection.");
-      this.updateRILNetworkInterface();
-    }
+    this.updateRILNetworkInterface();
   },
 
   handleSignalStrengthChange: function handleSignalStrengthChange(message) {
     let voiceInfo = this.rilContext.voice;
     // TODO CDMA, EVDO, LTE, etc. (see bug 726098)
     if (voiceInfo.signalStrength != message.gsmDBM ||
         voiceInfo.relSignalStrength != message.gsmRelative) {
       voiceInfo.signalStrength = message.gsmDBM;
@@ -688,37 +674,56 @@ RadioInterfaceLayer.prototype = {
       debug("We haven't read completely the APN data from the " +
             "settings DB yet. Wait for that.");
       return;
     } 
 
     // This check avoids data call connection if the radio is not ready 
     // yet after toggling off airplane mode. 
     if (this.rilContext.radioState != RIL.GECKO_RADIOSTATE_READY) {
+      debug("RIL is not ready for data connection: radio's not ready");
       return; 
     }
 
     // We only watch at "ril.data.enabled" flag changes for connecting or
     // disconnecting the data call. If the value of "ril.data.enabled" is
     // true and any of the remaining flags change the setting application
     // should turn this flag to false and then to true in order to reload
     // the new values and reconnect the data call.
     if (this._oldRilDataEnabledState == this.dataCallSettings["enabled"]) {
       debug("No changes for ril.data.enabled flag. Nothing to do.");
       return;
     }
 
     if (!this.dataCallSettings["enabled"] && RILNetworkInterface.connected) {
       debug("Data call settings: disconnect data call.");
       RILNetworkInterface.disconnect();
+      return;
     }
-    if (this.dataCallSettings["enabled"] && !RILNetworkInterface.connected) {
-      debug("Data call settings connect data call.");
-      RILNetworkInterface.connect(this.dataCallSettings);
+    if (!this.dataCallSettings["enabled"] || RILNetworkInterface.connected) {
+      debug("Data call settings: nothing to do.");
+      return;
     }
+    let dataInfo = this.rilContext.data;
+    let isRegistered =
+      dataInfo.state == RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED;
+    let haveDataConnection =
+      dataInfo.type != RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
+    if (!isRegistered || !haveDataConnection) {
+      debug("RIL is not ready for data connection: Phone's not registered " +
+            "or doesn't have data connection.");
+      return;
+    }
+    if (dataInfo.roaming && !this.dataCallSettings["roaming_enabled"]) {
+      debug("We're roaming, but data roaming is disabled.");
+      return;
+    }
+
+    debug("Data call settings: connect data call.");
+    RILNetworkInterface.connect(this.dataCallSettings);
   },
 
   /**
    * Track the active call and update the audio system as its state changes.
    */
   _activeCall: null,
   updateCallAudioState: function updateCallAudioState() {
     if (!this._activeCall) {