Integrate the latest changes

1) Add the support of BLE scan throttling during 2G transfer (enabled by default)
2) Remove the unnecessary flag overriding and rely on the production config instead.
3) Add BT coex test to betocq.
4) Change the success rate target to 98%.
5) Add the check of AP connection. If AP is disconnected or connect to a wrong frequency on the target side, mark the test as failed.
6) consolidate AP connection and speed check codes to one function.
7) Add P2P frequency check for WFD/HS SCC test cases.
8) Reduce 2G speed check from 3 to 2 MB/s until it is improved in NC.
9) Remove AP frequency check for the test cases with empty wifi_ssid.
10) Fix typo in DFS test cases and reduce BT transfer size by 50%.
11) Skip p2p frequency check if wifi speed check is disabled or it is a DBS test.
12) Copy the latest snippet apk which moves transfer time count after
    the file is created.

Bug:337326375
Test: manual test
Test: atest
Change-Id: I3708e7a19cd78efbfd63c4d46b4fdca88410934a
diff --git a/tests/bettertogether/betocq/CHANGELOG.md b/tests/bettertogether/betocq/CHANGELOG.md
index 632c69a..3113f52 100644
--- a/tests/bettertogether/betocq/CHANGELOG.md
+++ b/tests/bettertogether/betocq/CHANGELOG.md
@@ -1,5 +1,23 @@
 # BetoCQ test suite release history
 
+## 2.1
+
+## New
+* Add iperf test.
+
+### Bug fixes
+* Add the support of BLE scan throttling during 2G transfer (enabled by default)
+* Remove the unnecessary flag overriding and rely on the production config instead.
+* Add BT coex test to betocq.
+* Change the success rate target to 98%.
+* Add the check of AP connection. If AP is disconnected or connect to a wrong frequency on the target side, mark the test as failed.
+* consolidate AP connection and speed check codes to one function.
+* Add P2P frequency check for WFD/HS SCC test cases.
+* Reduce 2G speed check from 3 to 2 MB/s until it is improved in NC.
+* Remove AP frequency check for the test cases with empty wifi_ssid.
+* Fix typo in DFS test cases and reduce BT transfer size by 50%.
+* Skip p2p frequency check if wifi speed check is disabled or it is a DBS test.
+
 ## 2.0
 
 ### New
@@ -26,4 +44,4 @@
 ### New
 * `esim_transfer_stress_test.py` for testing eSIM transfer using Bluetooth only.
 * `quick_start_stress_test.py` for testing the Quickstart flow using both
-   Bluetooth and Wifi.
\ No newline at end of file
+   Bluetooth and Wifi.
diff --git a/tests/bettertogether/betocq/betocq_test_suite.py b/tests/bettertogether/betocq/betocq_test_suite.py
index 162fd47..6b10b20 100644
--- a/tests/bettertogether/betocq/betocq_test_suite.py
+++ b/tests/bettertogether/betocq/betocq_test_suite.py
@@ -33,6 +33,7 @@
 
 from betocq import base_betocq_suite
 from betocq import nc_constants
+from betocq.compound_tests import bt_2g_wifi_coex_test
 from betocq.compound_tests import mcc_5g_all_wifi_non_dbs_2g_sta_test
 from betocq.compound_tests import scc_2g_all_wifi_sta_test
 from betocq.compound_tests import scc_5g_all_wifi_dbs_2g_sta_test
@@ -77,6 +78,9 @@
           beto_cq_function_group_test.BetoCqFunctionGroupTest
       )
 
+    if test_parameters.run_bt_coex_test:
+      self.add_test_class(bt_2g_wifi_coex_test.Bt2gWifiCoexTest)
+
     # add bt and ble test
     if test_parameters.run_bt_performance_test:
       self.add_test_class(bt_performance_test.BtPerformanceTest)
diff --git a/tests/bettertogether/betocq/compound_tests/bt_2g_wifi_coex_test.py b/tests/bettertogether/betocq/compound_tests/bt_2g_wifi_coex_test.py
index af09c91..9f37456 100644
--- a/tests/bettertogether/betocq/compound_tests/bt_2g_wifi_coex_test.py
+++ b/tests/bettertogether/betocq/compound_tests/bt_2g_wifi_coex_test.py
@@ -79,7 +79,9 @@
         'The Wifi Direct connection might be broken, check related log.'
     )
 
-  def _get_throughout_benchmark(self) -> tuple[float, float]:
+  def _get_throughput_benchmark(
+      self, sta_frequency: int, sta_max_link_speed_mbps: int
+  ) -> tuple[float, float]:
     # no requirement for throughput.
     return (0.0, 0.0)
 
