[RTT] Update CTS to auto-select test AP

Update CTS to select a test AP:
- Scan for APs
- Select the APs supporting IEEE 802.11mc
- Pick the AP with the highest RSSI

Bug: 74518964
Test: atest WifiRttTest (and pick the CTS test)
Change-Id: I6467c75eedcc8260703d2a99214154c9e888cce9
diff --git a/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java b/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
index b235d96..99684e8 100644
--- a/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
+++ b/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
@@ -43,10 +43,6 @@
 public class TestBase extends AndroidTestCase {
     protected static final String TAG = "WifiRttCtsTests";
 
-    // The SSID of the test AP which supports IEEE 802.11mc
-    // TODO b/74518964: finalize correct method to refer to an AP in the test lab
-    static final String SSID_OF_TEST_AP = "standalone_rtt";
-
     // wait for Wi-Fi RTT to become available
     private static final int WAIT_FOR_RTT_CHANGE_SECS = 10;
 
@@ -211,33 +207,30 @@
     }
 
     /**
-     * Start a scan and return the test AP with the specified SSID and which supports IEEE 802.11mc.
-     * If the AP is not found re-attempts the scan maxScanRetries times (i.e. total number of
-     * scans can be maxScanRetries + 1).
+     * Start a scan and return a test AP which supports IEEE 802.11mc and which has the highest
+     * RSSI. Will perform N (parameterized) scans and get the best AP across both scans.
      *
      * Returns null if test AP is not found in the specified number of scans.
      *
-     * @param ssid The SSID of the test AP
-     * @param maxScanRetries Maximum number of scans retries (in addition to first scan).
+     * @param numScanRetries Maximum number of scans retries (in addition to first scan).
      */
-    protected ScanResult scanForTestAp(String ssid, int maxScanRetries)
+    protected ScanResult scanForTestAp(int numScanRetries)
             throws InterruptedException {
         int scanCount = 0;
-        while (scanCount <= maxScanRetries) {
+        ScanResult bestTestAp = null;
+        while (scanCount <= numScanRetries) {
             for (ScanResult scanResult : scanAps()) {
                 if (!scanResult.is80211mcResponder()) {
                     continue;
                 }
-                if (!ssid.equals(scanResult.SSID)) {
-                    continue;
+                if (bestTestAp == null || scanResult.level > bestTestAp.level) {
+                    bestTestAp = scanResult;
                 }
-
-                return scanResult;
             }
 
             scanCount++;
         }
 
-        return null;
+        return bestTestAp;
     }
 }
diff --git a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
index d0b0d6d..5995bbd 100644
--- a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
+++ b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
@@ -34,8 +34,8 @@
  * Wi-Fi RTT CTS test: range to all available Access Points which support IEEE 802.11mc.
  */
 public class WifiRttTest extends TestBase {
-    // Max number of scan retries to do while searching for APs supporting IEEE 802.11mc
-    private static final int MAX_NUM_SCAN_RETRIES_SEARCHING_FOR_IEEE80211MC_AP = 2;
+    // Number of scans to do while searching for APs supporting IEEE 802.11mc
+    private static final int NUM_SCANS_SEARCHING_FOR_IEEE80211MC_AP = 2;
 
     // Number of RTT measurements per AP
     private static final int NUM_OF_RTT_ITERATIONS = 10;
@@ -63,8 +63,7 @@
         }
 
         // Scan for IEEE 802.11mc supporting APs
-        ScanResult testAp = scanForTestAp(SSID_OF_TEST_AP,
-                MAX_NUM_SCAN_RETRIES_SEARCHING_FOR_IEEE80211MC_AP);
+        ScanResult testAp = scanForTestAp(NUM_SCANS_SEARCHING_FOR_IEEE80211MC_AP);
         assertTrue("Cannot find test AP", testAp != null);
 
         // Perform RTT operations