1# Copyright (C) 2024 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""This Test is to test the Wifi SCC with the DFS channels case. 16 17This is about the feature - using DFS channels for WFD, for details, refer to 18https://docs.google.com/presentation/d/18Fl0fY4piq_sfXfo3rCr2Ca55AJHEOvB7rC-rV3SQ9E/edit?usp=sharing 19and config_wifiEnableStaDfsChannelForPeerNetwork - 20https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/Wifi/service/ServiceWifiResources/res/values/config.xml;l=1151 21In this case, the feature is enabled for the target device. 22 23The device requirements: 24 support 5G: true 25 using DFS channels for peer network: true 26The AP requirements: 27 wifi channel: 52 (5260) 28""" 29 30import logging 31import os 32import sys 33 34# Allows local imports to be resolved via relative path, so the test can be run 35# without building. 36_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 37if _betocq_dir not in sys.path: 38 sys.path.append(_betocq_dir) 39 40from mobly import base_test 41from mobly import test_runner 42 43from betocq import d2d_performance_test_base 44from betocq import nc_constants 45 46 47class SccDfs5gWfdStaTest(d2d_performance_test_base.D2dPerformanceTestBase): 48 """Test class for Wifi SCC with the DFS 5G channels case.""" 49 50 def _get_country_code(self) -> str: 51 return 'GB' 52 53 def setup_class(self): 54 super().setup_class() 55 self.performance_test_iterations = getattr( 56 self.test_scc_dfs_5g_wfd_sta, base_test.ATTR_REPEAT_CNT 57 ) 58 logging.info( 59 'performance test iterations: %s', self.performance_test_iterations 60 ) 61 62 @base_test.repeat( 63 count=nc_constants.SCC_PERFORMANCE_TEST_COUNT, 64 max_consecutive_error=nc_constants.SCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR, 65 ) 66 def test_scc_dfs_5g_wfd_sta(self): 67 """Test the performance for Wifi SCC with DFS 5G WFD and STA.""" 68 self._test_connection_medium_performance( 69 nc_constants.NearbyMedium.UPGRADE_TO_WIFIDIRECT, 70 wifi_ssid=self.test_parameters.wifi_dfs_5g_ssid, 71 wifi_password=self.test_parameters.wifi_dfs_5g_password, 72 ) 73 74 def _get_file_transfer_failure_tip(self) -> str: 75 return ( 76 'The Wifi Direct connection might be broken, check related logs, ' 77 f'{self._get_throughput_low_tip()}' 78 ) 79 80 def _get_throughput_low_tip(self) -> str: 81 return ( 82 f'{self._throughput_low_string}. This is 5G SCC DFS WFD test case.' 83 ' Check STA and WFD GO frequencies in the target logs (dumpsys wifip2p)' 84 ' and ensure they have the same value. In the configuration file,' 85 ' enable_sta_dfs_channel_for_peer_network is set to true on both' 86 ' source and target sides. Check if both device do support WFD group' 87 ' owner in the STA-associated DFS channel. Check if' 88 ' config_wifiEnableStaDfsChannelForPeerNetwork' 89 ' https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/Wifi/service/ServiceWifiResources/res/values/config.xml' 90 ' is set to true and has the correct driver/FW implementation.' 91 ) 92 93 def _is_wifi_ap_ready(self) -> bool: 94 return True if self.test_parameters.wifi_dfs_5g_ssid else False 95 96 @property 97 def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]: 98 return { 99 'discoverer': { 100 'supports_5g': True, 101 'enable_sta_dfs_channel_for_peer_network': True, 102 }, 103 'advertiser': { 104 'supports_5g': True, 105 'enable_sta_dfs_channel_for_peer_network': True, 106 }, 107 } 108 109 110if __name__ == '__main__': 111 test_runner.main() 112