Bug 931348 - Part 3: Use allDataDisconnected() instead of anyDataConnected(). r=hsinyi, a=1.3+
authorJessica Jong <jjong@mozilla.com>
Wed, 29 Jan 2014 16:16:10 -0500
changeset 175129 2df3c92b932d075e48ca9663895ee903df5e5d78
parent 175128 780f33e17613701977309c273581c913415fd2c8
child 175130 ce98c76af3f51694e92b8fa8e3e978e47c7bf205
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi, 1
bugs931348
milestone28.0a2
Bug 931348 - Part 3: Use allDataDisconnected() instead of anyDataConnected(). r=hsinyi, a=1.3+
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -818,17 +818,17 @@ RadioInterfaceLayer.prototype = {
         let network = subject.QueryInterface(Ci.nsINetworkInterface);
         // DSDS: setup pending data connection when switching the default id
         // for data call. We can not use network.type to tell if it's
         // NETWORK_TYPE_MOBILE, since the type is removed from
         // RILNetworkInterface.connectedTypes on disconnect().
         if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN) {
           let oldRadioInterface =
             this.radioInterfaces[this._currentDataClientId];
-          if (!oldRadioInterface.anyDataConnected() &&
+          if (oldRadioInterface.allDataDisconnected() &&
               typeof this._pendingDataCallRequest === "function") {
             if (RILQUIRKS_DATA_REGISTRATION_ON_DEMAND) {
               oldRadioInterface.setDataRegistration(false);
             }
             if (DEBUG) debug("All data calls disconnected, setup pending data call.");
             this._pendingDataCallRequest();
             this._pendingDataCallRequest = null;
           }
@@ -2087,23 +2087,32 @@ RadioInterface.prototype = {
     }
 
     // Create RilNetworkInterface for each APN setting that just cached.
     for each (let apnSetting in this.apnSettings.byApn) {
       apnSetting.iface = new RILNetworkInterface(this, apnSetting);
     }
   },
 
+  allDataDisconnected: function() {
+    for each (let apnSetting in this.apnSettings.byApn) {
+      let iface = apnSetting.iface;
+      if (iface && iface.state != RIL.GECKO_NETWORK_STATE_UNKNOWN &&
+          iface.state != RIL.GECKO_NETWORK_STATE_DISCONNECTED) {
+        return false;
+      }
+    }
+    return true;
+  },
+
   anyDataConnected: function anyDataConnected() {
     for each (let apnSetting in this.apnSettings.byApn) {
-      for each (let type in apnSetting.types) {
-        if (this.getDataCallStateByType(type) ==
-            RIL.GECKO_NETWORK_STATE_CONNECTED) {
-          return true;
-        }
+      let iface = apnSetting.iface;
+      if (iface && iface.state == RIL.GECKO_NETWORK_STATE_CONNECTED) {
+        return true;
       }
     }
     return false;
   },
 
   /**
    * Check if we get all necessary APN data.
    */
@@ -2490,17 +2499,17 @@ RadioInterface.prototype = {
     }
 
     this._deliverDataCallCallback("dataCallStateChanged",
                                   [datacall]);
 
     // Process pending radio power off request after all data calls
     // are disconnected.
     if (datacall.state == RIL.GECKO_NETWORK_STATE_UNKNOWN &&
-        !this.anyDataConnected()) {
+        this.allDataDisconnected()) {
       if (gRadioEnabledController.isDeactivatingDataCalls()) {
         if (DEBUG) this.debug("All data connections are disconnected.");
         gRadioEnabledController.finishDeactivatingDataCalls(this.clientId);
       }
 
       if (this._pendingApnSettings) {
         if (DEBUG) this.debug("Setup pending apn settings.");
         this.setupApnSettings(this._pendingApnSettings);