[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: Id002b109bd056105ec8335acd298fa3b314c73f3
Merged-In: I7244c41d3bf12ba573c3cfca077d0ac2cfdcf5ed
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index a915766..e8fc8bb 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -741,6 +741,10 @@
     }
 
     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();
     }