diff options
author | xshu <xshu@google.com> | 2020-02-12 17:39:45 -0800 |
---|---|---|
committer | xshu <xshu@google.com> | 2020-02-13 16:41:50 -0800 |
commit | 3935d9d984bf4c7ea5be6b75f22773a0abd55e5b (patch) | |
tree | cefbe884c43d494e8105340f37e0a9a33718293d | |
parent | 0fbeb8b4e75689b173f910f1ddc8583f363ce8d1 (diff) |
BssidBlocklistMonitor success metrics
Log the histogram of number of times BSSIDs are fitered out from network
selection.
Bug: 149229812
Test: atest com.android.server.wifi
Change-Id: Ic0add48d890151d5ec535734a7b321e0daff3ef7
5 files changed, 62 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 6a28c3586..0f579710c 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -405,6 +405,7 @@ public class WifiMetrics { private static final int[] WIFI_LOCK_SESSION_DURATION_HISTOGRAM_BUCKETS = {1, 10, 60, 600, 3600}; private final WifiToggleStats mWifiToggleStats = new WifiToggleStats(); + private BssidBlocklistStats mBssidBlocklistStats = new BssidBlocklistStats(); private final IntHistogram mWifiLockHighPerfAcqDurationSecHistogram = new IntHistogram(WIFI_LOCK_SESSION_DURATION_HISTOGRAM_BUCKETS); @@ -512,6 +513,23 @@ public class WifiMetrics { } } + class BssidBlocklistStats { + public IntCounter networkSelectionFilteredBssidCount = new IntCounter(); + + public WifiMetricsProto.BssidBlocklistStats toProto() { + WifiMetricsProto.BssidBlocklistStats proto = new WifiMetricsProto.BssidBlocklistStats(); + proto.networkSelectionFilteredBssidCount = networkSelectionFilteredBssidCount.toProto(); + return proto; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("networkSelectionFilteredBssidCount=" + networkSelectionFilteredBssidCount); + return sb.toString(); + } + } + /** * Log event, tracking the start time, end time and result of a wireless connection attempt. */ @@ -2678,6 +2696,8 @@ public class WifiMetrics { pw.println("mWifiLogProto.observed80211mcSupportingApsInScanHistogram" + mObserved80211mcApInScanHistogram); + pw.println("mWifiLogProto.bssidBlocklistStats:"); + pw.println(mBssidBlocklistStats.toString()); pw.println("mSoftApTetheredEvents:"); for (SoftApConnectedClientsEvent event : mSoftApEventListTethered) { @@ -3397,6 +3417,7 @@ public class WifiMetrics { if (healthMonitorMetrics != null) { mWifiLogProto.healthMonitorMetrics = healthMonitorMetrics; } + mWifiLogProto.bssidBlocklistStats = mBssidBlocklistStats.toProto(); } } @@ -3591,6 +3612,7 @@ public class WifiMetrics { mWifiToggleStats.clear(); mPasspointProvisionFailureCounts.clear(); mNumProvisionSuccess = 0; + mBssidBlocklistStats = new BssidBlocklistStats(); } } @@ -5079,6 +5101,13 @@ public class WifiMetrics { } /** + * Add to the histogram of number of BSSIDs filtered out from network selection. + */ + public void incrementNetworkSelectionFilteredBssidCount(int numBssid) { + mBssidBlocklistStats.networkSelectionFilteredBssidCount.increment(numBssid); + } + + /** * Increment number of passpoint provision success */ public void incrementPasspointProvisionSuccess() { diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 2194dad2b..98e00e811 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -359,6 +359,7 @@ public class WifiNetworkSelector { StringBuffer lowRssi = new StringBuffer(); StringBuffer mboAssociationDisallowedBssid = new StringBuffer(); boolean scanResultsHaveCurrentBssid = false; + int numBssidFiltered = 0; for (ScanDetail scanDetail : scanDetails) { ScanResult scanResult = scanDetail.getScanResult(); @@ -377,6 +378,7 @@ public class WifiNetworkSelector { if (bssidBlacklist.contains(scanResult.BSSID)) { blacklistedBssid.append(scanId).append(" / "); + numBssidFiltered++; continue; } @@ -402,6 +404,7 @@ public class WifiNetworkSelector { validScanDetails.add(scanDetail); } + mWifiMetrics.incrementNetworkSelectionFilteredBssidCount(numBssidFiltered); // WNS listens to all single scan results. Some scan requests may not include // the channel of the currently connected network, so the currently connected diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 6870f6a5e..8989b3bfa 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -579,6 +579,9 @@ message WifiLog { // Metrics collected by health monitor optional HealthMonitorMetrics health_monitor_metrics = 158; + + // Metrics related to the BssidBlocklistMonitor + optional BssidBlocklistStats bssid_blocklist_stats = 159; } // Information that gets logged for every WiFi connection. @@ -1841,6 +1844,11 @@ message ExperimentValues { optional int32 data_stall_cca_level_thr = 9; } +message BssidBlocklistStats { + // Distributions of number of blocked BSSIDs filtered out from network selection. + repeated Int32Count network_selection_filtered_bssid_count = 1; +} + message WifiIsUnusableEvent { enum TriggerType { // Default/Invalid event diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index d83051d44..f624b4fab 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -1562,6 +1562,26 @@ public class WifiMetricsTest extends WifiBaseTest { } /** + * Test the logging of BssidBlocklistStats. + */ + @Test + public void testBssidBlocklistMetrics() throws Exception { + for (int i = 0; i < 3; i++) { + mWifiMetrics.incrementNetworkSelectionFilteredBssidCount(i); + } + mWifiMetrics.incrementNetworkSelectionFilteredBssidCount(2); + dumpProtoAndDeserialize(); + + Int32Count[] expectedHistogram = { + buildInt32Count(0, 1), + buildInt32Count(1, 1), + buildInt32Count(2, 2), + }; + assertKeyCountsEqual(expectedHistogram, + mDecodedProto.bssidBlocklistStats.networkSelectionFilteredBssidCount); + } + + /** * Test that WifiMetrics is being cleared after dumping via proto */ @Test diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index 18de28473..906b4b93b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -534,6 +534,7 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Do network selection. mWifiNetworkSelector.selectNetwork(scanDetails, blacklist, mWifiInfo, true, false, false); + verify(mWifiMetrics).incrementNetworkSelectionFilteredBssidCount(0); verify(mWifiConfigManager).getConfiguredNetworks(); verify(mWifiConfigManager, times(savedConfigs.length)).tryEnableNetwork(anyInt()); @@ -567,6 +568,7 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, blacklist, mWifiInfo, false, true, false); + verify(mWifiMetrics).incrementNetworkSelectionFilteredBssidCount(1); assertEquals("Expect null configuration", null, candidate); assertTrue(mWifiNetworkSelector.getConnectableScanDetails().isEmpty()); } |