Bug 1021424 - Verify network.type and network.state before applying mms settings. f=btseng, r=vicamo, a=2.0+
authorJessica Jong <jjong@mozilla.com>
Tue, 24 Jun 2014 02:16:00 +0200
changeset 207369 a2df04e4f4d8b41042e6b612ce08e9fc13e32b4f
parent 207368 c2ca5265a5b166ad76dbd9d375bd1ca3b1e4277e
child 207370 a10d2edbefe8bb909d87bd262b1a699ddb9d112f
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo, 2
bugs1021424
milestone32.0a2
Bug 1021424 - Verify network.type and network.state before applying mms settings. f=btseng, r=vicamo, a=2.0+
dom/mobilemessage/src/gonk/MmsService.js
--- a/dom/mobilemessage/src/gonk/MmsService.js
+++ b/dom/mobilemessage/src/gonk/MmsService.js
@@ -278,38 +278,16 @@ MmsConnection.prototype = {
       this.radioInterface.deactivateDataCallByType("mms");
     }
   },
 
   init: function() {
     Services.obs.addObserver(this, kNetworkConnStateChangedTopic,
                              false);
     Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-
-    this.connected = this.radioInterface.getDataCallStateByType("mms") ==
-      Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
-    // If the MMS network is connected during the initialization, it means the
-    // MMS network must share the same APN with the mobile network by default.
-    // Under this case, |networkManager.active| should keep the mobile network,
-    // which is supposed be an instance of |nsIRilNetworkInterface| for sure.
-    if (this.connected) {
-      let networkManager =
-        Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
-      let activeNetwork = networkManager.active;
-
-      let rilNetwork = activeNetwork.QueryInterface(Ci.nsIRilNetworkInterface);
-      if (rilNetwork.serviceId != this.serviceId) {
-        if (DEBUG) debug("Sevice ID between active/MMS network doesn't match.");
-        return;
-      }
-
-      // Set up the MMS APN setting based on the connected MMS network,
-      // which is going to be used for the HTTP requests later.
-      this.setApnSetting(rilNetwork);
-    }
   },
 
   /**
    * Return the roaming status of voice call.
    *
    * @return true if voice call is roaming.
    */
   isVoiceRoaming: function() {
@@ -468,25 +446,23 @@ MmsConnection.prototype = {
       case kNetworkConnStateChangedTopic: {
         // The network for MMS connection must be nsIRilNetworkInterface.
         if (!(subject instanceof Ci.nsIRilNetworkInterface)) {
           return;
         }
 
         // Check if the network state change belongs to this service.
         let network = subject.QueryInterface(Ci.nsIRilNetworkInterface);
-        if (network.serviceId != this.serviceId) {
+        if (network.serviceId != this.serviceId ||
+            network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
           return;
         }
 
-        // We only need to capture the state change of MMS network. Using
-        // |network.state| isn't reliable due to the possibilty of shared APN.
         let connected =
-          this.radioInterface.getDataCallStateByType("mms") ==
-            Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
+          network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
 
         // Return if the MMS network state doesn't change, where the network
         // state change can come from other non-MMS networks.
         if (connected == this.connected) {
           return;
         }
 
         this.connected = connected;