diff options
author | Roshan Pius <rpius@google.com> | 2016-11-16 22:52:17 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-11-16 22:52:17 +0000 |
commit | 35be00b7bc35096d299741d5e0276b7be1230af5 (patch) | |
tree | 76091eb14cb7b6e62000d0fb11b01cedb7a23b88 | |
parent | fb9899dfc18c0afb9648902d710da834e6d9dea9 (diff) | |
parent | af54bfce479e1dfb634cb939105b4800d3f1e2a7 (diff) |
WifiStateMachine: Ignore connection when the network Id is unknown
am: af54bfce47
Change-Id: Icd784fb2ecdfc05cf9bf77989decb865d60151e9
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 8a8e4c6c8..35ff744ec 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -5233,12 +5233,23 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss if (mVerboseLoggingEnabled) log("Network connection established"); mLastNetworkId = lookupFrameworkNetworkId(message.arg1); mLastBssid = (String) message.obj; - - mWifiInfo.setBSSID(mLastBssid); - mWifiInfo.setNetworkId(mLastNetworkId); - mWifiConnectivityManager.trackBssid(mLastBssid, true); - sendNetworkStateChangeBroadcast(mLastBssid); - transitionTo(mObtainingIpState); + // TODO: This check should not be needed after WifiStateMachinePrime refactor. + // Currently, the last connected network configuration is left in + // wpa_supplicant, this may result in wpa_supplicant initiating connection + // to it after a config store reload. Hence the old network Id lookups may not + // work, so disconnect the network and let network selector reselect a new + // network. + if (getCurrentWifiConfiguration() != null) { + mWifiInfo.setBSSID(mLastBssid); + mWifiInfo.setNetworkId(mLastNetworkId); + mWifiConnectivityManager.trackBssid(mLastBssid, true); + sendNetworkStateChangeBroadcast(mLastBssid); + transitionTo(mObtainingIpState); + } else { + logw("Connected to unknown networkId " + mLastNetworkId + + ", disconnecting..."); + sendMessage(CMD_DISCONNECT); + } break; case WifiMonitor.NETWORK_DISCONNECTION_EVENT: // Calling handleNetworkDisconnect here is redundant because we might already |