Bug 804531 - B2G 3G: When primary APN available, default route should not be set to secondary APN. r=philikon

This commit is contained in:
Shian-Yow Wu 2012-11-01 17:09:45 +08:00
parent 4f15ab1350
commit ea890e70aa

View File

@ -333,6 +333,7 @@ NetworkManager.prototype = {
setAndConfigureActive: function setAndConfigureActive() { setAndConfigureActive: function setAndConfigureActive() {
debug("Evaluating whether active network needs to be changed."); debug("Evaluating whether active network needs to be changed.");
let oldActive = this.active; let oldActive = this.active;
let defaultDataNetwork;
if (this._overriddenActive) { if (this._overriddenActive) {
debug("We have an override for the active network: " + debug("We have an override for the active network: " +
@ -340,12 +341,6 @@ NetworkManager.prototype = {
// The override was just set, so reconfigure the network. // The override was just set, so reconfigure the network.
if (this.active != this._overriddenActive) { if (this.active != this._overriddenActive) {
this.active = this._overriddenActive; this.active = this._overriddenActive;
// Don't set default route and DNS on secondary APN
if (oldActive &&
(oldActive.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
oldActive.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL)) {
return;
}
this.setDefaultRouteAndDNS(oldActive); this.setDefaultRouteAndDNS(oldActive);
} }
return; return;
@ -365,6 +360,9 @@ NetworkManager.prototype = {
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
continue; continue;
} }
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
defaultDataNetwork = network;
}
this.active = network; this.active = network;
if (network.type == this.preferredNetworkType) { if (network.type == this.preferredNetworkType) {
debug("Found our preferred type of network: " + network.name); debug("Found our preferred type of network: " + network.name);
@ -372,11 +370,14 @@ NetworkManager.prototype = {
} }
} }
if (this.active) { if (this.active) {
// Don't set default route and DNS on secondary APN // Give higher priority to default data APN than seconary APN.
if (oldActive && // If default data APN is not connected, we still set default route
(oldActive.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || // and DNS on seconary APN.
oldActive.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL)) { if (defaultDataNetwork &&
return; (this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) &&
this.active.type != this.preferredNetworkType) {
this.active = defaultDataNetwork;
} }
this.setDefaultRouteAndDNS(oldActive); this.setDefaultRouteAndDNS(oldActive);
} }