[WPA3] Hide connect button for cloned networks not in range

Cloned networks are WPA2 or Open networks that have a WPA3 or OWE
cloned networks with the same SSID and credentials. When an AP
in transition mode is in the area, the scan results will only
report the higher security level. In order to prevent a case
where the user forcely connects to the AP with the lower security,
disable this option for those networks. Otherwise, it will look
that Wi-Fi is connected, but Wi-Fi picker will not show a connected
network.

Bug: 143843364
Test: Manual test
Change-Id: I7244c41d3bf12ba573c3cfca077d0ac2cfdcf5ed
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index e9d2e08..c935b6a 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -781,6 +781,11 @@
     }
 
     private boolean canConnectNetwork() {
+        // Do not allow a cloned network to connect when out of range
+        // Otherwise it may create inconsistencies in the UI
+        if (mAccessPoint.isCloned() && mIsOutOfRange) {
+            return false;
+        }
         // Display connect button for disconnected AP even not in the range.
         return !mAccessPoint.isActive();
     }