diff options
author | Jeff Davidson <jpd@google.com> | 2015-01-08 10:11:01 -0800 |
---|---|---|
committer | Jeff Davidson <jpd@google.com> | 2015-01-08 11:11:10 -0800 |
commit | 2c9b6297f3cd74780a084634320d03a413a3b779 (patch) | |
tree | 6c4a0238e8060b66c8580260cda73b1045f90287 /service | |
parent | 1456ea5d08ed5a4e697b58ededde4b5a90809d76 (diff) | |
download | android_frameworks_opt_net_wifi-2c9b6297f3cd74780a084634320d03a413a3b779.tar.gz android_frameworks_opt_net_wifi-2c9b6297f3cd74780a084634320d03a413a3b779.tar.bz2 android_frameworks_opt_net_wifi-2c9b6297f3cd74780a084634320d03a413a3b779.zip |
Fix incorrect tracking of ephemeral network statistics.
The lastUntrustedBSSID variable was being used as an SSID, not a
BSSID, and was not cleared after the untrusted network was
disconnected, causing stats not to increment on new connections if the
last connection was to the same SSID.
So, remove this unnecessary variable, and check the current
WifiConfiguration to determine which network we're currently using, if
any. Increment the connection count only when we are actually going to
associate with the SSID.
This only affects untrusted network flows and should have no impact
when connecting to saved Wi-Fi networks. The only non-statistical
change involves the boost given to the active network, which is
controlled by the NetworkScorer and can be updated dynamically
(outside of the framework).
Bug: 18908655
Change-Id: I5b712a4ff613d8199d0591e568886be0d2419645
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiAutoJoinController.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/service/java/com/android/server/wifi/WifiAutoJoinController.java b/service/java/com/android/server/wifi/WifiAutoJoinController.java index af1fc1bcd..b86f77681 100644 --- a/service/java/com/android/server/wifi/WifiAutoJoinController.java +++ b/service/java/com/android/server/wifi/WifiAutoJoinController.java @@ -67,9 +67,6 @@ public class WifiAutoJoinController { /** Whether to allow connections to untrusted networks. */ private boolean mAllowUntrustedConnections = false; - /* for debug purpose only : the untrusted SSID we would be connected to if we had VPN */ - String lastUntrustedBSSID = null; - /* For debug purpose only: if the scored override a score */ boolean didOverride = false; @@ -1650,17 +1647,17 @@ public class WifiAutoJoinController { !isOpenNetwork(result)) { continue; } - if (mWifiConfigStore.mDeletedEphemeralSSIDs.contains - ("\"" + result.SSID + "\"")) { + String quotedSSID = "\"" + result.SSID + "\""; + if (mWifiConfigStore.mDeletedEphemeralSSIDs.contains(quotedSSID)) { // SSID had been Forgotten by user, then don't score it continue; } if ((nowMs - result.seen) < mScanResultAutoJoinAge) { // Increment usage count for the network - mWifiConnectionStatistics.incrementOrAddUntrusted(result.SSID, 0, 1); + mWifiConnectionStatistics.incrementOrAddUntrusted(quotedSSID, 0, 1); - boolean isActiveNetwork = lastUntrustedBSSID != null - && result.BSSID.equals(lastUntrustedBSSID); + boolean isActiveNetwork = currentConfiguration != null + && currentConfiguration.SSID.equals(quotedSSID); int score = mNetworkScoreCache.getNetworkScore(result, isActiveNetwork); if (score != WifiNetworkScoreCache.INVALID_NETWORK_SCORE && score > currentScore) { @@ -1679,16 +1676,6 @@ public class WifiAutoJoinController { } } if (untrustedCandidate != null) { - if (lastUntrustedBSSID == null - || !untrustedCandidate.SSID.equals(lastUntrustedBSSID)) { - // We found a new candidate that we are going to connect to, then - // increase its connection count - mWifiConnectionStatistics. - incrementOrAddUntrusted(untrustedCandidate.SSID, 1, 0); - // Remember which SSID we are connecting to - lastUntrustedBSSID = untrustedCandidate.SSID; - } - // At this point, we have an untrusted network candidate. // Create the new ephemeral configuration and see if we should switch over candidate = @@ -1772,6 +1759,13 @@ public class WifiAutoJoinController { candidate.numAssociation++; mWifiConnectionStatistics.numAutoJoinAttempt++; + if (candidate.ephemeral) { + // We found a new candidate that we are going to connect to, then + // increase its connection count + mWifiConnectionStatistics. + incrementOrAddUntrusted(candidate.SSID, 1, 0); + } + if (candidate.BSSID == null || candidate.BSSID.equals("any")) { // First step we selected the configuration we want to connect to // Second step: Look for the best Scan result for this configuration |