diff --git a/tests/bettertogether/betocq/compound_tests/mcc_5g_all_wifi_non_dbs_2g_sta_test.py b/tests/bettertogether/betocq/compound_tests/mcc_5g_all_wifi_non_dbs_2g_sta_test.py
index cf397c4..b80e1de 100644
--- a/tests/bettertogether/betocq/compound_tests/mcc_5g_all_wifi_non_dbs_2g_sta_test.py
+++ b/tests/bettertogether/betocq/compound_tests/mcc_5g_all_wifi_non_dbs_2g_sta_test.py
@@ -74,10 +74,10 @@
 
   def _get_file_transfer_failure_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
 
     return (
@@ -87,10 +87,10 @@
 
   def _get_throughput_low_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'{self._throughput_low_string}. The upgraded medium is'
diff --git a/tests/bettertogether/betocq/compound_tests/scc_2g_all_wifi_sta_test.py b/tests/bettertogether/betocq/compound_tests/scc_2g_all_wifi_sta_test.py
index 4e8c118..1c7ef42 100644
--- a/tests/bettertogether/betocq/compound_tests/scc_2g_all_wifi_sta_test.py
+++ b/tests/bettertogether/betocq/compound_tests/scc_2g_all_wifi_sta_test.py
@@ -79,10 +79,10 @@
 
   def _get_file_transfer_failure_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'The upgraded wifi medium {upgraded_medium_name} might be broken, '
@@ -91,10 +91,10 @@
 
   def _get_throughput_low_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'{self._throughput_low_string}. The upgraded medium is'
diff --git a/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_dbs_2g_sta_test.py b/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_dbs_2g_sta_test.py
index dad5b4b..52d2346 100644
--- a/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_dbs_2g_sta_test.py
+++ b/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_dbs_2g_sta_test.py
@@ -74,10 +74,10 @@
 
   def _get_file_transfer_failure_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'The upgraded wifi medium {upgraded_medium_name} might be broken, '
@@ -86,10 +86,10 @@
 
   def _get_throughput_low_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'{self._throughput_low_string}. The upgraded medium is'
diff --git a/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_sta_test.py b/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_sta_test.py
index 784c019..7c0289d 100644
--- a/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_sta_test.py
+++ b/tests/bettertogether/betocq/compound_tests/scc_5g_all_wifi_sta_test.py
@@ -71,10 +71,10 @@
 
   def _get_file_transfer_failure_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'The upgraded wifi medium {upgraded_medium_name} might be broken, '
@@ -83,10 +83,10 @@
 
   def _get_throughput_low_tip(self) -> str:
     upgraded_medium_name = None
-    if (self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+    if (self._current_test_result.quality_info.upgrade_medium
         is not None):
       upgraded_medium_name = (
-          self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium.name
+          self._current_test_result.quality_info.upgrade_medium.name
       )
     return (
         f'{self._throughput_low_string}. The upgraded medium is'
diff --git a/tests/bettertogether/betocq/cuj_and_test_config.yml b/tests/bettertogether/betocq/cuj_and_test_config.yml
index 4ddd4fd..bf724d2 100644
--- a/tests/bettertogether/betocq/cuj_and_test_config.yml
+++ b/tests/bettertogether/betocq/cuj_and_test_config.yml
@@ -14,6 +14,7 @@
   run_bt_performance_test: True
   run_directed_test: True
   run_compound_test: True
+  run_bt_coex_test: True
   run_iperf_test: True
   allow_unrooted_device: False
   skip_bug_report: False
diff --git a/tests/bettertogether/betocq/d2d_performance_test_base.py b/tests/bettertogether/betocq/d2d_performance_test_base.py
index bd814d2..6d5f92b 100644
--- a/tests/bettertogether/betocq/d2d_performance_test_base.py
+++ b/tests/bettertogether/betocq/d2d_performance_test_base.py
@@ -31,9 +31,10 @@
 
 
 _DELAY_BETWEEN_EACH_TEST_CYCLE = datetime.timedelta(seconds=5)
-_INVALID_FREQ = -1
-_INVALID_LINK_SPEED = -1
 _BITS_PER_BYTE = 8
+_MAX_FREQ_2G_MHZ = 2500
+_MIN_FREQ_5G_DFS_MHZ = 5260
+_MAX_FREQ_5G_DFS_MHZ = 5720
 
 
 class D2dPerformanceTestBase(nc_base_test.NCBaseTestClass, abc.ABC):
@@ -117,23 +118,27 @@
           )
     return None
 
-  def _get_throughout_benchmark(self) -> tuple[float, float]:
-    """Gets the throughout benchmark as KBps."""
-    max_num_streams = min(
-        self.discoverer.max_num_streams, self.advertiser.max_num_streams
-    )
-
+  def _get_target_sta_frequency_and_max_link_speed(self) -> tuple[int, int]:
+    """Gets the STA frequency and max link speed."""
+    connection_info = self.advertiser.nearby.wifiGetConnectionInfo()
     sta_frequency = int(
-        self.advertiser.nearby.wifiGetConnectionInfo().get(
-            'mFrequency', _INVALID_FREQ
-        )
+        connection_info.get('mFrequency', nc_constants.INVALID_INT)
     )
 
     sta_max_link_speed_mbps = int(
-        self.advertiser.nearby.wifiGetConnectionInfo().get(
-            'mMaxSupportedTxLinkSpeed', _INVALID_LINK_SPEED
+        connection_info.get(
+            'mMaxSupportedTxLinkSpeed', nc_constants.INVALID_INT
         )
     )
+    return (sta_frequency, sta_max_link_speed_mbps)
+
+  def _get_throughput_benchmark(
+      self, sta_frequency: int, sta_max_link_speed_mbps: int
+  ) -> tuple[float, float]:
+    """Gets the throughput benchmark as KBps."""
+    max_num_streams = min(
+        self.discoverer.max_num_streams, self.advertiser.max_num_streams
+    )
 
     if self._is_2g_d2d_wifi_medium:
       max_phy_rate_mbps = min(
@@ -267,7 +272,7 @@
         )
       finally:
         self._prior_bt_nc_fail_reason = prior_bt_snippet.test_failure_reason
-        self._current_test_result.prior_nc_setup_quality_info = (
+        self._current_test_result.prior_nc_quality_info = (
             prior_bt_snippet.connection_quality_info
         )
 
@@ -320,7 +325,7 @@
       )
     finally:
       self._active_nc_fail_reason = active_snippet.test_failure_reason
-      self._current_test_result.file_transfer_nc_setup_quality_info = (
+      self._current_test_result.quality_info = (
           active_snippet.connection_quality_info
       )
 
@@ -335,47 +340,17 @@
       )
       if (
           self.test_parameters.run_iperf_test
-          and self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+          and self._current_test_result.quality_info.upgrade_medium
           == nc_constants.NearbyConnectionMedium.WIFI_DIRECT
       ):
+        # TODO: b/338094399 - update this part for the connection over WFD.
         self._current_test_result.iperf_throughput_kbps = (
             iperf_utils.run_iperf_test(self.discoverer, self.advertiser)
         )
 
     finally:
       self._active_nc_fail_reason = active_snippet.test_failure_reason
-
-      if (
-          self._active_nc_fail_reason
-          is nc_constants.SingleTestFailureReason.SUCCESS
-      ):
-        iperf_speed_mbps = int(
-            self._current_test_result.iperf_throughput_kbps / 1024
-        )
-        nc_speed_mbps = round(
-            self._current_test_result.file_transfer_throughput_kbps / 1024, 1
-        )
-        iperf_speed_min_mbps, nc_speed_min_mbps = (
-            self._get_throughout_benchmark()
-        )
-        if (nc_speed_mbps < nc_speed_min_mbps) or (
-            iperf_speed_mbps > 0 and iperf_speed_mbps < iperf_speed_min_mbps
-        ):
-          self._active_nc_fail_reason = (
-              nc_constants.SingleTestFailureReason.FILE_TRANSFER_THROUGHPUT_LOW
-          )
-          result_str = ''
-          if iperf_speed_mbps > 0 and iperf_speed_mbps < iperf_speed_min_mbps:
-            result_str = result_str + (
-                f'iperf speed {iperf_speed_mbps} < target'
-                f' {iperf_speed_min_mbps}'
-            )
-          if nc_speed_mbps < nc_speed_min_mbps:
-            result_str = result_str + (
-                f' file speed {nc_speed_mbps} < target {nc_speed_min_mbps}'
-            )
-          self._throughput_low_string = result_str + ' MB/s'
-          asserts.fail(self._throughput_low_string)
+      self._check_ap_connection_and_speed(wifi_ssid)
 
     # 6. disconnect prior BT connection if required
     if prior_bt_snippet:
@@ -383,6 +358,98 @@
     # 7. disconnect D2D active connection
     active_snippet.disconnect_endpoint()
 
+  def _check_ap_connection_and_speed(self, wifi_ssid: str) -> None:
+    (sta_frequency, max_link_speed_mbps) = (
+        self._get_target_sta_frequency_and_max_link_speed()
+    )
+    if wifi_ssid and(
+        sta_frequency == nc_constants.INVALID_INT
+        or max_link_speed_mbps == nc_constants.INVALID_INT
+    ):
+      self._active_nc_fail_reason = (
+          nc_constants.SingleTestFailureReason.DISCONNECTED_FROM_AP
+      )
+      asserts.fail(
+          'Target device is disconnected from AP. Check AP DHCP config.'
+      )
+
+    iperf_speed_min_mbps, nc_speed_min_mbps = self._get_throughput_benchmark(
+        sta_frequency, max_link_speed_mbps
+    )
+
+    if wifi_ssid and not self._is_valid_sta_frequency(wifi_ssid, sta_frequency):
+      self._active_nc_fail_reason = (
+          nc_constants.SingleTestFailureReason.WRONG_AP_FREQUENCY
+      )
+      asserts.fail(f'AP is set to a wrong frequency {sta_frequency}')
+
+    if (
+        self._current_test_result.quality_info.upgrade_medium
+        in [
+            nc_constants.NearbyConnectionMedium.WIFI_DIRECT,
+            nc_constants.NearbyConnectionMedium.WIFI_HOTSPOT,
+        ]
+    ):
+      p2p_frequency = setup_utils.get_wifi_p2p_frequency(self.advertiser)
+      if all([
+          p2p_frequency != nc_constants.INVALID_INT,
+          p2p_frequency != sta_frequency,
+          not self._is_mcc,
+          not self._is_dbs_mode,
+          nc_speed_min_mbps > 0,
+      ]):
+        self._active_nc_fail_reason = (
+            nc_constants.SingleTestFailureReason.WRONG_P2P_FREQUENCY
+        )
+        asserts.fail(
+            f'P2P frequeny ({p2p_frequency}) is different from STA frequency'
+            f' ({sta_frequency}) in SCC test case. Check the device capability'
+            ' configuration especially for DBS, DFS, indoor capabilities.'
+        )
+
+    if (
+        self._active_nc_fail_reason
+        is nc_constants.SingleTestFailureReason.SUCCESS
+    ):
+      iperf_speed_mbps = int(
+          self._current_test_result.iperf_throughput_kbps / 1024
+      )
+      nc_speed_mbps = round(
+          self._current_test_result.file_transfer_throughput_kbps / 1024, 2
+      )
+
+      if (nc_speed_mbps < nc_speed_min_mbps) or (
+          iperf_speed_mbps > 0 and iperf_speed_mbps < iperf_speed_min_mbps
+      ):
+        self._active_nc_fail_reason = (
+            nc_constants.SingleTestFailureReason.FILE_TRANSFER_THROUGHPUT_LOW
+        )
+        result_str = ''
+        if iperf_speed_mbps > 0 and iperf_speed_mbps < iperf_speed_min_mbps:
+          result_str = result_str + (
+              f'iperf speed {iperf_speed_mbps} < target {iperf_speed_min_mbps}'
+          )
+        if nc_speed_mbps < nc_speed_min_mbps:
+          result_str = result_str + (
+              f' file speed {nc_speed_mbps} < target {nc_speed_min_mbps}'
+          )
+        self._throughput_low_string = result_str + ' MB/s'
+        asserts.fail(self._throughput_low_string)
+
+  def _is_valid_sta_frequency(self, wifi_ssid: str, sta_frequency: int) -> bool:
+    if wifi_ssid == self.test_parameters.wifi_2g_ssid:
+      return sta_frequency <= _MAX_FREQ_2G_MHZ
+    elif wifi_ssid == self.test_parameters.wifi_5g_ssid:
+      return sta_frequency > _MAX_FREQ_2G_MHZ and (
+          sta_frequency < _MIN_FREQ_5G_DFS_MHZ
+          or sta_frequency > _MAX_FREQ_5G_DFS_MHZ
+      )
+    else:  # 5G DFS band
+      return (
+          sta_frequency >= _MIN_FREQ_5G_DFS_MHZ
+          and sta_frequency <= _MAX_FREQ_5G_DFS_MHZ
+      )
+
   def _get_transfer_file_size(self) -> int:
     return nc_constants.TRANSFER_FILE_SIZE_500MB
 
@@ -410,11 +477,11 @@
     if self._use_prior_bt:
       quality_info.append(
           'prior_bt:'
-          f'{self._current_test_result.prior_nc_setup_quality_info.get_dict()}'
+          f'{self._current_test_result.prior_nc_quality_info.get_dict()}'
       )
     quality_info.append(
         'file_transfer:'
-        f'{self._current_test_result.file_transfer_nc_setup_quality_info.get_dict()}'
+        f'{self._current_test_result.quality_info.get_dict()}'
     )
     quality_info.append(
         'speed: '
@@ -525,20 +592,20 @@
     """Collects test result metrics for each iteration."""
     if self._use_prior_bt:
       self._performance_test_metrics.prior_bt_discovery_latencies.append(
-          self._current_test_result.prior_nc_setup_quality_info.discovery_latency
+          self._current_test_result.prior_nc_quality_info.discovery_latency
       )
       self._performance_test_metrics.prior_bt_connection_latencies.append(
-          self._current_test_result.prior_nc_setup_quality_info.connection_latency
+          self._current_test_result.prior_nc_quality_info.connection_latency
       )
 
     self._performance_test_metrics.file_transfer_discovery_latencies.append(
-        self._current_test_result.file_transfer_nc_setup_quality_info.discovery_latency
+        self._current_test_result.quality_info.discovery_latency
     )
     self._performance_test_metrics.file_transfer_connection_latencies.append(
-        self._current_test_result.file_transfer_nc_setup_quality_info.connection_latency
+        self._current_test_result.quality_info.connection_latency
     )
     self._performance_test_metrics.upgraded_wifi_transfer_mediums.append(
-        self._current_test_result.file_transfer_nc_setup_quality_info.upgrade_medium
+        self._current_test_result.quality_info.upgrade_medium
     )
     self._performance_test_metrics.file_transfer_throughputs_kbps.append(
         self._current_test_result.file_transfer_throughput_kbps
@@ -553,10 +620,10 @@
         self._current_test_result.advertiser_sta_latency
     )
     if (
-        self._current_test_result.file_transfer_nc_setup_quality_info.medium_upgrade_expected
+        self._current_test_result.quality_info.medium_upgrade_expected
     ):
       self._performance_test_metrics.medium_upgrade_latencies.append(
-          self._current_test_result.file_transfer_nc_setup_quality_info.medium_upgrade_latency
+          self._current_test_result.quality_info.medium_upgrade_latency
       )
 
   def __convert_kbps_to_mbps(self, throughput_kbps: float) -> float:
@@ -622,12 +689,17 @@
         == nc_constants.SingleTestFailureReason.SUCCESS
         for test_result in self._test_results
     )
-    # round down the passing test iterations
-    passed = success_count >= int(
+    passed = success_count >= round(
         self.performance_test_iterations * nc_constants.SUCCESS_RATE_TARGET
     )
     final_result_message = (
-        'PASS' if passed else f'FAIL: low successes - {success_count}'
+        'PASS'
+        if passed
+        else (
+            'FAIL: low successe rate: '
+            f' {success_count / self.performance_test_iterations:.2%} is lower'
+            f' than the target {nc_constants.SUCCESS_RATE_TARGET:.2%}'
+        )
     )
     detailed_stats = [
         f'Required Iterations: {self.performance_test_iterations}',
@@ -794,4 +866,3 @@
         f'Android Version: {ad.android_version}',
         f'GMS_version: {setup_utils.dump_gms_version(ad)}',
     ]
-
diff --git a/tests/bettertogether/betocq/directed_tests/ble_performance_test.py b/tests/bettertogether/betocq/directed_tests/ble_performance_test.py
index da81bcc..bc3aa78 100644
--- a/tests/bettertogether/betocq/directed_tests/ble_performance_test.py
+++ b/tests/bettertogether/betocq/directed_tests/ble_performance_test.py
@@ -60,12 +60,14 @@
     )
 
   def _get_transfer_file_size(self) -> int:
-    return nc_constants.TRANSFER_FILE_SIZE_1MB
+    return nc_constants.TRANSFER_FILE_SIZE_500KB
 
   def _get_file_transfer_timeout(self) -> datetime.timedelta:
-    return nc_constants.BLE_1M_PAYLOAD_TRANSFER_TIMEOUT
+    return nc_constants.BLE_500K_PAYLOAD_TRANSFER_TIMEOUT
 
-  def _get_throughout_benchmark(self) -> tuple[float, float]:
+  def _get_throughput_benchmark(
+      self, sta_frequency: int, sta_max_link_speed_mbps: int
+  ) -> tuple[float, float]:
     return (
         nc_constants.BLE_MEDIUM_THROUGHPUT_BENCHMARK_MBPS,
         nc_constants.BLE_MEDIUM_THROUGHPUT_BENCHMARK_MBPS,
diff --git a/tests/bettertogether/betocq/directed_tests/bt_performance_test.py b/tests/bettertogether/betocq/directed_tests/bt_performance_test.py
index 3537436..83293d3 100644
--- a/tests/bettertogether/betocq/directed_tests/bt_performance_test.py
+++ b/tests/bettertogether/betocq/directed_tests/bt_performance_test.py
@@ -59,12 +59,14 @@
     )
 
   def _get_transfer_file_size(self) -> int:
-    return nc_constants.TRANSFER_FILE_SIZE_1MB
+    return nc_constants.TRANSFER_FILE_SIZE_500KB
 
   def _get_file_transfer_timeout(self) -> datetime.timedelta:
-    return nc_constants.BT_1M_PAYLOAD_TRANSFER_TIMEOUT
+    return nc_constants.BT_500K_PAYLOAD_TRANSFER_TIMEOUT
 
-  def _get_throughout_benchmark(self) -> tuple[float, float]:
+  def _get_throughput_benchmark(
+      self, sta_frequency: int, sta_max_link_speed_mbps: int
+  ) -> tuple[float, float]:
     return (
         nc_constants.CLASSIC_BT_MEDIUM_THROUGHPUT_BENCHMARK_MBPS,
         nc_constants.CLASSIC_BT_MEDIUM_THROUGHPUT_BENCHMARK_MBPS,
@@ -76,7 +78,7 @@
   def _get_file_transfer_failure_tip(self) -> str:
     return (
         'The classic Bluetooth connection might be broken, check related log, '
-        f' {self._get_throughput_low_tip()}'
+        f'{self._get_throughput_low_tip()}'
     )
 
   def _get_throughput_low_tip(self) -> str:
diff --git a/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_hotspot_sta_test.py b/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_hotspot_sta_test.py
index ec4c54b..7ef40cc 100644
--- a/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_hotspot_sta_test.py
+++ b/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_hotspot_sta_test.py
@@ -91,7 +91,7 @@
     )
 
   def _is_wifi_ap_ready(self) -> bool:
-    return True if self.test_parameters.wifi_5g_ssid else False
+    return True if self.test_parameters.wifi_dfs_5g_ssid else False
 
   @property
   def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]:
@@ -106,6 +106,5 @@
     }
 
 
-
 if __name__ == '__main__':
   test_runner.main()
diff --git a/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_wfd_sta_test.py b/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_wfd_sta_test.py
index 3998e5d..760abdc 100644
--- a/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_wfd_sta_test.py
+++ b/tests/bettertogether/betocq/directed_tests/scc_dfs_5g_wfd_sta_test.py
@@ -91,7 +91,7 @@
     )
 
   def _is_wifi_ap_ready(self) -> bool:
