summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-06-23 18:18:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-06-23 18:19:00 +0000
commit6560e4d203ffc5c1306b466921833e466cf2b5a7 (patch)
tree25f632d2c03b9b03e1dd68b5c15407cedb40a3a3 /service
parent366133c457a4fda565c0845287e0db122f67f782 (diff)
parentc5e71bfd00163a0efe3f469a04d303cfb4dcc617 (diff)
Merge "Permanent disable network with wrong password" into oc-dr1-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java6
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java33
2 files changed, 34 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 3dbba221a..3c81922c3 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -122,7 +122,8 @@ public class WifiConfigManager {
1, // threshold for DISABLED_AUTHENTICATION_NO_CREDENTIALS
1, // threshold for DISABLED_NO_INTERNET
1, // threshold for DISABLED_BY_WIFI_MANAGER
- 1 // threshold for DISABLED_BY_USER_SWITCH
+ 1, // threshold for DISABLED_BY_USER_SWITCH
+ 1 // threshold for DISABLED_BY_WRONG_PASSWORD
};
/**
* Network Selection disable timeout for each kind of error. After the timeout milliseconds,
@@ -143,7 +144,8 @@ public class WifiConfigManager {
Integer.MAX_VALUE, // threshold for DISABLED_AUTHENTICATION_NO_CREDENTIALS
Integer.MAX_VALUE, // threshold for DISABLED_NO_INTERNET
Integer.MAX_VALUE, // threshold for DISABLED_BY_WIFI_MANAGER
- Integer.MAX_VALUE // threshold for DISABLED_BY_USER_SWITCH
+ Integer.MAX_VALUE, // threshold for DISABLED_BY_USER_SWITCH
+ Integer.MAX_VALUE // threshold for DISABLED_BY_WRONG_PASSWORD
};
/**
* Interface for other modules to listen to the saved network updated
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 31cc9ef33..0fb61df17 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3581,6 +3581,27 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
+ /**
+ * Determine if the specified auth failure is considered to be a permanent wrong password
+ * failure. The criteria for such failure is when wrong password error is detected
+ * and the network had never been connected before.
+ *
+ * For networks that have previously connected successfully, we consider wrong password
+ * failures to be temporary, to be on the conservative side. Since this might be the
+ * case where we are trying to connect to a wrong network (e.g. A network with same SSID
+ * but different password).
+ */
+ private boolean isPermanentWrongPasswordFailure(int networkId, int reasonCode) {
+ if (reasonCode != WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD) {
+ return false;
+ }
+ WifiConfiguration network = mWifiConfigManager.getConfiguredNetwork(networkId);
+ if (network != null && network.getNetworkSelectionStatus().getHasEverConnected()) {
+ return false;
+ }
+ return true;
+ }
+
private class WifiNetworkFactory extends NetworkFactory {
public WifiNetworkFactory(Looper l, Context c, String TAG, NetworkCapabilities f) {
super(l, c, TAG, f);
@@ -4838,9 +4859,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiDiagnostics.captureBugReportData(
WifiDiagnostics.REPORT_REASON_AUTH_FAILURE);
mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT);
- mWifiConfigManager.updateNetworkSelectionStatus(mTargetNetworkId,
- WifiConfiguration.NetworkSelectionStatus
- .DISABLED_AUTHENTICATION_FAILURE);
+ int disableReason = WifiConfiguration.NetworkSelectionStatus
+ .DISABLED_AUTHENTICATION_FAILURE;
+ // Check if this is a permanent wrong password failure.
+ if (isPermanentWrongPasswordFailure(mTargetNetworkId, message.arg2)) {
+ disableReason = WifiConfiguration.NetworkSelectionStatus
+ .DISABLED_BY_WRONG_PASSWORD;
+ }
+ mWifiConfigManager.updateNetworkSelectionStatus(
+ mTargetNetworkId, disableReason);
//If failure occurred while Metrics is tracking a ConnnectionEvent, end it.
reportConnectionAttemptEnd(
WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE,