diff options
author | Robert Greenwalt <robdroid@android.com> | 2009-10-07 17:57:49 -0700 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2009-10-21 14:05:09 -0700 |
commit | 1538dba4b00f767ddc4010e05b5983d6377999c2 (patch) | |
tree | 50b0d2da02b2d1c6e52a837765e373d4f9610cd7 /wifi/java/android | |
parent | f8e3ac851959efbd21da930a802f8efb65ccec5b (diff) | |
download | frameworks_base-1538dba4b00f767ddc4010e05b5983d6377999c2.zip frameworks_base-1538dba4b00f767ddc4010e05b5983d6377999c2.tar.gz frameworks_base-1538dba4b00f767ddc4010e05b5983d6377999c2.tar.bz2 |
Make FWK start a wifi scan if supplicant forgets. (do not merge)
Waits 15sec after getting a DISCONNECTED or INACTIVE state. Also tracks
the number of supplicant state transitions. After the period is up
if we haven't received any more supplicant state transitions, it requests a scan.
bug: 2168081
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 2c0d0f1..b7d3a6e 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -90,6 +90,7 @@ public class WifiStateTracker extends NetworkStateTracker { */ private static final int EVENT_DRIVER_STATE_CHANGED = 12; private static final int EVENT_PASSWORD_KEY_MAY_BE_INCORRECT = 13; + private static final int EVENT_MAYBE_START_SCAN_POST_DISCONNECT = 14; /** * Interval in milliseconds between polling for connection @@ -126,6 +127,14 @@ public class WifiStateTracker extends NetworkStateTracker { private static final int RECONNECT_DELAY_MSECS = 2000; /** + * When the supplicant disconnects from an AP it sometimes forgets + * to restart scanning. Wait this delay before asking it to start + * scanning (in case it forgot). 15 sec is the standard delay between + * scans. + */ + private static final int KICKSTART_SCANNING_DELAY_MSECS = 15000; + + /** * The maximum number of times we will retry a connection to an access point * for which we have failed in acquiring an IP address from DHCP. A value of * N means that we will make N+1 connection attempts in all. @@ -149,6 +158,14 @@ public class WifiStateTracker extends NetworkStateTracker { private int mNumSupplicantLoopIterations = 0; /** + * The current number of supplicant state changes. This is used to determine + * if we've received any new info since we found out it was DISCONNECTED or + * INACTIVE. If we haven't for X ms, we then request a scan - it should have + * done that automatically, but sometimes some firmware does not. + */ + private int mNumSupplicantStateChanges = 0; + + /** * True if we received an event that that a password-key may be incorrect. * If the next incoming supplicant state change event is DISCONNECT, * broadcast a message that we have a possible password error and disable @@ -831,7 +848,16 @@ public class WifiStateTracker extends NetworkStateTracker { } break; + case EVENT_MAYBE_START_SCAN_POST_DISCONNECT: + // Only do this if we haven't gotten a new supplicant status since the timer + // started + if (mNumSupplicantStateChanges == msg.arg1) { + WifiNative.scanCommand(false); // do a passive scan + } + break; + case EVENT_SUPPLICANT_STATE_CHANGED: + mNumSupplicantStateChanges++; SupplicantStateChangeResult supplicantStateResult = (SupplicantStateChangeResult) msg.obj; SupplicantState newState = supplicantStateResult.state; @@ -850,6 +876,17 @@ public class WifiStateTracker extends NetworkStateTracker { int networkId = supplicantStateResult.networkId; /* + * If we get disconnect or inactive we need to start our + * watchdog timer to start a scan + */ + if (newState == SupplicantState.DISCONNECTED || + newState == SupplicantState.INACTIVE) { + sendMessageDelayed(obtainMessage(EVENT_MAYBE_START_SCAN_POST_DISCONNECT, + mNumSupplicantStateChanges, 0), KICKSTART_SCANNING_DELAY_MSECS); + } + + + /* * Did we get to DISCONNECTED state due to an * authentication (password) failure? */ |