-    return True if self.test_parameters.wifi_5g_ssid else False
+    return True if self.test_parameters.wifi_dfs_5g_ssid else False
 
   @property
   def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]:
diff --git a/tests/bettertogether/betocq/function_tests/bt_ble_function_test_actor.py b/tests/bettertogether/betocq/function_tests/bt_ble_function_test_actor.py
index 92b89e2..3af658d 100644
--- a/tests/bettertogether/betocq/function_tests/bt_ble_function_test_actor.py
+++ b/tests/bettertogether/betocq/function_tests/bt_ble_function_test_actor.py
@@ -51,7 +51,7 @@
           medium_upgrade_type=nc_constants.MediumUpgradeType.NON_DISRUPTIVE)
     finally:
       self._test_failure_reason = nearby_snippet.test_failure_reason
-      self._test_result.file_transfer_nc_setup_quality_info = (
+      self._test_result.quality_info = (
           nearby_snippet.connection_quality_info
       )
 
diff --git a/tests/bettertogether/betocq/function_tests/bt_multiplex_function_test_actor.py b/tests/bettertogether/betocq/function_tests/bt_multiplex_function_test_actor.py
index 2f59804..f72c54f 100644
--- a/tests/bettertogether/betocq/function_tests/bt_multiplex_function_test_actor.py
+++ b/tests/bettertogether/betocq/function_tests/bt_multiplex_function_test_actor.py
@@ -68,7 +68,7 @@
           medium_upgrade_type=nc_constants.MediumUpgradeType.NON_DISRUPTIVE)
     finally:
       self._test_failure_reason = nearby_snippet_2.test_failure_reason
