Bug 1057973 - Part 2: QueryInterface(Ci.nsIRilNetworkInterface) before accessing serviceId property. r=vyang
authorBevis Tseng <btseng@mozilla.com>
Thu, 28 Aug 2014 10:54:39 +0800
changeset 224084 91bebdf15f4883688372380404397eb2d25a59c6
parent 224083 e229a3641adaeeb2ef63bc714f6d4a55a3e00be3
child 224085 0d1bb6200f1050f00fa23fc1675b9abf9c819751
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersvyang
bugs1057973
milestone34.0a1
Bug 1057973 - Part 2: QueryInterface(Ci.nsIRilNetworkInterface) before accessing serviceId property. r=vyang
dom/system/gonk/NetworkManager.js
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -274,22 +274,19 @@ NetworkManager.prototype = {
         return interfaces;
       }
     }
   },
 
   getNetworkId: function(network) {
     let id = "device";
 #ifdef MOZ_B2G_RIL
-    if (this.isNetworkTypeMobile(network.type)) {
-      if (!(network instanceof Ci.nsIRilNetworkInterface)) {
-        throw Components.Exception("Mobile network not an nsIRilNetworkInterface",
-                                   Cr.NS_ERROR_INVALID_ARG);
-      }
-      id = "ril" + network.serviceId;
+    if (network instanceof Ci.nsIRilNetworkInterface) {
+      let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
+      id = "ril" + rilNetwork.serviceId;
     }
 #endif
 
     return id + "-" + network.type;
   },
 
   // nsINetworkManager
 
@@ -791,19 +788,21 @@ NetworkManager.prototype = {
     this.tetheringSettings = {};
     this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
   },
 
   getNetworkInterface: function(type, serviceId) {
     for each (let network in this.networkInterfaces) {
       if (network.type == type) {
 #ifdef MOZ_B2G_RIL
-        if (serviceId != undefined && this.isNetworkTypeMobile(network.type) &&
-            network.serviceId != serviceId) {
-          continue;
+        if (network instanceof Ci.nsIRilNetworkInterface) {
+          let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
+          if (rilNetwork.serviceId != serviceId) {
+            continue;
+          }
         }
 #endif
         return network;
       }
     }
     return null;
   },