From e4e5a49dbe4ca726c51d9350fa61088c2bb23d8a Mon Sep 17 00:00:00 2001 From: Purushottam Kushwaha Date: Tue, 1 Sep 2020 11:19:37 +0530 Subject: NPE: Add null check for getConfiguredNetwork() During CMD_RESET_SIM_NETWORKS , WifiConfiguration get via getConfiguredNetwork() shall be guarded with null to avoid Null Pointer Exception. Bug: 167345712 Test: atest com.android.server.wifi (cherry-picked from 75f843c66829afc8920f3cf6302651f753985cba) (cherry picked from commit 36f987c05103b123e40f65a792d81e7c3a1710d3) Merged-In: I612817342a9c541d51c8c022f7c09b9462e39d21 Change-Id: I612817342a9c541d51c8c022f7c09b9462e39d21 --- service/java/com/android/server/wifi/ClientModeImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 95983096a..9f4c41f83 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -5013,11 +5013,12 @@ public class ClientModeImpl extends StateMachine { && mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID) { WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(mLastNetworkId); - if ((message.arg1 == RESET_SIM_REASON_DEFAULT_DATA_SIM_CHANGED + if (config != null + && ((message.arg1 == RESET_SIM_REASON_DEFAULT_DATA_SIM_CHANGED && config.carrierId != TelephonyManager.UNKNOWN_CARRIER_ID) || (config.enterpriseConfig != null && config.enterpriseConfig.isAuthenticationSimBased() - && !mWifiCarrierInfoManager.isSimPresent(mLastSubId))) { + && !mWifiCarrierInfoManager.isSimPresent(mLastSubId)))) { mWifiMetrics.logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT, StaEvent.DISCONNECT_RESET_SIM_NETWORKS); // remove local PMKSA cache in framework -- cgit v1.2.3