Bug 818830 - B2G 3G: If we change APN name when data call is active, new data call cannot be established. r=vicamo, a=blocking-basecamp
authorShian-Yow Wu <swu@mozilla.com>
Fri, 14 Dec 2012 11:13:31 +0800
changeset 118880 908fb662b8abc7cad293e973771dd35c96915b97
parent 118879 2fad47a231072a13f1a01b14246fcbf610dce8f2
child 118881 a3f1771e71c9e7a5b4d11e9ec5f719cd7333a2d8
push idunknown
push userunknown
push dateunknown
reviewersvicamo, blocking-basecamp
bugs818830
milestone19.0a2
Bug 818830 - B2G 3G: If we change APN name when data call is active, new data call cannot be established. r=vicamo, a=blocking-basecamp
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -2635,17 +2635,25 @@ RILNetworkInterface.prototype = {
     if (message.apn != this.dataCallSettings["apn"]) {
       return;
     }
     debug("Data call error on APN: " + message.apn);
     this.reset();
   },
 
   dataCallStateChanged: function dataCallStateChanged(datacall) {
-    if (datacall.apn != this.dataCallSettings["apn"]) {
+    if (this.cid && this.cid != datacall.cid) {
+    // If data call for this connection existed but cid mismatched,
+    // it means this datacall state change is not for us.
+      return;
+    }
+    // If data call for this connection does not exist, it could be state
+    // change for new data call.  We only update data call state change
+    // if APN name matched.
+    if (!this.cid && datacall.apn != this.dataCallSettings["apn"]) {
       return;
     }
     debug("Data call ID: " + datacall.cid + ", interface name: " +
           datacall.ifname + ", APN name: " + datacall.apn);
     if (this.connecting &&
         (datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTING ||
          datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTED)) {
       this.connecting = false;
@@ -2659,17 +2667,20 @@ RILNetworkInterface.prototype = {
         this.dns1 = datacall.dns[0];
         this.dns2 = datacall.dns[1];
       }
       if (!this.registeredAsNetworkInterface) {
         gNetworkManager.registerNetworkInterface(this);
         this.registeredAsNetworkInterface = true;
       }
     }
-    if (this.cid != datacall.cid) {
+    // In current design, we don't update status of secondary APN if it shares
+    // same APN name with the default APN.  In this condition, this.cid will
+    // not be set and we don't want to update its status.
+    if (this.cid == null) {
       return;
     }
     if (this.state == datacall.state) {
       return;
     }
 
     this.state = datacall.state;
 
@@ -2679,16 +2690,17 @@ RILNetworkInterface.prototype = {
     if (this == this.mRIL.dataNetworkInterface) {
       this.mRIL.updateRILNetworkInterface();
     }
 
     if (this.state == RIL.GECKO_NETWORK_STATE_UNKNOWN &&
        this.registeredAsNetworkInterface) {
       gNetworkManager.unregisterNetworkInterface(this);
       this.registeredAsNetworkInterface = false;
+      this.cid = null;
       return;
     }
 
     Services.obs.notifyObservers(this,
                                  kNetworkInterfaceStateChangedTopic,
                                  null);
   },