From 734ea2fae6332bfd82f0e2128dffd2876d64e3eb Mon Sep 17 00:00:00 2001 From: Michael Plass Date: Tue, 2 Apr 2019 16:09:43 -0700 Subject: WifiMetrics - record the active CandidateScorer id Bug: 128937950 Test: atest FrameworksWifiTests Test: adb shell dumpsys wifi | grep networkSelectorExperimentId Change-Id: Ided67c570c7dce72c64540b0fe1cb379fa8924f7 --- .../com/android/server/wifi/WifiMetricsTest.java | 30 ++++++++++++---------- .../server/wifi/WifiNetworkSelectorTest.java | 6 ++++- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 33da96690..5d94c1193 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -2159,13 +2159,12 @@ public class WifiMetricsTest { } /** - * Check ScoringParams + * Check network selector id */ @Test - public void testExperimentId() throws Exception { - final int id = 42; - final String expectId = "x" + id; - when(mScoringParams.getExperimentIdentifier()).thenReturn(id); + public void testNetworkSelectorExperimentId() throws Exception { + final int id = 42888888; + mWifiMetrics.setNetworkSelectorExperimentId(id); mWifiMetrics.startConnectionEvent(mTestWifiConfig, "TestNetwork", WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE); mWifiMetrics.endConnectionEvent( @@ -2173,10 +2172,21 @@ public class WifiMetricsTest { WifiMetricsProto.ConnectionEvent.HLF_NONE, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN); dumpProtoAndDeserialize(); - assertEquals(expectId, mDecodedProto.scoreExperimentId); assertEquals(id, mDecodedProto.connectionEvent[0].networkSelectorExperimentId); } + /** + * Check ScoringParams + */ + @Test + public void testExperimentId() throws Exception { + final int id = 42; + final String expectId = "x" + id; + when(mScoringParams.getExperimentIdentifier()).thenReturn(id); + dumpProtoAndDeserialize(); + assertEquals(expectId, mDecodedProto.scoreExperimentId); + } + /** * Check ScoringParams default case */ @@ -2185,16 +2195,8 @@ public class WifiMetricsTest { final int id = 0; final String expectId = ""; when(mScoringParams.getExperimentIdentifier()).thenReturn(id); - mWifiMetrics.startConnectionEvent(mTestWifiConfig, "TestNetwork", - WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE); - mWifiMetrics.endConnectionEvent( - WifiMetrics.ConnectionEvent.FAILURE_NONE, - WifiMetricsProto.ConnectionEvent.HLF_NONE, - WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN); dumpProtoAndDeserialize(); assertEquals(expectId, mDecodedProto.scoreExperimentId); - assertEquals(id, mDecodedProto.connectionEvent[0].networkSelectorExperimentId); - } /** short hand for instantiating an anonymous int array, instead of 'new int[]{a1, a2, ...}' */ diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index ec79e5749..cda5d626b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -783,6 +783,7 @@ public class WifiNetworkSelectorTest { WifiMetricsProto.ConnectionEvent.NOMINATOR_EXTERNAL_SCORED, WifiMetricsProto.ConnectionEvent.NOMINATOR_SAVED))); } + verify(mWifiMetrics, atLeastOnce()).setNetworkSelectorExperimentId(anyInt()); } /** @@ -1627,6 +1628,7 @@ public class WifiNetworkSelectorTest { verify(mWifiMetrics).logNetworkSelectionDecision( WifiNetworkSelector.LEGACY_CANDIDATE_SCORER_EXP_ID, nullScorerId, false, 2); verify(mWifiMetrics, atLeastOnce()).setNominatorForNetwork(anyInt(), anyInt()); + verify(mWifiMetrics, atLeastOnce()).setNetworkSelectorExperimentId(anyInt()); verifyNoMoreInteractions(mWifiMetrics); } @@ -1670,6 +1672,8 @@ public class WifiNetworkSelectorTest { verify(mWifiMetrics, times(2)).logNetworkSelectionDecision( WifiNetworkSelector.LEGACY_CANDIDATE_SCORER_EXP_ID, compatibilityExpId, true, 2); + + int expid = CompatibilityScorer.COMPATIBILITY_SCORER_DEFAULT_EXPID; + verify(mWifiMetrics, atLeastOnce()).setNetworkSelectorExperimentId(eq(expid)); } } - -- cgit v1.2.3