diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-11-13 03:46:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-11-13 03:46:12 +0000 |
commit | 3e592dd784bb9ec027f8d60603358a1fa5dd98d9 (patch) | |
tree | 52408b09fd52d686583ed529bc42df1d2b0171d3 | |
parent | a684619cbc42603dbca0874f78d0f0953f5111fe (diff) | |
parent | 8788d11587d4d07e85fc91bba1747bc5c44b3839 (diff) |
Merge "[WifiNetworkSelector] fix regression (NPE)"
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSelector.java | 23 |
1 files 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<ScanDetail> 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 |