diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-02-05 14:47:27 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-02-10 15:22:58 -0800 |
commit | 102d05fa9135bef5c6b875f9a6485566b06ebd18 (patch) | |
tree | 990ee430142bdc479b532ee524027300aca8a39d /wifi | |
parent | aa82768b8c6b6e81bb048d2d72b6586eb66b5b5d (diff) | |
download | frameworks_base-102d05fa9135bef5c6b875f9a6485566b06ebd18.zip frameworks_base-102d05fa9135bef5c6b875f9a6485566b06ebd18.tar.gz frameworks_base-102d05fa9135bef5c6b875f9a6485566b06ebd18.tar.bz2 |
get DHCP IP on each connection
The IP state was not being refreshed when the supplicant transitions
from COMPLETED to ASSOCIATED to COMPLETED. This can lead to
a connected state with no real connection due to old IP settings.
The fix refreshes IP on each connection.
Bug: 2329261
Change-Id: I38cd56369ee2d8ab3e0f06f5c9f5712b9b2f35a0
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index cb615d2..afaed24 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -835,7 +835,7 @@ public class WifiStateTracker extends NetworkStateTracker { WifiNative.closeSupplicantConnection(); } if (died) { - resetInterface(false); + resetConnections(true); } // When supplicant dies, kill the DHCP thread if (mDhcpTarget != null) { @@ -1074,6 +1074,13 @@ public class WifiStateTracker extends NetworkStateTracker { DetailedState saveState = getNetworkInfo().getDetailedState(); handleDisconnectedState(DetailedState.DISCONNECTED); setDetailedStateInternal(saveState); + } else { + /** + * stop DHCP to ensure there is a new IP address + * even if the supplicant transitions without disconnect + * COMPLETED -> ASSOCIATED -> COMPLETED + */ + resetConnections(false); } configureInterface(); mLastBssid = result.BSSID; @@ -1279,12 +1286,11 @@ public class WifiStateTracker extends NetworkStateTracker { * {@code DISCONNECTED} or {@code FAILED}. */ private void handleDisconnectedState(DetailedState newState) { - if (LOCAL_LOGD) Log.d(TAG, "Deconfiguring interface and stopping DHCP"); if (mDisconnectPending) { cancelDisconnect(); } mDisconnectExpected = false; - resetInterface(true); + resetConnections(true); setDetailedState(newState); sendNetworkStateChangeBroadcast(mLastBssid); mWifiInfo.setBSSID(null); @@ -1294,10 +1300,11 @@ public class WifiStateTracker extends NetworkStateTracker { } /** - * Resets the Wi-Fi interface by clearing any state, resetting any sockets + * Resets the Wi-Fi Connections by clearing any state, resetting any sockets * using the interface, stopping DHCP, and disabling the interface. */ - public void resetInterface(boolean reenable) { + public void resetConnections(boolean disableInterface) { + if (LOCAL_LOGD) Log.d(TAG, "Reset connections and stopping DHCP"); mHaveIpAddress = false; mObtainingIpAddress = false; mWifiInfo.setIpAddress(0); @@ -1317,9 +1324,14 @@ public class WifiStateTracker extends NetworkStateTracker { Log.e(TAG, "Could not stop DHCP"); } - NetworkUtils.disableInterface(mInterfaceName); - // we no longer net to start the interface (driver does this for us) - // and it led to problems - removed. + /** + * Interface is re-enabled in the supplicant + * when moving out of ASSOCIATING state + */ + if(disableInterface) { + if (LOCAL_LOGD) Log.d(TAG, "Disabling interface"); + NetworkUtils.disableInterface(mInterfaceName); + } } /** @@ -1538,7 +1550,7 @@ public class WifiStateTracker extends NetworkStateTracker { public synchronized boolean restart() { if (mRunState == RUN_STATE_STOPPED) { mRunState = RUN_STATE_STARTING; - resetInterface(true); + resetConnections(true); return WifiNative.startDriverCommand(); } else if (mRunState == RUN_STATE_STOPPING) { mRunState = RUN_STATE_STARTING; @@ -1969,7 +1981,7 @@ public class WifiStateTracker extends NetworkStateTracker { oDns2 != mDhcpInfo.dns2)); if (changed) { - resetInterface(true); + resetConnections(true); configureInterface(); if (mUseStaticIp) { mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED); |