From c8623f0fe9ba447c890063bc74850a06b9022bf5 Mon Sep 17 00:00:00 2001 From: Mingguang Xu Date: Thu, 3 Sep 2020 15:50:12 -0700 Subject: Add metrics for Adaptive Connectivity toggle Add a new UserActionEvent to track the state change of Adaptive Connectivity and attach its state to StaEvent. Bug: 166644305 Test: atest com.android.server.wifi Updated-PDD: TRUE Signed-off-by: Mingguang Xu Change-Id: If33df01ec4292afae29eae61f129923ec82bd0ae Merged-In: I72762fc129c9f026ca9323b11e4e159ed2706cb7 --- .../com/android/server/wifi/WifiMetricsTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (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 b4cd7592c..b69b30208 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -2302,6 +2302,7 @@ public class WifiMetricsTest extends WifiBaseTest { mTestLooper.dispatchAll(); wifiMetrics.setScreenState(true); when(mWifiDataStall.isCellularDataAvailable()).thenReturn(true); + wifiMetrics.setAdaptiveConnectivityState(true); for (int i = 0; i < mTestStaLogInts.length; i++) { int[] lia = mTestStaLogInts[i]; wifiMetrics.logStaEvent(lia[0], lia[1], lia[2] == 1 ? mTestWifiConfig : null); @@ -2342,6 +2343,7 @@ public class WifiMetricsTest extends WifiBaseTest { evs[7] == 1 ? mTestWifiConfig : null, event.configInfo); assertEquals(true, event.screenOn); assertEquals(true, event.isCellularDataAvailable); + assertEquals(true, event.isAdaptiveConnectivityEnabled); j++; } assertEquals(mExpectedValues.length, j); @@ -2553,6 +2555,35 @@ public class WifiMetricsTest extends WifiBaseTest { assertNull(userActionEvents[0].targetNetworkInfo); } + /** + * Test the logging of UserActionEvent for Adaptive Connectivity toggle + */ + @Test + public void testLogUserActionEventForAdaptiveConnectivity() throws Exception { + long testStartTimeMillis = 123123L; + boolean adaptiveConnectivityEnabled = true; + when(mClock.getElapsedSinceBootMillis()).thenReturn(testStartTimeMillis); + mWifiMetrics.logUserActionEvent( + mWifiMetrics.convertAdaptiveConnectivityStateToUserActionEventType( + adaptiveConnectivityEnabled)); + long testStartTimeMillis2 = 200000L; + boolean adaptiveConnectivityEnabled2 = false; + when(mClock.getElapsedSinceBootMillis()).thenReturn(testStartTimeMillis2); + mWifiMetrics.logUserActionEvent( + mWifiMetrics.convertAdaptiveConnectivityStateToUserActionEventType( + adaptiveConnectivityEnabled2)); + dumpProtoAndDeserialize(); + + WifiMetricsProto.UserActionEvent[] userActionEvents = mDecodedProto.userActionEvents; + assertEquals(2, userActionEvents.length); + assertEquals(WifiMetricsProto.UserActionEvent.EVENT_CONFIGURE_ADAPTIVE_CONNECTIVITY_ON, + userActionEvents[0].eventType); + assertEquals(testStartTimeMillis, userActionEvents[0].startTimeMillis); + assertEquals(WifiMetricsProto.UserActionEvent.EVENT_CONFIGURE_ADAPTIVE_CONNECTIVITY_OFF, + userActionEvents[1].eventType); + assertEquals(testStartTimeMillis2, userActionEvents[1].startTimeMillis); + } + /** * Verify that the max length of the UserActionEvent list is limited to MAX_USER_ACTION_EVENTS. */ -- cgit v1.2.3