diff options
author | Randy Pan <zpan@google.com> | 2017-05-03 23:07:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-03 23:07:24 +0000 |
commit | d6992944c7011c0a68b208dfd042fe61aa48e702 (patch) | |
tree | ffcd2f39d3470eb78b67a8704c38fc41d5751d42 | |
parent | 9d79780441b335d9f3e052de1483019c00467715 (diff) | |
parent | e212ec5833a5d4bb4b5cb68af4ae0a0626a32ad5 (diff) |
Merge "Wifi network selection logging improvement" into oc-dev am: bd6f2f3e73
am: e212ec5833
Change-Id: Ibbaf629372200e7af300ab4181525e323aad4865
-rw-r--r-- | service/java/com/android/server/wifi/SavedNetworkEvaluator.java | 40 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSelector.java | 14 |
2 files changed, 39 insertions, 15 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java index 7565f7819..5e75fbe8f 100644 --- a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java @@ -33,7 +33,7 @@ import java.util.List; * saved networks. */ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluator { - private static final String NAME = "WifiSavedNetworkEvaluator"; + private static final String NAME = "SavedNetworkEvaluator"; private final WifiConfigManager mWifiConfigManager; private final Clock mClock; private final LocalLog mLocalLog; @@ -96,7 +96,7 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat return; } - StringBuffer sbuf = new StringBuffer("Saved Networks List: \n"); + StringBuffer sbuf = new StringBuffer(); for (WifiConfiguration network : savedNetworks) { /** * Ignore Passpoint networks. Passpoint networks are also considered as "saved" @@ -120,20 +120,36 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat // Clear the cached candidate, score and seen. mWifiConfigManager.clearNetworkCandidateScanResult(network.networkId); - sbuf.append(" ").append(WifiNetworkSelector.toNetworkString(network)).append(" ") - .append(" User Preferred BSSID: ").append(network.BSSID) - .append(" FQDN: ").append(network.FQDN).append(" ") - .append(status.getNetworkStatusString()).append(" Disable account: "); - for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE; + boolean networkDisabled = false; + boolean networkStringLogged = false; + for (int index = WifiConfiguration.NetworkSelectionStatus + .NETWORK_SELECTION_DISABLED_STARTING_INDEX; index < WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_DISABLED_MAX; index++) { - sbuf.append(status.getDisableReasonCounter(index)).append(" "); + int count = status.getDisableReasonCounter(index); + if (count > 0) { + networkDisabled = true; + if (!networkStringLogged) { + sbuf.append(" ").append(WifiNetworkSelector.toNetworkString(network)) + .append(" "); + networkStringLogged = true; + } + sbuf.append("reason=") + .append(WifiConfiguration.NetworkSelectionStatus + .getNetworkDisableReasonString(index)) + .append(", count=").append(count).append("; "); + } + } + + if (networkDisabled) { + sbuf.append("\n"); } - sbuf.append("Connect Choice: ").append(status.getConnectChoice()) - .append(" set time: ").append(status.getConnectChoiceTimestamp()) - .append("\n"); } - localLog(sbuf.toString()); + + if (sbuf.length() > 0) { + localLog("Disabled saved networks:"); + localLog(sbuf.toString()); + } } /** diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 5b84537ae..ce04bd28e 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -385,6 +385,7 @@ public class WifiNetworkSelector { private WifiConfiguration overrideCandidateWithUserConnectChoice( @NonNull WifiConfiguration candidate) { WifiConfiguration tempConfig = candidate; + WifiConfiguration originalCandidate = candidate; ScanResult scanResultCandidate = candidate.getNetworkSelectionStatus().getCandidate(); while (tempConfig.getNetworkSelectionStatus().getConnectChoice() != null) { @@ -403,9 +404,12 @@ public class WifiNetworkSelector { break; } } - localLog("After user selection adjustment, the final candidate is:" - + WifiNetworkSelector.toNetworkString(candidate) + " : " - + scanResultCandidate.BSSID); + + if (candidate != originalCandidate) { + localLog("After user selection adjustment, the final candidate is:" + + WifiNetworkSelector.toNetworkString(candidate) + " : " + + scanResultCandidate.BSSID); + } return candidate; } @@ -461,10 +465,14 @@ public class WifiNetworkSelector { WifiConfiguration selectedNetwork = null; for (NetworkEvaluator registeredEvaluator : mEvaluators) { if (registeredEvaluator != null) { + localLog("About to run " + registeredEvaluator.getName() + " :"); selectedNetwork = registeredEvaluator.evaluateNetworks(filteredScanDetails, currentNetwork, currentBssid, connected, untrustedNetworkAllowed, mConnectableNetworks); if (selectedNetwork != null) { + localLog(registeredEvaluator.getName() + " selects " + + WifiNetworkSelector.toNetworkString(selectedNetwork) + " : " + + selectedNetwork.getNetworkSelectionStatus().getCandidate().BSSID); break; } } |