Closed Bug 730830 Opened 13 years ago Closed 13 years ago

Don't add the Mozilla networks if they already exist

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mrbkap, Unassigned)

References

Details

Attachments

(1 file)

Attached patch patch (deleted) — Splinter Review
Right now, we'll add the hacked mozilla networks, even if there's already an entry for them, we should avoid doing so. Of note here is a fix to getNetworkConfiguration where the change from var -> let means that each closure created inside the loop gets its own fieldName.
Attachment #600923 - Flags: review?(gal)
Attachment #600923 - Flags: review?(gal) → review?(21)
Comment on attachment 600923 [details] [diff] [review] patch >diff --git a/dom/wifi/nsWifiWorker.js b/dom/wifi/nsWifiWorker.js >@@ -861,6 +861,13 @@ var WifiManager = (function() { > var done = 0; > var errors = 0; > var lines = reply.split("\n"); >+ if (lines.length === 1) { >+ // We need to make sure we call the callback even if there are no >+ // configured networks. >+ callback(networks); >+ return; >+ } nit: maybe you can return before declaring the done and errors variables >@@ -986,7 +993,33 @@ function nsWifiWorker() { > WifiManager.scan(false, function(){}); > }); > } >- addThem(); >+ >+ WifiManager.getConfiguredNetworks(function(networks) { >+ if (!networks) { >+ debug("Unable to get existing networks"); >+ return; >+ } >+ >+ // O(n*m) but this is all temporary, right? >+ // We enable any of our networks that area already configured but >+ // disabled and avoid re-adding them if they exist. >+ for each (let net in networks) { >+ if (!net.ssid) >+ continue; >+ for (let known = 0; known < configs.length; ++known) { >+ if (configs[known].ssid !== net.ssid) >+ continue; >+ >+ configs.splice(known, 1); >+ if (net.status === "DISABLED") >+ WifiManager.enableNetwork(net.netId, false, function() {}); >+ break; >+ } >+ } >+ >+ if (configs.length > 0) >+ addThem(); >+ }); This is not really elegant but this has been removed into another bug, right? r+ with the small nit and a bug number for this part of the code that will/has been removed elsewhere.
Attachment #600923 - Flags: review?(21) → review+
This landed yesterday with bug 732982.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: