handle bssid blacklist in case of dhcp failures
Change-Id: Iba13db478ed69976c37bd4882f59bf0cae2212e6
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index b49fc90..5e9e497 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -405,6 +405,15 @@
<!-- Integer indicating associated full scan max num passive channels -->
<integer translatable="false" name="config_wifi_framework_associated_partial_scan_max_num_passive_channels">3</integer>
+ <!-- Integer indicating number of association errors leading to blacklisting of the network -->
+ <integer translatable="false" name="config_wifi_framework_max_connection_errors_to_blacklist">4</integer>
+
+ <!-- Integer indicating number of authentication errors leading to blacklisting of the network -->
+ <integer translatable="false" name="config_wifi_framework_max_auth_errors_to_blacklist">4</integer>
+
+ <!-- Integer indicating minimum blacklisting delay of a wofo configuration due to connectin or auth errors -->
+ <integer translatable="false" name="config_wifi_framework_network_black_list_min_time_milli">120000</integer>
+
<!-- Boolean indicating associated scan are allowed -->
<bool translatable="false" name="config_wifi_framework_enable_associated_autojoin_scan">true</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c580d26..11fa2c2 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -330,7 +330,10 @@
<java-symbol type="integer" name="config_wifi_framework_associated_partial_scan_tx_packet_threshold" />
<java-symbol type="integer" name="config_wifi_framework_associated_partial_scan_rx_packet_threshold" />
<java-symbol type="integer" name="config_wifi_framework_network_switch_tx_packet_threshold" />
- <java-symbol type="integer" name="config_wifi_framework_network_switch_tx_packet_threshold" />
+ <java-symbol type="integer" name="config_wifi_framework_network_switch_rx_packet_threshold" />
+ <java-symbol type="integer" name="config_wifi_framework_max_connection_errors_to_blacklist" />
+ <java-symbol type="integer" name="config_wifi_framework_max_auth_errors_to_blacklist" />
+ <java-symbol type="integer" name="config_wifi_framework_network_black_list_min_time_milli" />
<java-symbol type="integer" name="config_bluetooth_max_advertisers" />
<java-symbol type="integer" name="config_bluetooth_max_scan_filters" />
<java-symbol type="integer" name="config_cursorWindowSize" />
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java
index 27c2541..29656c9 100644
--- a/wifi/java/android/net/wifi/ScanResult.java
+++ b/wifi/java/android/net/wifi/ScanResult.java
@@ -107,6 +107,12 @@
public int autoJoinStatus;
/**
+ * num IP configuration failures
+ * @hide
+ */
+ public int numIpConfigFailures;
+
+ /**
* @hide
* Last time we blacklisted the ScanResult
*/
@@ -256,6 +262,7 @@
untrusted = source.untrusted;
numConnection = source.numConnection;
numUsage = source.numUsage;
+ numIpConfigFailures = source.numIpConfigFailures;
}
}
@@ -320,6 +327,7 @@
dest.writeInt(untrusted ? 1 : 0);
dest.writeInt(numConnection);
dest.writeInt(numUsage);
+ dest.writeInt(numIpConfigFailures);
if (informationElements != null) {
dest.writeInt(informationElements.length);
for (int i = 0; i < informationElements.length; i++) {
@@ -355,6 +363,7 @@
sr.untrusted = in.readInt() != 0;
sr.numConnection = in.readInt();
sr.numUsage = in.readInt();
+ sr.numIpConfigFailures = in.readInt();
int n = in.readInt();
if (n != 0) {
sr.informationElements = new InformationElement[n];
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index d27c2f7..4f5f31a 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -203,6 +203,12 @@
public int status;
/**
+ * The configuration needs to be written to networkHistory.txt
+ * @hide
+ */
+ public boolean dirty;
+
+ /**
* The code referring to a reason for disabling the network
* Valid when {@link #status} == Status.DISABLED
* @hide
@@ -621,6 +627,18 @@
/**
* @hide
+ * Number of IP config failures
+ */
+ public int numIpConfigFailures;
+
+ /**
+ * @hide
+ * Number of Auth failures
+ */
+ public int numAuthFailures;
+
+ /**
+ * @hide
* Last time we blacklisted the configuration
*/
public long blackListTimestamp;
@@ -884,7 +902,10 @@
} else if (status > autoJoinStatus) {
blackListTimestamp = System.currentTimeMillis();
}
- autoJoinStatus = status;
+ if (status != autoJoinStatus) {
+ autoJoinStatus = status;
+ dirty = true;
+ }
}
@Override
@@ -893,7 +914,7 @@
if (this.status == WifiConfiguration.Status.CURRENT) {
sbuf.append("* ");
} else if (this.status == WifiConfiguration.Status.DISABLED) {
- sbuf.append("- DSBLE: ").append(this.disableReason).append(" ");
+ sbuf.append("- DSBLE");
}
sbuf.append("ID: ").append(this.networkId).append(" SSID: ").append(this.SSID).
append(" BSSID: ").append(this.BSSID).append(" FQDN: ").append(this.FQDN).
@@ -902,8 +923,20 @@
if (this.numConnectionFailures > 0) {
sbuf.append(" numConnectFailures ").append(this.numConnectionFailures).append("\n");
}
+ if (this.numIpConfigFailures > 0) {
+ sbuf.append(" numIpConfigFailures ").append(this.numIpConfigFailures).append("\n");
+ }
+ if (this.numAuthFailures > 0) {
+ sbuf.append(" numAuthFailures ").append(this.numAuthFailures).append("\n");
+ }
if (this.autoJoinStatus > 0) {
- sbuf.append(" autoJoinStatus ").append(this.numConnectionFailures).append("\n");
+ sbuf.append(" autoJoinStatus ").append(this.autoJoinStatus).append("\n");
+ }
+ if (this.disableReason > 0) {
+ sbuf.append(" disableReason ").append(this.disableReason).append("\n");
+ }
+ if (this.numAssociation > 0) {
+ sbuf.append(" numAssociation ").append(this.numAssociation).append("\n");
}
if (this.didSelfAdd) sbuf.append(" didSelfAdd");
if (this.selfAdded) sbuf.append(" selfAdded");
@@ -1028,10 +1061,17 @@
}
}
if (this.scanResultCache != null) {
- sbuf.append("scan cache: ");
+ sbuf.append("Scan Cache: ");
for(ScanResult result : this.scanResultCache.values()) {
sbuf.append("{").append(result.BSSID).append(",").append(result.frequency);
- sbuf.append(",").append(result.level).append(",st=");
+ sbuf.append(",").append(result.level);
+ if (result.autoJoinStatus > 0) {
+ sbuf.append(",st=").append(result.autoJoinStatus);
+ }
+ if (result.numIpConfigFailures > 0) {
+ sbuf.append(",ipfail=");
+ sbuf.append(result.numIpConfigFailures);
+ }
sbuf.append(result.autoJoinStatus).append("} ");
}
sbuf.append('\n');
@@ -1356,6 +1396,8 @@
lastDisconnected = source.lastDisconnected;
lastConnectionFailure = source.lastConnectionFailure;
numConnectionFailures = source.numConnectionFailures;
+ numIpConfigFailures = source.numIpConfigFailures;
+ numAuthFailures = source.numAuthFailures;
numScorerOverride = source.numScorerOverride;
numScorerOverrideAndSwitchedNetwork = source.numScorerOverrideAndSwitchedNetwork;
numAssociation = source.numAssociation;
@@ -1370,6 +1412,7 @@
autoJoinUseAggressiveJoinAttemptThreshold
= source.autoJoinUseAggressiveJoinAttemptThreshold;
autoJoinBailedDueToLowRssi = source.autoJoinBailedDueToLowRssi;
+ dirty = source.dirty;
}
}
@@ -1420,6 +1463,8 @@
dest.writeLong(blackListTimestamp);
dest.writeLong(lastConnectionFailure);
dest.writeInt(numConnectionFailures);
+ dest.writeInt(numIpConfigFailures);
+ dest.writeInt(numAuthFailures);
dest.writeInt(numScorerOverride);
dest.writeInt(numScorerOverrideAndSwitchedNetwork);
dest.writeInt(numAssociation);
@@ -1478,6 +1523,8 @@
config.blackListTimestamp = in.readLong();
config.lastConnectionFailure = in.readLong();
config.numConnectionFailures = in.readInt();
+ config.numIpConfigFailures = in.readInt();
+ config.numAuthFailures = in.readInt();
config.numScorerOverride = in.readInt();
config.numScorerOverrideAndSwitchedNetwork = in.readInt();
config.numAssociation = in.readInt();