Fix testWifiConfigLockdown on certain devices

On devices with testWifiConfigLockdown = true, the test fails
as it doesn't understand some configurations are auto-created
wpa3-sae variants. Fix the test by skipping configs which are
already auto-removed.

Bug: 209497261
Test: DeviceOwnerTest#testWifiConfigLockdown
Change-Id: Iad200388f1741304dd8b77f786ce872b653de383
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiConfigLockdownTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiConfigLockdownTest.java
index 627ef61..89a7b29 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiConfigLockdownTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiConfigLockdownTest.java
@@ -110,6 +110,13 @@
         for (WifiConfiguration config : configs) {
             if (areMatchingSsids(ORIGINAL_DEVICE_OWNER_SSID, config.SSID)
                     || areMatchingSsids(ORIGINAL_REGULAR_SSID, config.SSID)) {
+                // On some devices a wpa3-sae configuration is auto-created for every wpa2
+                // config, and they are auto-removed when the corresponding config is removed.
+                // Recheck every config against the latest list of wifi configurations and skip
+                // those which is already auto-removed.
+                if (mWifiManager.getConfiguredNetworks().stream()
+                        .noneMatch(c -> c.networkId == config.networkId)) continue;
+
                 assertWithMessage("mWifiManager.removeNetwork(%s)", config.networkId)
                         .that(mWifiManager.removeNetwork(config.networkId)).isTrue();
                 ++removeCount;