diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-12-11 22:33:31 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-12-12 16:47:02 -0800 |
commit | cdc077c9dd6473b5abfad4edfaf1ff41a436caaf (patch) | |
tree | 3c26e24c256e4df0166c7bd00d46eb5646ba5e64 /wifi/java | |
parent | c1761e7fe10390d90b805f373b51ecaabf214dac (diff) | |
download | frameworks_base-cdc077c9dd6473b5abfad4edfaf1ff41a436caaf.zip frameworks_base-cdc077c9dd6473b5abfad4edfaf1ff41a436caaf.tar.gz frameworks_base-cdc077c9dd6473b5abfad4edfaf1ff41a436caaf.tar.bz2 |
Fix configured network status
For a connected network, keep status as CURRENT. For a network,
that is disconnected it should be ENABLED. A disabled network
will have the status as DISABLED
Also, add a unit test to ensure there is only one CURRENT network
that is connected
Change-Id: Iaa4a7124a0c372a8f6df3d846ae8c15d9b29cf13
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 19 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 5 |
2 files changed, 23 insertions, 1 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index af48c7c..d345411 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -22,6 +22,7 @@ import android.net.DhcpInfoInternal; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NetworkUtils; +import android.net.NetworkInfo.DetailedState; import android.net.ProxyProperties; import android.net.RouteInfo; import android.net.wifi.WifiConfiguration.IpAssignment; @@ -276,6 +277,24 @@ class WifiConfigStore { return result; } + static void updateStatus(int netId, DetailedState state) { + if (netId != INVALID_NETWORK_ID) { + WifiConfiguration config = sConfiguredNetworks.get(netId); + if (config == null) return; + switch (state) { + case CONNECTED: + config.status = Status.CURRENT; + break; + case DISCONNECTED: + config.status = Status.ENABLED; + break; + default: + //do nothing, retain the existing state + break; + } + } + } + /** * Forget the specified network and save config * diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 21dad82..71d7c01 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1642,8 +1642,10 @@ public class WifiStateMachine extends StateMachine { mWifiInfo.setRssi(MIN_RSSI); mWifiInfo.setLinkSpeed(-1); - /* send event to CM & network change broadcast */ setNetworkDetailedState(DetailedState.DISCONNECTED); + WifiConfigStore.updateStatus(mLastNetworkId, DetailedState.DISCONNECTED); + + /* send event to CM & network change broadcast */ sendNetworkStateChangeBroadcast(mLastBssid); /* Clear network properties */ @@ -1726,6 +1728,7 @@ public class WifiStateMachine extends StateMachine { } else { configureLinkProperties(); setNetworkDetailedState(DetailedState.CONNECTED); + WifiConfigStore.updateStatus(mLastNetworkId, DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mLastBssid); } } |