From e416f1b0ebc69d02147f72599fe41d5a045ca2d3 Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Thu, 7 Sep 2017 23:47:24 -0700 Subject: WifiStateMachine: check for null config after dhcp If a network config is removed while we are in the ObtainingIpState, we will attempt to get the configured network from WifiConfigManager but it will be null. As we move to the Connected state, this throws a NPE. Instead of moving along to the Connected state, disconnect from the network if we find out we have null for the current config. Also add an additional null check where the NPE was thrown further down the line. Bug: 65257934 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Ibbce6491970de16cf5265b03398b50a7cdd50ba2 --- service/java/com/android/server/wifi/WifiStateMachine.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 41a599451..87ceee893 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4821,7 +4821,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // Notify PasspointManager of Passpoint network connected event. WifiConfiguration currentNetwork = getCurrentWifiConfiguration(); - if (currentNetwork.isPasspoint()) { + if (currentNetwork != null && currentNetwork.isPasspoint()) { mPasspointManager.onPasspointNetworkConnected(currentNetwork.FQDN); } } @@ -5828,8 +5828,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss reportConnectionAttemptEnd( WifiMetrics.ConnectionEvent.FAILURE_NONE, WifiMetricsProto.ConnectionEvent.HLF_NONE); - sendConnectedState(); - transitionTo(mConnectedState); + if (getCurrentWifiConfiguration() == null) { + // The current config may have been removed while we were connecting, + // trigger a disconnect to clear up state. + mWifiNative.disconnect(); + transitionTo(mDisconnectingState); + } else { + sendConnectedState(); + transitionTo(mConnectedState); + } break; case CMD_IP_CONFIGURATION_LOST: // Get Link layer stats so that we get fresh tx packet counters. -- cgit v1.2.3