diff options
author | Nalla Kartheek <karthe@codeaurora.org> | 2015-02-20 14:55:21 +0530 |
---|---|---|
committer | AragaoAnderson <andersonaragao@me.com> | 2015-04-11 21:30:22 -0300 |
commit | 2caaed6bb73020faad5f656844ae093aa40f7a56 (patch) | |
tree | fd8801590257c6018696c371264fb5d12a05ea11 /service/java/com/android | |
parent | 1e45f2f13c0e5b5a1d595da0df0dc57bd1aca93f (diff) | |
download | android_frameworks_opt_net_wifi-2caaed6bb73020faad5f656844ae093aa40f7a56.tar.gz android_frameworks_opt_net_wifi-2caaed6bb73020faad5f656844ae093aa40f7a56.tar.bz2 android_frameworks_opt_net_wifi-2caaed6bb73020faad5f656844ae093aa40f7a56.zip |
Wifi: Filter the scan results based on the configured band
Framework needs to get the scan results based on the configured band as the
supplicant / host driver shall maintain the cache for these scan results.
Without this, the UI shall display the scan results not corresponding to the
configured band.
This band capability also needs to be considered while getting the visibility
of the network to trigger auto join.
This commit ensures the same.
Change-Id: Iccc9ab936895b3fb1028c2ad6a4fa12b7d4c7067
CRs-Fixed: 797374
Diffstat (limited to 'service/java/com/android')
3 files changed, 42 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiAutoJoinController.java b/service/java/com/android/server/wifi/WifiAutoJoinController.java index c8fbc8dc9..43312102b 100644 --- a/service/java/com/android/server/wifi/WifiAutoJoinController.java +++ b/service/java/com/android/server/wifi/WifiAutoJoinController.java @@ -950,6 +950,10 @@ public class WifiAutoJoinController { if (!mWifiConfigStore.enable5GHzPreference) { return 0; } + if (mWifiStateMachine.getFrequencyBand() + == WifiManager.WIFI_FREQUENCY_BAND_2GHZ) { + return 0; + } if (rssi > mWifiConfigStore.bandPreferenceBoostThreshold5) { // Boost by 2 dB for each point @@ -1019,12 +1023,21 @@ public class WifiAutoJoinController { // Determine which BSSID we want to associate to, taking account // relative strength of 5 and 2.4 GHz BSSIDs long nowMs = System.currentTimeMillis(); + int currentBand = mWifiStateMachine.getFrequencyBand(); for (ScanResult b : current.scanResultCache.values()) { int bRssiBoost5 = 0; int aRssiBoost5 = 0; int bRssiBoost = 0; int aRssiBoost = 0; + if (b.is5GHz() + && (currentBand == WifiManager.WIFI_FREQUENCY_BAND_2GHZ)) { + continue; + } + if (b.is24GHz() + && (currentBand == WifiManager.WIFI_FREQUENCY_BAND_5GHZ)) { + continue; + } if ((b.seen == 0) || (b.BSSID == null) || ((nowMs - b.seen) > age) || b.autoJoinStatus != ScanResult.ENABLED @@ -1151,9 +1164,18 @@ public class WifiAutoJoinController { long nowMs = System.currentTimeMillis(); int startScore = -10000; + int currentBand = mWifiStateMachine.getFrequencyBand(); // Run thru all cached scan results for (ScanResult result : config.scanResultCache.values()) { + if (result.is5GHz() + && (currentBand == WifiManager.WIFI_FREQUENCY_BAND_2GHZ)) { + continue; + } + if (result.is24GHz() + && (currentBand == WifiManager.WIFI_FREQUENCY_BAND_5GHZ)) { + continue; + } if ((nowMs - result.seen) < age) { int sc = mNetworkScoreCache.getNetworkScore(result, isActive); if (sc > startScore) { diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index 5478d144b..b14226a2d 100755 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -398,6 +398,8 @@ public class WifiConfigStore extends IpConfigStore { public static final int maxNumScanCacheEntries = 128; + private int mConfiguredBand = 0; + /** * Regex pattern for extracting a connect choice. * Matches a strings like the following: @@ -677,7 +679,7 @@ public class WifiConfigStore extends IpConfigStore { } // Calculate the RSSI for scan results that are more recent than milli - config.setVisibility(milli); + config.setVisibility(milli, mConfiguredBand); if (config.visibility == null) { continue; } @@ -1904,6 +1906,10 @@ public class WifiConfigStore extends IpConfigStore { return lastSelectedConfiguration; } + public void setConfiguredBand(int band) { + mConfiguredBand = band; + } + public boolean isLastSelectedConfiguration(WifiConfiguration config) { return (lastSelectedConfiguration != null && config != null diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index bae925286..c921925ea 100755 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -3590,6 +3590,17 @@ public class WifiStateMachine extends StateMachine { scanResult.seen = System.currentTimeMillis(); mScanResultCache.put(key, scanResult); } + if (mFrequencyBand.get() + == WifiManager.WIFI_FREQUENCY_BAND_2GHZ) { + if (ScanResult.is5GHz(freq)) { + continue; + } + } else if (mFrequencyBand.get() + == WifiManager.WIFI_FREQUENCY_BAND_5GHZ) { + if (ScanResult.is24GHz(freq)) { + continue; + } + } mNumScanResultsReturned ++; // Keep track of how many scan results we got // as part of this scan's processing mScanResults.add(scanResult); @@ -3830,7 +3841,7 @@ public class WifiStateMachine extends StateMachine { WifiConfiguration currentConfiguration = getCurrentWifiConfiguration(); if (currentConfiguration != null && currentConfiguration.scanResultCache != null) { - currentConfiguration.setVisibility(12000); + currentConfiguration.setVisibility(12000, mFrequencyBand.get()); if (currentConfiguration.visibility != null) { if (currentConfiguration.visibility.rssi24 != WifiConfiguration.INVALID_RSSI && currentConfiguration.visibility.rssi24 @@ -5657,6 +5668,7 @@ public class WifiStateMachine extends StateMachine { if (PDBG) loge("did set frequency band " + band); mFrequencyBand.set(band); + mWifiConfigStore.setConfiguredBand(band); // Flush old data - like scan results mWifiNative.bssFlush(); if (mFrequencyBand.get() == WifiManager.WIFI_FREQUENCY_BAND_2GHZ) { |