Bug 809006 - B2G Network Manager: Unable to set default route and DNS when required system properties not available. r=vicamo

This commit is contained in:
Shian-Yow Wu 2012-11-07 15:12:52 +08:00
Родитель f20c1a6124
Коммит 923d906d77
2 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -389,7 +389,10 @@ NetworkManager.prototype = {
let options = { let options = {
cmd: this.active.dhcp ? "runDHCPAndSetDefaultRouteAndDNS" : "setDefaultRouteAndDNS", cmd: this.active.dhcp ? "runDHCPAndSetDefaultRouteAndDNS" : "setDefaultRouteAndDNS",
ifname: this.active.name, ifname: this.active.name,
oldIfname: (oldInterface && oldInterface != this.active) ? oldInterface.name : null oldIfname: (oldInterface && oldInterface != this.active) ? oldInterface.name : null,
gateway_str: this.active.gateway,
dns1_str: this.active.dns1,
dns2_str: this.active.dns2
}; };
this.worker.postMessage(options); this.worker.postMessage(options);
this.setNetworkProxy(); this.setNetworkProxy();

Просмотреть файл

@ -123,11 +123,9 @@ function networkInterfaceStatsSuccess(params) {
* Name of the network interface. * Name of the network interface.
*/ */
function getIFProperties(ifname) { function getIFProperties(ifname) {
let gateway_str = libcutils.property_get("net." + ifname + ".gw");
return { return {
ifname: ifname, ifname: ifname,
gateway: netHelpers.stringToIP(gateway_str), gateway_str: libcutils.property_get("net." + ifname + ".gw"),
gateway_str: gateway_str,
dns1_str: libcutils.property_get("net." + ifname + ".dns1"), dns1_str: libcutils.property_get("net." + ifname + ".dns1"),
dns2_str: libcutils.property_get("net." + ifname + ".dns2"), dns2_str: libcutils.property_get("net." + ifname + ".dns2"),
}; };
@ -159,13 +157,15 @@ function setDefaultRouteAndDNS(options) {
libnetutils.ifc_remove_default_route(options.oldIfname); libnetutils.ifc_remove_default_route(options.oldIfname);
} }
if (!options.gateway || !options.dns1_str) { let ifprops = getIFProperties(options.ifname);
options = getIFProperties(options.ifname); let gateway_str = options.gateway_str || ifprops.gateway_str;
} let dns1_str = options.dns1_str || ifprops.dns1_str;
let dns2_str = options.dns2_str || ifprops.dns2_str;
let gateway = netHelpers.stringToIP(gateway_str);
libnetutils.ifc_set_default_route(options.ifname, options.gateway); libnetutils.ifc_set_default_route(options.ifname, gateway);
libcutils.property_set("net.dns1", options.dns1_str); libcutils.property_set("net.dns1", dns1_str);
libcutils.property_set("net.dns2", options.dns2_str); libcutils.property_set("net.dns2", dns2_str);
// Bump the DNS change property. // Bump the DNS change property.
let dnschange = libcutils.property_get("net.dnschange", "0"); let dnschange = libcutils.property_get("net.dnschange", "0");