diff options
author | xshu <xshu@google.com> | 2018-07-23 14:01:29 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2018-07-23 17:21:56 -0700 |
commit | db017e2376136fb3828d696bbb882ecf5f2d174e (patch) | |
tree | 1959c916e2e0ba55c106ec46b0f70100130d0aca /tests | |
parent | 31b106d6610b9a61787a71dc51dba24b5f33e278 (diff) |
Metrics: count num scan requests with DFS channels
This will help monitor the usage of DFS channels from external requests.
DFS channels take significantly more power than non-DFS channels.
Also made it so that only valid scan requests are counted in the metrics.
This is better since only valid scan requests are serviced ultimately.
Bug: 72755722
Test: compile, unit tests
Manual testing:
flash
Toggle wifi on - off - on
adb shell dumpsys wifi
verify that a non zero integer is printed for mWifiLogProto.numOneshotHasDfsChannelScans
Change-Id: I2692f669509f41cf3dcf3236bc583c5a7ac6748f
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 6 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java | 71 |
2 files changed, 74 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 579dca606..1077eafc6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -311,6 +311,7 @@ public class WifiMetricsTest { private static final int DATA_STALL_MIN_TX_BAD_SETTING = 5; private static final int DATA_STALL_MIN_TX_SUCCESS_WITHOUT_RX_SETTING = 75; private static final int NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES = 5; + private static final int NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS = 4; /** Number of notifications per "Connect to Network" notification type. */ private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40}; @@ -706,6 +707,9 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES; i++) { mWifiMetrics.incrementNumSarSensorRegistrationFailures(); } + for (int i = 0; i < NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS; i++) { + mWifiMetrics.incrementOneshotScanWithDfsCount(); + } mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS); mWifiMetrics.setIsMacRandomizationOn(IS_MAC_RANDOMIZATION_ON); @@ -1015,6 +1019,8 @@ public class WifiMetricsTest { assertEquals(NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES, mDecodedProto.numSarSensorRegistrationFailures); + assertEquals(NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS, + mDecodedProto.numOneshotHasDfsChannelScans); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java index 58f2eb6a1..67b99f884 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -719,7 +719,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -771,7 +771,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -816,7 +816,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -922,6 +922,71 @@ public class WifiScanningServiceTest { } /** + * Do a single scan that includes DFS channels and verify that both oneshot scan count and + * oneshot scan count with dfs are incremented. + */ + @Test + public void testMetricsForOneshotScanWithDFSIsIncremented() throws Exception { + WifiScanner.ScanSettings requestSettings = createRequest( + WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 0, 0, 20, + WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); + int requestId = 33; + WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set + + startServiceAndLoadDriver(); + mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); + + Handler handler = mock(Handler.class); + BidirectionalAsyncChannel controlChannel = connectChannel(handler); + InOrder order = inOrder(handler, mWifiScannerImpl); + + // successful start + when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class), + any(WifiNative.ScanEventHandler.class))).thenReturn(true); + + sendSingleScanRequest(controlChannel, requestId, requestSettings, null); + + assertEquals(0, mWifiMetrics.getOneshotScanCount()); + assertEquals(0, mWifiMetrics.getOneshotScanWithDfsCount()); + // Scan is successfully queue + mLooper.dispatchAll(); + assertEquals(1, mWifiMetrics.getOneshotScanCount()); + assertEquals(1, mWifiMetrics.getOneshotScanWithDfsCount()); + } + + /** + * Do a single scan that excludes DFS channels and verify that only oneshot scan count is + * incremented. + */ + @Test + public void testMetricsForOneshotScanWithDFSIsNotIncremented() throws Exception { + WifiScanner.ScanSettings requestSettings = createRequest( + WifiScanner.WIFI_BAND_5_GHZ, 0, 0, 20, + WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); + int requestId = 33; + WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set + + startServiceAndLoadDriver(); + mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); + + Handler handler = mock(Handler.class); + BidirectionalAsyncChannel controlChannel = connectChannel(handler); + InOrder order = inOrder(handler, mWifiScannerImpl); + + // successful start + when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class), + any(WifiNative.ScanEventHandler.class))).thenReturn(true); + + sendSingleScanRequest(controlChannel, requestId, requestSettings, null); + + assertEquals(0, mWifiMetrics.getOneshotScanCount()); + // Scan is successfully queue + mLooper.dispatchAll(); + assertEquals(1, mWifiMetrics.getOneshotScanCount()); + assertEquals(0, mWifiMetrics.getOneshotScanWithDfsCount()); + } + + /** * Send a single scan request and then disable Wi-Fi before it completes */ @Test |