-      self._test_result.prior_nc_setup_quality_info = (
+      self._test_result.quality_info = (
           nearby_snippet_2.connection_quality_info
       )
     # 2nd bt connection
@@ -92,7 +92,7 @@
           medium_upgrade_type=nc_constants.MediumUpgradeType.NON_DISRUPTIVE)
     finally:
       self._test_failure_reason = nearby_snippet.test_failure_reason
-      self._test_result.file_transfer_nc_setup_quality_info = (
+      self._test_result.prior_nc_quality_info = (
           nearby_snippet.connection_quality_info
       )
 
diff --git a/tests/bettertogether/betocq/function_tests/fixed_wifi_medium_function_test_actor.py b/tests/bettertogether/betocq/function_tests/fixed_wifi_medium_function_test_actor.py
index d44e04e..1316afe 100644
--- a/tests/bettertogether/betocq/function_tests/fixed_wifi_medium_function_test_actor.py
+++ b/tests/bettertogether/betocq/function_tests/fixed_wifi_medium_function_test_actor.py
@@ -57,7 +57,7 @@
           medium_upgrade_type=nc_constants.MediumUpgradeType.NON_DISRUPTIVE)
     finally:
       self._test_failure_reason = nearby_snippet.test_failure_reason
-      self._test_result.file_transfer_nc_setup_quality_info = (
+      self._test_result.quality_info = (
           nearby_snippet.connection_quality_info
       )
 
diff --git a/tests/bettertogether/betocq/nc_base_test.py b/tests/bettertogether/betocq/nc_base_test.py
index aca14cf..0f814a1 100644
--- a/tests/bettertogether/betocq/nc_base_test.py
+++ b/tests/bettertogether/betocq/nc_base_test.py
@@ -226,7 +226,6 @@
       setup_utils.grant_manage_external_storage_permission(
           ad, NEARBY_SNIPPET_2_PACKAGE_NAME
       )
-      setup_utils.enable_bluetooth_multiplex(ad)
       ad.load_snippet('nearby2', NEARBY_SNIPPET_2_PACKAGE_NAME)
       self.__loaded_2_nearby_snippets = True
     if not ad.nearby.wifiIsEnabled():
@@ -235,7 +234,10 @@
     setup_utils.enable_logs(ad)
     setup_utils.disable_redaction(ad)
     setup_utils.enable_wifi_aware(ad)
-    setup_utils.enable_dfs_scc(ad)
+
+    setup_utils.enable_ble_scan_throttling_during_2g_transfer(
+        ad, self.test_parameters.enable_2g_ble_scan_throttling
+    )
 
     setup_utils.set_country_code(ad, self._get_country_code())
 
diff --git a/tests/bettertogether/betocq/nc_constants.py b/tests/bettertogether/betocq/nc_constants.py
index 46f5ab1..7314148 100644
--- a/tests/bettertogether/betocq/nc_constants.py
+++ b/tests/bettertogether/betocq/nc_constants.py
@@ -21,7 +21,7 @@
 import logging
 from typing import Any
 
-SUCCESS_RATE_TARGET = 0.95  # 95%
+SUCCESS_RATE_TARGET = 0.98
 MCC_PERFORMANCE_TEST_COUNT = 100
 MCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR = 5
 SCC_PERFORMANCE_TEST_COUNT = 10
@@ -36,8 +36,8 @@
 FIRST_CONNECTION_INIT_TIMEOUT = datetime.timedelta(seconds=30)
 FIRST_CONNECTION_RESULT_TIMEOUT = datetime.timedelta(seconds=35)
 BT_1K_PAYLOAD_TRANSFER_TIMEOUT = datetime.timedelta(seconds=20)
-BT_1M_PAYLOAD_TRANSFER_TIMEOUT = datetime.timedelta(seconds=50)
-BLE_1M_PAYLOAD_TRANSFER_TIMEOUT = datetime.timedelta(seconds=50)
+BT_500K_PAYLOAD_TRANSFER_TIMEOUT = datetime.timedelta(seconds=25)
+BLE_500K_PAYLOAD_TRANSFER_TIMEOUT = datetime.timedelta(seconds=25)
 SECOND_DISCOVERY_TIMEOUT = datetime.timedelta(seconds=35)
 SECOND_CONNECTION_INIT_TIMEOUT = datetime.timedelta(seconds=10)
 SECOND_CONNECTION_RESULT_TIMEOUT = datetime.timedelta(seconds=25)
@@ -55,13 +55,13 @@
 
 MCC_THROUGHPUT_MULTIPLIER = 0.25
 MAX_PHY_RATE_TO_MIN_THROUGHPUT_RATIO_5G = 0.37
-MAX_PHY_RATE_TO_MIN_THROUGHPUT_RATIO_2G = 0.2
+MAX_PHY_RATE_TO_MIN_THROUGHPUT_RATIO_2G = 0.15
 # Add a temporary cap for NC speed check until nearby connections layer overhead
 # issue is fixed. Note that this cap is not applied to iperf speed check
 NC_THROUGHPUT_MIN_CAP_MBPS = 20
 
-CLASSIC_BT_MEDIUM_THROUGHPUT_BENCHMARK_MBPS = 0.02  # 20KBps
-BLE_MEDIUM_THROUGHPUT_BENCHMARK_MBPS = 0.02  # 20KBps
+CLASSIC_BT_MEDIUM_THROUGHPUT_BENCHMARK_MBPS = 0.02
+BLE_MEDIUM_THROUGHPUT_BENCHMARK_MBPS = 0.02
 
 KEEP_ALIVE_TIMEOUT_BT_MS = 30000
 KEEP_ALIVE_INTERVAL_BT_MS = 5000
@@ -75,11 +75,13 @@
 UNSET_LATENCY = datetime.timedelta.max
 UNSET_THROUGHPUT_KBPS = -1.0
 MAX_NUM_BUG_REPORT = 5
+INVALID_INT = -1
 
 TRANSFER_FILE_SIZE_500MB = 500 * 1024  # kB
 TRANSFER_FILE_SIZE_200MB = 200 * 1024  # kB
 TRANSFER_FILE_SIZE_20MB = 20 * 1024  # kB
 TRANSFER_FILE_SIZE_1MB = 1024  # kB
+TRANSFER_FILE_SIZE_500KB = 512  # kB
 TRANSFER_FILE_SIZE_1KB = 1  # kB
 
 TARGET_CUJ_QUICK_START = 'quick_start'
@@ -136,10 +138,12 @@
   allow_unrooted_device: bool = False
   keep_alive_timeout_ms: int = KEEP_ALIVE_TIMEOUT_WIFI_MS
   keep_alive_interval_ms: int = KEEP_ALIVE_INTERVAL_WIFI_MS
+  enable_2g_ble_scan_throttling: bool = True
 
   run_function_tests_with_performance_tests: bool = True
   run_bt_performance_test: bool = True
   run_ble_performance_test: bool = False
+  run_bt_coex_test: bool = True
   run_directed_test: bool = True
   run_compound_test: bool = True
   run_iperf_test: bool = True
@@ -242,7 +246,10 @@
   SOURCE_WIFI_CONNECTION = 8
   TARGET_WIFI_CONNECTION = 9
   AP_IS_NOT_CONFIGURED = 10
-  SUCCESS = 11
+  DISCONNECTED_FROM_AP = 11
+  WRONG_AP_FREQUENCY = 12
+  WRONG_P2P_FREQUENCY = 13
+  SUCCESS = 14
 
 
 COMMON_TRIAGE_TIP: dict[SingleTestFailureReason, str] = {
@@ -354,11 +361,11 @@
       SingleTestFailureReason.UNINITIALIZED
   )
   result_message: str = ''
-  prior_nc_setup_quality_info: ConnectionSetupQualityInfo = dataclasses.field(
+  prior_nc_quality_info: ConnectionSetupQualityInfo = dataclasses.field(
       default_factory=ConnectionSetupQualityInfo
   )
   discoverer_sta_latency: datetime.timedelta = UNSET_LATENCY
-  file_transfer_nc_setup_quality_info: ConnectionSetupQualityInfo = (
+  quality_info: ConnectionSetupQualityInfo = (
       dataclasses.field(default_factory=ConnectionSetupQualityInfo)
   )
   file_transfer_throughput_kbps: float = UNSET_THROUGHPUT_KBPS
diff --git a/tests/bettertogether/betocq/setup_utils.py b/tests/bettertogether/betocq/setup_utils.py
index 22ec3ca..206c2f5 100644
--- a/tests/bettertogether/betocq/setup_utils.py
+++ b/tests/bettertogether/betocq/setup_utils.py
@@ -24,6 +24,7 @@
 from mobly.controllers.android_device_lib import adb
 
 from betocq import gms_auto_updates_util
+from betocq import nc_constants
 
 WIFI_COUNTRYCODE_CONFIG_TIME_SEC = 3
 TOGGLE_AIRPLANE_MODE_WAIT_TIME_SEC = 2
@@ -388,6 +389,31 @@
   check_and_try_to_write_ph_flag(ad, pname, flag_name, flag_type, flag_value)
 
 
+def enable_ble_scan_throttling_during_2g_transfer(
+    ad: android_device.AndroidDevice, enable_ble_scan_throttling: bool = False
+) -> None:
+  """Enable BLE scan throttling during 2G transfer.
+  """
+
+  # The default values for the following parameters are 3 mins which are long
+  # enough for the performance test.
+  # mediums_ble_client_wifi_24_ghz_warming_up_duration
+  # fast_pair_wifi_24_ghz_warming_up_duration
+  # sharing_wifi_24_ghz_warming_up_duration
+
+  pname = 'com.google.android.gms.nearby'
+  flag_name = 'fast_pair_enable_connection_state_changed_listener'
+  flag_type = 'boolean'
+  flag_value = 'true' if enable_ble_scan_throttling else 'false'
+  check_and_try_to_write_ph_flag(ad, pname, flag_name, flag_type, flag_value)
+
+  flag_name = 'sharing_enable_connection_state_changed_listener'
+  check_and_try_to_write_ph_flag(ad, pname, flag_name, flag_type, flag_value)
+
+  flag_name = 'mediums_ble_client_enable_connection_state_changed_listener'
+  check_and_try_to_write_ph_flag(ad, pname, flag_name, flag_type, flag_value)
+
+
 def disable_redaction(ad: android_device.AndroidDevice) -> None:
   """Disable info log redaction on the given device."""
   pname = 'com.google.android.gms'
@@ -425,14 +451,67 @@
   time.sleep(_DISABLE_ENABLE_GMS_UPDATE_WAIT_TIME_SEC)
 
 
-def dump_wifi_sta_status(
-    ad: android_device.AndroidDevice,
-) -> None:
+def get_wifi_sta_frequency(ad: android_device.AndroidDevice) -> int:
+  """Get wifi STA frequency on the given device."""
+  wifi_sta_status = dump_wifi_sta_status(ad)
+  if not wifi_sta_status:
+    return nc_constants.INVALID_INT
+  prefix = 'Frequency:'
+  postfix = 'MHz'
+  return get_int_between_prefix_postfix(wifi_sta_status, prefix, postfix)
+
+
+def get_wifi_p2p_frequency(ad: android_device.AndroidDevice) -> int:
+  """Get wifi p2p frequency on the given device."""
+  wifi_p2p_status = dump_wifi_p2p_status(ad)
+  if not wifi_p2p_status:
+    return nc_constants.INVALID_INT
+  prefix = 'channelFrequency='
+  postfix = ', groupRole=GroupOwner'
+  return get_int_between_prefix_postfix(wifi_p2p_status, prefix, postfix)
+
+
+def get_wifi_sta_max_link_speed(ad: android_device.AndroidDevice) -> int:
+  """Get wifi STA max supported Tx link speed on the given device."""
+  wifi_sta_status = dump_wifi_sta_status(ad)
+  if not wifi_sta_status:
+    return nc_constants.INVALID_INT
+  prefix = 'Max Supported Tx Link speed:'
+  postfix = 'Mbps'
+  return get_int_between_prefix_postfix(wifi_sta_status, prefix, postfix)
+
+
+def get_int_between_prefix_postfix(
+    string: str, prefix: str, postfix: str
+) -> int:
+  left_index = string.rfind(prefix)
+  right_index = string.rfind(postfix)
+  if left_index > 0 and right_index > left_index:
+    try:
+      return int(string[left_index + len(prefix): right_index].strip())
+    except ValueError:
+      return nc_constants.INVALID_INT
+  return nc_constants.INVALID_INT
+
+
+def dump_wifi_sta_status(ad: android_device.AndroidDevice) -> str:
   """Dumps wifi STA status on the given device."""
-  wifi_sta_status = (
-      ad.adb.shell('cmd wifi status | grep WifiInfo').decode('utf-8').strip()
-  )
-  ad.log.info(f'Wifi Score Report: {wifi_sta_status}')
+  try:
+    return (
+        ad.adb.shell('cmd wifi status | grep WifiInfo').decode('utf-8').strip()
+    )
+  except adb.AdbError:
+    return ''
+
+
+def dump_wifi_p2p_status(ad: android_device.AndroidDevice) -> str:
+  """Dumps wifi p2p status on the given device."""
+  try:
+    return (
+        ad.adb.shell('dumpsys wifip2p').decode('utf-8').strip()
+    )
+  except adb.AdbError:
+    return ''
 
 
 def get_hardware(ad: android_device.AndroidDevice) -> str:
diff --git a/tests/bettertogether/betocq/version.py b/tests/bettertogether/betocq/version.py
index a21f32a..53be708 100644
--- a/tests/bettertogether/betocq/version.py
+++ b/tests/bettertogether/betocq/version.py
@@ -15,7 +15,8 @@
 """Define the Beto CQ test script version."""
 
 
-TEST_SCRIPT_VERSION = '2.0.0'
+TEST_SCRIPT_VERSION = '2.1.0'
 
 # VERSION_LOG (only add new description for new version, keep the history log)
 # '2.0.0': 'initial version'
+# '2.1.0': 'add iperf'
diff --git a/tests/bettertogether/quickstart/snippets/nearby_snippet.apk b/tests/bettertogether/quickstart/snippets/nearby_snippet.apk
index 14384f0..33bc304 100755
--- a/tests/bettertogether/quickstart/snippets/nearby_snippet.apk
+++ b/tests/bettertogether/quickstart/snippets/nearby_snippet.apk
Binary files differ
diff --git a/tests/bettertogether/quickstart/snippets/nearby_snippet_2.apk b/tests/bettertogether/quickstart/snippets/nearby_snippet_2.apk
index c4d958f..ba053fa 100755
--- a/tests/bettertogether/quickstart/snippets/nearby_snippet_2.apk
+++ b/tests/bettertogether/quickstart/snippets/nearby_snippet_2.apk
Binary files differ