diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-01-27 15:45:27 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-01-28 20:54:12 -0800 |
commit | 05d72117f9b449914979b008c17edd6c5645565b (patch) | |
tree | 8028a5bce21c9bb71e665605793cd35b69c259f7 /wifi/java/android | |
parent | c4a0c2744a19a42bd1f5c39a6f1673310c6f9c3a (diff) | |
download | frameworks_base-05d72117f9b449914979b008c17edd6c5645565b.zip frameworks_base-05d72117f9b449914979b008c17edd6c5645565b.tar.gz frameworks_base-05d72117f9b449914979b008c17edd6c5645565b.tar.bz2 |
Handle error strings from monitor connection
Bug: 2399119
Change-Id: I481cfbfb11fb453659134004aafa3df236ba050b
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/WifiMonitor.java | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java index 3594ba6..0928d2b 100644 --- a/wifi/java/android/net/wifi/WifiMonitor.java +++ b/wifi/java/android/net/wifi/WifiMonitor.java @@ -119,6 +119,26 @@ public class WifiMonitor { private final WifiStateTracker mWifiStateTracker; + /** + * This indicates the supplicant connection for the monitor is closed + */ + private static final String monitorSocketClosed = "connection closed"; + + /** + * This indicates a read error on the monitor socket conenction + */ + private static final String wpaRecvError = "recv error"; + + /** + * Tracks consecutive receive errors + */ + private int mRecvErrors = 0; + + /** + * Max errors before we close supplicant connection + */ + private static final int MAX_RECV_ERRORS = 10; + public WifiMonitor(WifiStateTracker tracker) { mWifiStateTracker = tracker; } @@ -151,16 +171,13 @@ public class WifiMonitor { for (;;) { String eventStr = WifiNative.waitForEvent(); - if (eventStr == null) { - continue; - } - // Skip logging the common but mostly uninteresting scan-results event if (Config.LOGD && eventStr.indexOf(scanResultsEvent) == -1) { Log.v(TAG, "Event [" + eventStr + "]"); } if (!eventStr.startsWith(eventPrefix)) { - if (eventStr.startsWith(wpaEventPrefix) && 0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) { + if (eventStr.startsWith(wpaEventPrefix) && + 0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) { handlePasswordKeyMayBeIncorrect(); } continue; @@ -216,12 +233,38 @@ public class WifiMonitor { } else if (event == DRIVER_STATE) { handleDriverEvent(eventData); } else if (event == TERMINATING) { + /** + * If monitor socket is closed, we have already + * stopped the supplicant, simply exit the monitor thread + */ + if (eventData.startsWith(monitorSocketClosed)) { + if (Config.LOGD) { + Log.d(TAG, "Monitor socket is closed, exiting thread"); + } + break; + } + + /** + * Close the supplicant connection if we see + * too many recv errors + */ + if (eventData.startsWith(wpaRecvError)) { + if (++mRecvErrors > MAX_RECV_ERRORS) { + if (Config.LOGD) { + Log.d(TAG, "too many recv errors, closing connection"); + } + } else { + continue; + } + } + + // notify and exit mWifiStateTracker.notifySupplicantLost(); - // If supplicant is gone, exit the thread break; } else { handleEvent(event, eventData); } + mRecvErrors = 0; } } |