From a9fe56f7afda25ccaf77f90de8fc5a61f4afd9eb Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Wed, 11 Dec 2019 15:51:15 -0800 Subject: Wifi: enable ThroughputScorer by default to collect Tx/RxSpeed stats. Bug: 141770991 Test: unit test with atest com.android.server.wifi Test: manual test with AP and adb dumpsys wifi Change-Id: Iea54725b68d83e49db837d43b72a192b58ba4d38 --- .../android/server/wifi/WifiNetworkSelector.java | 2 +- .../server/wifi/WifiNetworkSelectorTest.java | 30 +++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index e794ef7bc..426a81424 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -93,7 +93,7 @@ public class WifiNetworkSelector { /** * The identifier string of the CandidateScorer to use (in the absence of overrides). */ - public static final String PRESET_CANDIDATE_SCORER_NAME = "CompatibilityScorer"; + public static final String PRESET_CANDIDATE_SCORER_NAME = "ThroughputScorer"; /** * Experiment ID for the legacy scorer. diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index ac49f1d25..7653e1a30 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -100,7 +100,12 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { mScoreCardBasedScorer = new ScoreCardBasedScorer(mScoringParams); mThroughputScorer = new ThroughputScorer(mScoringParams); when(mWifiNative.getClientInterfaceName()).thenReturn("wlan0"); - mWifiNetworkSelector.registerCandidateScorer(mCompatibilityScorer); + if (WifiNetworkSelector.PRESET_CANDIDATE_SCORER_NAME.equals( + mThroughputScorer.getIdentifier())) { + mWifiNetworkSelector.registerCandidateScorer(mThroughputScorer); + } else { + mWifiNetworkSelector.registerCandidateScorer(mCompatibilityScorer); + } } /** Cleans up test. */ @@ -1452,7 +1457,7 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { } /** - * Tests that metrics are recorded for 3 scorers (legacy, compat, and null scorer). + * Tests that metrics are recorded for 3 scorers. */ @Test public void testCandidateScorerMetrics_threeScorers() { @@ -1481,11 +1486,16 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { } /** - * Tests that metrics are recorded for legacy scorer and throughput scorer. + * Tests that metrics are recorded for two scorers. */ @Test - public void testCandidateScorerMetricsThrougputScorer() { - mWifiNetworkSelector.registerCandidateScorer(mThroughputScorer); + public void testCandidateScorerMetricsThroughputScorer() { + if (WifiNetworkSelector.PRESET_CANDIDATE_SCORER_NAME.equals( + mThroughputScorer.getIdentifier())) { + mWifiNetworkSelector.registerCandidateScorer(mCompatibilityScorer); + } else { + mWifiNetworkSelector.registerCandidateScorer(mThroughputScorer); + } // add a second NetworkEvaluator that returns the second network in the scan list mWifiNetworkSelector.registerNetworkNominator( @@ -1498,8 +1508,14 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Wanted 2 times since test2GhzHighQuality5GhzAvailable() calls // WifiNetworkSelector.selectNetwork() twice - verify(mWifiMetrics, times(2)).logNetworkSelectionDecision(throughputExpId, - compatibilityExpId, true, 2); + if (WifiNetworkSelector.PRESET_CANDIDATE_SCORER_NAME.equals( + mThroughputScorer.getIdentifier())) { + verify(mWifiMetrics, times(2)).logNetworkSelectionDecision( + compatibilityExpId, throughputExpId, true, 2); + } else { + verify(mWifiMetrics, times(2)).logNetworkSelectionDecision(throughputExpId, + compatibilityExpId, true, 2); + } } /** -- cgit v1.2.3