summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvandwalle <vandwalle@google.com>2015-01-11 11:46:48 -0800
committervandwalle <vandwalle@google.com>2015-01-27 23:24:20 -0800
commit4fa99f57077ab287d6ed1b51cf308c44ce8bbe0b (patch)
treeb5e0f7cedbfb239759372753cb89725460444447
parent56b11b4376e0921b6d7db52f738d8360607635b9 (diff)
downloadwifi-lollipop-mr1-dev.tar.gz
aggressively blacklist WifiConfiguration for the purpose of switching networklollipop-mr1-dev
In cases where networks are not properly configured, WiFi might tries to repeatdly switch from one network to a bad network, or might try to roam and renew DHCP which can fail. In KK, WiFi autojoin would try other networks (by cycling to network it sees) and end up associated to a "good" network. In L release even thought WiFi might pick a good network it will still repeatedly try to switch to what it thinks is a better network and fail, thus annoying the user whose connection becomes unstable. This CL tries to remember networks that have seen multiple DHCP or auth failure in the past and for those networks it disable roaming temporarily. That is, if wifi is not associated to any network, it will tries to join a network aggressively, however if wifi is currently associated to a network, it will not try to switch to a new network if that new network has seen multiple failure in the past. The maximum blacklist time is set to 2 days for now. An example of such situation is: - user has multiple SSID at home, one of which is incorrectly configured with a wrong password - broken DHCP situation (potentially: multiple servers on home network, broken implementation incorrecting NAK'ing DHCP requests but properly serving DHCP offer...) Bug:18792931 Change-Id: Ib09eaaea978c772f630e86696f9a49f18ad708e2
-rw-r--r--service/java/com/android/server/wifi/WifiAutoJoinController.java23
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStore.java20
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java14
3 files changed, 56 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiAutoJoinController.java b/service/java/com/android/server/wifi/WifiAutoJoinController.java
index b86f77681..c7da1794e 100644
--- a/service/java/com/android/server/wifi/WifiAutoJoinController.java
+++ b/service/java/com/android/server/wifi/WifiAutoJoinController.java
@@ -1520,6 +1520,29 @@ public class WifiAutoJoinController {
if (config.visibility == null) {
continue;
}
+
+ if (config.lastRoamingFailure != 0
+ && currentConfiguration != null
+ && (lastSelectedConfiguration == null
+ || !config.configKey().equals(lastSelectedConfiguration))) {
+ // Apply blacklisting for roaming to this config if:
+ // - the target config had a recent roaming failure
+ // - we are currently associated
+ // - the target config is not the last selected
+ if (now > config.lastRoamingFailure
+ && (now - config.lastRoamingFailure)
+ < config.roamingFailureBlackListTimeMilli) {
+ if (DBG) {
+ logDbg("compareNetwork not switching to " + config.configKey()
+ + " from current " + currentConfiguration.configKey()
+ + " because it is blacklisted due to roam failure, "
+ + " blacklist remain time = "
+ + (now - config.lastRoamingFailure) + " ms");
+ }
+ continue;
+ }
+ }
+
int boost = config.autoJoinUseAggressiveJoinAttemptThreshold + weakRssiBailCount;
if ((config.visibility.rssi5 + boost)
< mWifiConfigStore.thresholdInitialAutoJoinAttemptMin5RSSI
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index f347d56d7..94752d369 100644
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -342,6 +342,10 @@ public class WifiConfigStore extends IpConfigStore {
public int associatedPartialScanPeriodMilli;
+ // Sane value for roam blacklisting (not switching to a network if already associated)
+ // 2 days
+ public int networkSwitchingBlackListPeriodMilli = 2 * 24 * 60 * 60 * 1000;
+
public int bandPreferenceBoostFactor5 = 5; // Boost by 5 dB per dB above threshold
public int bandPreferencePenaltyFactor5 = 2; // Penalize by 2 dB per dB below threshold
public int bandPreferencePenaltyThreshold5 = WifiConfiguration.G_BAND_PREFERENCE_RSSI_THRESHOLD;
@@ -548,6 +552,9 @@ public class WifiConfigStore extends IpConfigStore {
scanResultRssiLevelPatchUp = mContext.getResources().getInteger(
R.integer.config_wifi_framework_scan_result_rssi_level_patchup_value);
+
+ networkSwitchingBlackListPeriodMilli = mContext.getResources().getInteger(
+ R.integer.config_wifi_network_switching_blacklist_time);
}
void enableVerboseLogging(int verbose) {
@@ -928,6 +935,19 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ void noteRoamingFailure(WifiConfiguration config, int reason) {
+ if (config == null) return;
+ config.lastRoamingFailure = System.currentTimeMillis();
+ config.roamingFailureBlackListTimeMilli
+ = 2 * (config.roamingFailureBlackListTimeMilli + 1000);
+ if (config.roamingFailureBlackListTimeMilli
+ > networkSwitchingBlackListPeriodMilli) {
+ config.roamingFailureBlackListTimeMilli =
+ networkSwitchingBlackListPeriodMilli;
+ }
+ config.lastRoamingFailureReason = reason;
+ }
+
void saveWifiConfigBSSID(WifiConfiguration config) {
// Sanity check the config is valid
if (config == null || (config.networkId == INVALID_NETWORK_ID &&
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 2311e34ae..fb9e9fd5b 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -7470,8 +7470,15 @@ public class WifiStateMachine extends StateMachine {
@Override
public boolean processMessage(Message message) {
logStateAndMessage(message, getClass().getSimpleName());
-
+ WifiConfiguration config;
switch (message.what) {
+ case CMD_IP_CONFIGURATION_LOST:
+ config = getCurrentWifiConfiguration();
+ if (config != null) {
+ mWifiConfigStore.noteRoamingFailure(config,
+ WifiConfiguration.ROAMING_FAILURE_IP_CONFIG);
+ }
+ return NOT_HANDLED;
case WifiWatchdogStateMachine.POOR_LINK_DETECTED:
if (DBG) log("Roaming and Watchdog reports poor link -> ignore");
return HANDLED;
@@ -7557,6 +7564,11 @@ public class WifiStateMachine extends StateMachine {
+ " isRoaming=" + isRoaming()
+ " roam=" + Integer.toString(mAutoRoaming));
if (message.arg1 == mLastNetworkId) {
+ config = getCurrentWifiConfiguration();
+ if (config != null) {
+ mWifiConfigStore.noteRoamingFailure(config,
+ WifiConfiguration.ROAMING_FAILURE_AUTH_FAILURE);
+ }
handleNetworkDisconnect();
transitionTo(mDisconnectingState);
}