From 653590862adc4555d583576fef81b82d4ece4949 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Thu, 6 Aug 2020 14:04:58 -0700 Subject: NullPointerException on authentication of SIM based EAP Handle EAP-SIM/AKA/AKAP authentication renew with right WifiCofniguration. Bug: 162940297 Test: atest com.android.server.wifi Change-Id: I95cc201644b4c9c276b77d3bbc361e553c005586 --- .../com/android/server/wifi/ClientModeImpl.java | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 3f6ef8601..0fc9cb355 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -5815,15 +5815,20 @@ public class ClientModeImpl extends StateMachine { } void handleGsmAuthRequest(SimAuthRequestData requestData) { + WifiConfiguration requestingWifiConfiguration = null; if (mTargetWifiConfiguration != null && mTargetWifiConfiguration.networkId == requestData.networkId) { + requestingWifiConfiguration = mTargetWifiConfiguration; logd("id matches targetWifiConfiguration"); } else if (mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID && mLastNetworkId == requestData.networkId) { + requestingWifiConfiguration = getCurrentWifiConfiguration(); logd("id matches currentWifiConfiguration"); - } else { - logd("id does not match targetWifiConfiguration"); + } + + if (requestingWifiConfiguration == null) { + logd("GsmAuthRequest received with null target/current WifiConfiguration."); return; } @@ -5840,15 +5845,15 @@ public class ClientModeImpl extends StateMachine { * [SRES][Cipher Key Kc] */ String response = mWifiCarrierInfoManager - .getGsmSimAuthResponse(requestData.data, mTargetWifiConfiguration); + .getGsmSimAuthResponse(requestData.data, requestingWifiConfiguration); if (response == null) { // In case of failure, issue may be due to sim type, retry as No.2 case response = mWifiCarrierInfoManager - .getGsmSimpleSimAuthResponse(requestData.data, mTargetWifiConfiguration); + .getGsmSimpleSimAuthResponse(requestData.data, requestingWifiConfiguration); if (response == null) { // In case of failure, issue may be due to sim type, retry as No.3 case response = mWifiCarrierInfoManager.getGsmSimpleSimNoLengthAuthResponse( - requestData.data, mTargetWifiConfiguration); + requestData.data, requestingWifiConfiguration); } } if (response == null || response.length() == 0) { @@ -5861,20 +5866,25 @@ public class ClientModeImpl extends StateMachine { } void handle3GAuthRequest(SimAuthRequestData requestData) { + WifiConfiguration requestingWifiConfiguration = null; if (mTargetWifiConfiguration != null && mTargetWifiConfiguration.networkId == requestData.networkId) { + requestingWifiConfiguration = mTargetWifiConfiguration; logd("id matches targetWifiConfiguration"); } else if (mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID && mLastNetworkId == requestData.networkId) { + requestingWifiConfiguration = getCurrentWifiConfiguration(); logd("id matches currentWifiConfiguration"); - } else { - logd("id does not match targetWifiConfiguration"); + } + + if (requestingWifiConfiguration == null) { + logd("3GAuthRequest received with null target/current WifiConfiguration."); return; } SimAuthResponseData response = mWifiCarrierInfoManager - .get3GAuthResponse(requestData, mTargetWifiConfiguration); + .get3GAuthResponse(requestData, requestingWifiConfiguration); if (response != null) { mWifiNative.simAuthResponse( mInterfaceName, response.type, response.response); -- cgit v1.2.3