summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--services/java/com/android/server/WifiWatchdogService.java2
-rw-r--r--wifi/java/android/net/wifi/WifiMonitor.java8
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java36
3 files changed, 36 insertions, 10 deletions
diff --git a/services/java/com/android/server/WifiWatchdogService.java b/services/java/com/android/server/WifiWatchdogService.java
index 9443a95..f2347ed 100644
--- a/services/java/com/android/server/WifiWatchdogService.java
+++ b/services/java/com/android/server/WifiWatchdogService.java
@@ -739,6 +739,8 @@ public class WifiWatchdogService {
// Black list this "bad" AP, this will cause an attempt to connect to another
blacklistAp(ap.bssid);
+ // Initiate an association to an alternate AP
+ mWifiStateTracker.reassociate();
}
private void blacklistAp(String bssid) {
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index 1e322bd..3594ba6 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -293,6 +293,7 @@ public class WifiMonitor {
private void handleSupplicantStateChange(String dataString) {
String[] dataTokens = dataString.split(" ");
+ String BSSID = null;
int networkId = -1;
int newState = -1;
for (String token : dataTokens) {
@@ -301,6 +302,11 @@ public class WifiMonitor {
continue;
}
+ if (nameValue[0].equals("BSSID")) {
+ BSSID = nameValue[1];
+ continue;
+ }
+
int value;
try {
value = Integer.parseInt(nameValue[1]);
@@ -328,7 +334,7 @@ public class WifiMonitor {
if (newSupplicantState == SupplicantState.INVALID) {
Log.w(TAG, "Invalid supplicant state: " + newState);
}
- mWifiStateTracker.notifyStateChange(networkId, newSupplicantState);
+ mWifiStateTracker.notifyStateChange(networkId, BSSID, newSupplicantState);
}
}
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 2668fe0..cb615d2 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -304,11 +304,13 @@ public class WifiStateTracker extends NetworkStateTracker {
* thread.
*/
private static class SupplicantStateChangeResult {
- SupplicantStateChangeResult(int networkId, SupplicantState state) {
+ SupplicantStateChangeResult(int networkId, String BSSID, SupplicantState state) {
this.state = state;
+ this.BSSID = BSSID;
this.networkId = networkId;
}
int networkId;
+ String BSSID;
SupplicantState state;
}
@@ -512,10 +514,10 @@ public class WifiStateTracker extends NetworkStateTracker {
* @param networkId the configured network on which the state change occurred
* @param newState the new {@code SupplicantState}
*/
- void notifyStateChange(int networkId, SupplicantState newState) {
+ void notifyStateChange(int networkId, String BSSID, SupplicantState newState) {
Message msg = Message.obtain(
this, EVENT_SUPPLICANT_STATE_CHANGED,
- new SupplicantStateChangeResult(networkId, newState));
+ new SupplicantStateChangeResult(networkId, BSSID, newState));
msg.sendToTarget();
}
@@ -884,6 +886,13 @@ public class WifiStateTracker extends NetworkStateTracker {
int networkId = supplicantStateResult.networkId;
+ /**
+ * The SupplicantState BSSID value is valid in ASSOCIATING state only.
+ * The NetworkState BSSID value comes upon a successful connection.
+ */
+ if (supplicantStateResult.state == SupplicantState.ASSOCIATING) {
+ mLastBssid = supplicantStateResult.BSSID;
+ }
/*
* If we get disconnect or inactive we need to start our
* watchdog timer to start a scan
@@ -928,6 +937,7 @@ public class WifiStateTracker extends NetworkStateTracker {
setSupplicantState(newState);
if (newState == SupplicantState.DORMANT) {
DetailedState newDetailedState;
+ Message reconnectMsg = obtainMessage(EVENT_DEFERRED_RECONNECT, mLastBssid);
if (mIsScanOnly || mRunState == RUN_STATE_STOPPING) {
newDetailedState = DetailedState.IDLE;
} else {
@@ -942,7 +952,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* milliseconds.
*/
if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly && networkId != -1) {
- sendEmptyMessageDelayed(EVENT_DEFERRED_RECONNECT, RECONNECT_DELAY_MSECS);
+ sendMessageDelayed(reconnectMsg, RECONNECT_DELAY_MSECS);
} else if (mRunState == RUN_STATE_STOPPING) {
synchronized (this) {
WifiNative.stopDriverCommand();
@@ -1104,15 +1114,19 @@ public class WifiStateTracker extends NetworkStateTracker {
break;
case EVENT_DEFERRED_RECONNECT:
- /*
+ String BSSID = msg.obj.toString();
+ /**
* If we've exceeded the maximum number of retries for reconnecting
- * to a given network, disable the network so that the supplicant
- * will try some other network, if any is available.
- * TODO: network ID may have changed since we stored it.
+ * to a given network, blacklist the BSSID to allow a connection attempt on
+ * an alternate BSSID if available
*/
if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) {
if (++mReconnectCount > getMaxDhcpRetries()) {
- mWM.disableNetwork(mLastNetworkId);
+ if (LOCAL_LOGD) {
+ Log.d(TAG, "Failed reconnect count: " +
+ mReconnectCount + " Blacklisting " + BSSID);
+ }
+ addToBlacklist(BSSID);
}
synchronized(this) {
WifiNative.reconnectCommand();
@@ -1684,6 +1698,10 @@ public class WifiStateTracker extends NetworkStateTracker {
mNumScansSinceNetworkStateChange = 0;
}
+ public synchronized boolean reassociate() {
+ return WifiNative.reassociateCommand();
+ }
+
public synchronized boolean addToBlacklist(String bssid) {
return WifiNative.addToBlacklistCommand(bssid);
}