summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-01-14 12:37:49 -0800
committerIrfan Sheriff <isheriff@google.com>2010-01-28 11:27:14 -0800
commit0049a1bf3f8bae3a10cfeff38aefce215bf1298b (patch)
tree7153232b780840367b5ca29b08f8d66d3633520d /wifi/java/android/net
parent5f551ef6a8b6a4f158d8b3ad9591d2f874c89f39 (diff)
downloadframeworks_base-0049a1bf3f8bae3a10cfeff38aefce215bf1298b.zip
frameworks_base-0049a1bf3f8bae3a10cfeff38aefce215bf1298b.tar.gz
frameworks_base-0049a1bf3f8bae3a10cfeff38aefce215bf1298b.tar.bz2
Blacklist APs instead of disable
We currently disable networks upon too many reconnects. This leads to asking the user input for reconnects. Blacklist it instead. Bug: 2129037 Change-Id: I23d69daf3964c066ed7f70d32fefb81016f19aa2
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/WifiMonitor.java8
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java36
2 files changed, 34 insertions, 10 deletions
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);
}