Bug 1159132 - Part 1: Use dun apn only when config ro.tethering.dun_required is set. r=echen
authorJessica Jong <jjong>
Mon, 04 May 2015 02:32:00 -0400
changeset 273907 71960acb863331d7b80fbf3408d4f9c2c70944bd
parent 273906 0098029a7bddd6af650f4972d87f88637fbeae1d
child 273908 b086661e0d37c24ff8a6fa868abb9e69bd550edf
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1159132
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1159132 - Part 1: Use dun apn only when config ro.tethering.dun_required is set. r=echen
dom/system/gonk/TetheringService.js
--- a/dom/system/gonk/TetheringService.js
+++ b/dom/system/gonk/TetheringService.js
@@ -34,18 +34,16 @@ XPCOMUtils.defineLazyServiceGetter(this,
 XPCOMUtils.defineLazyGetter(this, "gRil", function() {
   try {
     return Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
   } catch (e) {}
 
   return null;
 });
 
-const TOPIC_INTERFACE_REGISTERED     = "network-interface-registered";
-const TOPIC_INTERFACE_UNREGISTERED   = "network-interface-unregistered";
 const TOPIC_MOZSETTINGS_CHANGED      = "mozsettings-changed";
 const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
 const TOPIC_PREF_CHANGED             = "nsPref:changed";
 const TOPIC_XPCOM_SHUTDOWN           = "xpcom-shutdown";
 const PREF_NETWORK_DEBUG_ENABLED     = "network.debugging.enabled";
 
 const POSSIBLE_USB_INTERFACE_NAME = "rndis0,usb0";
 const DEFAULT_USB_INTERFACE_NAME  = "rndis0";
@@ -121,18 +119,16 @@ function updateDebug() {
   }
 }
 updateDebug();
 
 function TetheringService() {
   Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
   Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
   Services.obs.addObserver(this, TOPIC_CONNECTION_STATE_CHANGED, false);
-  Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, false);
-  Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, false);
   Services.prefs.addObserver(PREF_NETWORK_DEBUG_ENABLED, this, false);
 
   this._dataDefaultServiceId = 0;
 
   // Possible usb tethering interfaces for different gonk platform.
   this.possibleInterface = POSSIBLE_USB_INTERFACE_NAME.split(",");
 
   // Default values for internal and external interfaces.
@@ -252,38 +248,20 @@ TetheringService.prototype = {
         this.handle(aSubject.key, aSubject.value);
         break;
       case TOPIC_CONNECTION_STATE_CHANGED:
         network = aSubject.QueryInterface(Ci.nsINetworkInterface);
         debug("Network " + network.type + "/" + network.name +
               " changed state to " + network.state);
         this.onConnectionChanged(network);
         break;
-      case TOPIC_INTERFACE_REGISTERED:
-        network = aSubject.QueryInterface(Ci.nsINetworkInterface);
-        if (network &&
-            network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
-          debug("Force setting " + SETTINGS_DUN_REQUIRED + " to true.");
-          this.tetheringSettings[SETTINGS_DUN_REQUIRED] = true;
-        }
-        break;
-      case TOPIC_INTERFACE_UNREGISTERED:
-        network = aSubject.QueryInterface(Ci.nsINetworkInterface);
-        if (network &&
-            network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
-          this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
-          libcutils.property_get("ro.tethering.dun_required") === "1";
-        }
-        break;
       case TOPIC_XPCOM_SHUTDOWN:
         Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
         Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
         Services.obs.removeObserver(this, TOPIC_CONNECTION_STATE_CHANGED);
-        Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
-        Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
         Services.prefs.removeObserver(PREF_NETWORK_DEBUG_ENABLED, this);
 
         this.dunConnectTimer.cancel();
         this.dunRetryTimer.cancel();
         break;
     }
   },
 
@@ -638,16 +616,20 @@ TetheringService.prototype = {
       // the request params and redo |setWifiTethering| on
       // usb tethering task complete.
       debug('USB tethering request is being processed. Queue this wifi tethering request.');
       this._pendingWifiTetheringRequestArgs = Array.prototype.slice.call(arguments);
       debug('Pending args: ' + JSON.stringify(this._pendingWifiTetheringRequestArgs));
       return;
     }
 
+    // Re-check again, test cases set this property later.
+    this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
+      libcutils.property_get("ro.tethering.dun_required") === "1";
+
     if (!aEnable) {
       this.enableWifiTethering(false, aConfig, aCallback);
       return;
     }
 
     this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface = aNetwork.name;
 
     if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {