Merge "[WPA3] Fix connectivity issues with PSK-SAE Transtion mode" into qt-dev
am: b2fcb7825e

Change-Id: If02ef643c1903f447231215aaacd807e3f345311
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index ac11510..ba26f02 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -42,7 +42,6 @@
 import android.text.InputType;
 import android.text.TextUtils;
 import android.text.TextWatcher;
-import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
@@ -582,6 +581,25 @@
         }
     }
 
+    /**
+     * Special handling for WPA2/WPA3 in Transition mode: The key SECURITY_PSK_SAE_TRANSITION is
+     * a pseudo key which results by the scan results, but never appears in the saved networks.
+     * A saved network is either WPA3 for supporting devices or WPA2 for non-supporting devices.
+     *
+     * @param accessPointSecurity Access point current security type
+     * @return Converted security type (if required)
+     */
+    private int convertSecurityTypeForMatching(int accessPointSecurity) {
+        if (accessPointSecurity == AccessPoint.SECURITY_PSK_SAE_TRANSITION) {
+            if (mWifiManager.isWpa3SaeSupported()) {
+                return AccessPoint.SECURITY_SAE;
+            } else {
+                return AccessPoint.SECURITY_PSK;
+            }
+        }
+        return accessPointSecurity;
+    }
+
     public WifiConfiguration getConfig() {
         if (mMode == WifiConfigUiBase.MODE_VIEW) {
             return null;
@@ -604,6 +622,8 @@
 
         config.shared = mSharedCheckBox.isChecked();
 
+        mAccessPointSecurity = convertSecurityTypeForMatching(mAccessPointSecurity);
+
         switch (mAccessPointSecurity) {
             case AccessPoint.SECURITY_NONE:
                 config.allowedKeyManagement.set(KeyMgmt.NONE);