From 8788d11587d4d07e85fc91bba1747bc5c44b3839 Mon Sep 17 00:00:00 2001 From: Michael Plass Date: Fri, 9 Nov 2018 13:28:15 -0800 Subject: [WifiNetworkSelector] fix regression (NPE) Fix NPE introduced in I4817b8f2abc5a8d7a18c1db7f5baae4e307fb2cf Bug: 119275028 Test: Unit tests Change-Id: Ica0cc30c3212d7201cb3d460818597de759b7d56 --- .../android/server/wifi/WifiNetworkSelector.java | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index bd9ca7422..cd73b784d 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -129,9 +129,6 @@ public class WifiNetworkSelector { } private boolean isCurrentNetworkSufficient(WifiInfo wifiInfo, List scanDetails) { - WifiConfiguration network = - mWifiConfigManager.getConfiguredNetwork(wifiInfo.getNetworkId()); - // Currently connected? if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) { localLog("No current connected network."); @@ -157,12 +154,6 @@ public class WifiNetworkSelector { return false; } - // Open network is not qualified. - if (WifiConfigurationUtil.isConfigForOpenNetwork(network)) { - localLog("Current network is a open one."); - return false; - } - if (wifiInfo.is24GHz()) { // 2.4GHz networks is not qualified whenever 5GHz is available if (is5GHzNetworkAvailable(scanDetails)) { @@ -175,6 +166,20 @@ public class WifiNetworkSelector { return false; } + WifiConfiguration network = + mWifiConfigManager.getConfiguredNetwork(wifiInfo.getNetworkId()); + + if (network == null) { + localLog("Current network was removed."); + return false; + } + + // Open network is not qualified. + if (WifiConfigurationUtil.isConfigForOpenNetwork(network)) { + localLog("Current network is a open one."); + return false; + } + // Network with no internet access reports is not qualified. if (network.numNoInternetAccessReports > 0 && !network.noInternetAccessExpected) { localLog("Current network has [" + network.numNoInternetAccessReports -- cgit v1.2.3