summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiMonitor.java
diff options
context:
space:
mode:
authorvandwalle <vandwalle@google.com>2014-06-23 19:49:21 -0700
committervandwalle <vandwalle@google.com>2014-06-24 18:35:48 -0700
commitb07da189850a4bfa268f8ab9be7867935eb2ecb5 (patch)
tree422c2ad1a81c483edb7aef397e26d49f24733dde /service/java/com/android/server/wifi/WifiMonitor.java
parent09928de73a030a140492c4d92b7167cd003d2a75 (diff)
downloadandroid_frameworks_opt_net_wifi-b07da189850a4bfa268f8ab9be7867935eb2ecb5.tar.gz
android_frameworks_opt_net_wifi-b07da189850a4bfa268f8ab9be7867935eb2ecb5.tar.bz2
android_frameworks_opt_net_wifi-b07da189850a4bfa268f8ab9be7867935eb2ecb5.zip
improve link flapping
Change-Id: Ie378dde318dccaa566f660c9497bae31d4a9f1ab
Diffstat (limited to 'service/java/com/android/server/wifi/WifiMonitor.java')
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index 15c33575f..95af3dbc0 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -792,6 +792,9 @@ public class WifiMonitor {
* event name and &quot;&#8195;&#8212;&#8195;&quot;
*/
void handleEvent(int event, String remainder) {
+ if (DBG) {
+ logDbg("handleEvent " + Integer.toString(event) + " " + remainder);
+ }
switch (event) {
case DISCONNECTED:
handleNetworkStateChange(NetworkInfo.DetailedState.DISCONNECTED, remainder);
@@ -806,6 +809,9 @@ public class WifiMonitor {
break;
case UNKNOWN:
+ if (DBG) {
+ logDbg("handleEvent unknown: " + Integer.toString(event) + " " + remainder);
+ }
break;
}
}
@@ -1068,10 +1074,12 @@ public class WifiMonitor {
private void handleNetworkStateChange(NetworkInfo.DetailedState newState, String data) {
String BSSID = null;
int networkId = -1;
- if (newState == NetworkInfo.DetailedState.CONNECTED) {
+ int reason = 0;
+ if (newState == NetworkInfo.DetailedState.CONNECTED
+ || newState == NetworkInfo.DetailedState.DISCONNECTED) {
Matcher match = mConnectedEventPattern.matcher(data);
if (!match.find()) {
- if (DBG) Log.d(TAG, "Could not find BSSID in CONNECTED event string");
+ if (DBG) Log.d(TAG, "handleNetworkStateChange: Could not find BSSID in event string");
} else {
BSSID = match.group(1);
try {
@@ -1079,8 +1087,12 @@ public class WifiMonitor {
} catch (NumberFormatException e) {
networkId = -1;
}
+ int ind = data.indexOf("reason=");
+ if (ind > 0) {
+ reason = Integer.parseInt(data.substring(ind+7));
+ }
}
- notifyNetworkStateChange(newState, BSSID, networkId);
+ notifyNetworkStateChange(newState, BSSID, networkId, reason);
}
}
@@ -1093,14 +1105,18 @@ public class WifiMonitor {
* is {@code null}.
* @param netId the configured network on which the state change occurred
*/
- void notifyNetworkStateChange(NetworkInfo.DetailedState newState, String BSSID, int netId) {
+ void notifyNetworkStateChange(NetworkInfo.DetailedState newState, String BSSID, int netId, int reason) {
if (newState == NetworkInfo.DetailedState.CONNECTED) {
Message m = mStateMachine.obtainMessage(NETWORK_CONNECTION_EVENT,
- netId, 0, BSSID);
+ netId, reason, BSSID);
mStateMachine.sendMessage(m);
} else {
+
Message m = mStateMachine.obtainMessage(NETWORK_DISCONNECTION_EVENT,
- netId, 0, BSSID);
+ netId, reason, BSSID);
+ if (DBG) logDbg("WifiMonitor notify network disconnect: "
+ + BSSID + " id=" + Integer.toString(netId)
+ + " reason=" + Integer.toString(reason));
mStateMachine.sendMessage(m);
}
}