OSDN Git Service

[OWE] Support OWE in transition mode
authorHai Shalom <haishalom@google.com>
Mon, 13 May 2019 22:31:41 +0000 (15:31 -0700)
committerHai Shalom <haishalom@google.com>
Mon, 13 May 2019 22:37:43 +0000 (15:37 -0700)
Support OWE in transition mode for devices with OWE support
and devices without OWE support. Scan results will return a
new type of network for OWE in transition networks on devices
that support OWE, and Open for devices that don't support OWE.
Handle the case where Open network is manually added to a device
that supports OWE.

Bug: 132139642
Test: Device with OWE: Connect to Open, OWE-Transition, OWE networks
Test: Device without OWE: Connect to Open, OWE-Transition
Test: Manually create Open network, connect to OWE-Transition
Change-Id: I29e69eaae2672562420ee7c6393bf2cc4d7f1b91

packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
wifi/java/android/net/wifi/ScanResult.java

index 05af4e1..e28c612 100644 (file)
@@ -180,7 +180,8 @@ public class AccessPoint implements Comparable<AccessPoint> {
     public static final int SECURITY_SAE = 5;
     public static final int SECURITY_EAP_SUITE_B = 6;
     public static final int SECURITY_PSK_SAE_TRANSITION = 7;
-    public static final int SECURITY_MAX_VAL = 8; // Has to be the last
+    public static final int SECURITY_OWE_TRANSITION = 8;
+    public static final int SECURITY_MAX_VAL = 9; // Has to be the last
 
     private static final int PSK_UNKNOWN = 0;
     private static final int PSK_WPA = 1;
@@ -869,6 +870,12 @@ public class AccessPoint implements Comparable<AccessPoint> {
                     return concise ? context.getString(R.string.wifi_security_short_sae) :
                             context.getString(R.string.wifi_security_sae);
                 }
+            case SECURITY_OWE_TRANSITION:
+                if (mConfig != null && getSecurity(mConfig) == SECURITY_OWE) {
+                    return concise ? context.getString(R.string.wifi_security_short_owe) :
+                            context.getString(R.string.wifi_security_owe);
+                }
+                return concise ? "" : context.getString(R.string.wifi_security_none);
             case SECURITY_OWE:
                 return concise ? context.getString(R.string.wifi_security_short_owe) :
                     context.getString(R.string.wifi_security_owe);
@@ -1179,7 +1186,8 @@ public class AccessPoint implements Comparable<AccessPoint> {
      * Can only be called for unsecured networks.
      */
     public void generateOpenNetworkConfig() {
-        if ((security != SECURITY_NONE) && (security != SECURITY_OWE)) {
+        if ((security != SECURITY_NONE) && (security != SECURITY_OWE)
+                && (security != SECURITY_OWE_TRANSITION)) {
             throw new IllegalStateException();
         }
         if (mConfig != null)
@@ -1187,7 +1195,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
         mConfig = new WifiConfiguration();
         mConfig.SSID = AccessPoint.convertToQuotedString(ssid);
 
-        if (security == SECURITY_NONE) {
+        if (security == SECURITY_NONE || !getWifiManager().isEasyConnectSupported()) {
             mConfig.allowedKeyManagement.set(KeyMgmt.NONE);
         } else {
             mConfig.allowedKeyManagement.set(KeyMgmt.OWE);
@@ -1229,6 +1237,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
     private static final String sPskSuffix = "," + String.valueOf(SECURITY_PSK);
     private static final String sSaeSuffix = "," + String.valueOf(SECURITY_SAE);
     private static final String sPskSaeSuffix = "," + String.valueOf(SECURITY_PSK_SAE_TRANSITION);
+    private static final String sOweSuffix = "," + String.valueOf(SECURITY_OWE);
+    private static final String sOpenSuffix = "," + String.valueOf(SECURITY_NONE);
+    private static final String sOweTransSuffix = "," + String.valueOf(SECURITY_OWE_TRANSITION);
 
     private boolean isKeyEqual(String compareTo) {
         if (mKey == null) {
@@ -1243,6 +1254,14 @@ public class AccessPoint implements Comparable<AccessPoint> {
                         compareTo.substring(0, compareTo.lastIndexOf(',')));
             }
         }
+        if (compareTo.endsWith(sOpenSuffix) || compareTo.endsWith(sOweSuffix)) {
+            if (mKey.endsWith(sOweTransSuffix)) {
+                // Special handling for OWE/Open networks. If AP advertises OWE in transition mode
+                // and we have an Open network saved, allow this connection to be established.
+                return TextUtils.equals(mKey.substring(0, mKey.lastIndexOf(',')),
+                        compareTo.substring(0, compareTo.lastIndexOf(',')));
+            }
+        }
         return mKey.equals(compareTo);
     }
 
@@ -1579,10 +1598,11 @@ public class AccessPoint implements Comparable<AccessPoint> {
             return SECURITY_EAP_SUITE_B;
         } else if (result.capabilities.contains("EAP")) {
             return SECURITY_EAP;
+        } else if (result.capabilities.contains("OWE_TRANSITION")) {
+            return SECURITY_OWE_TRANSITION;
         } else if (result.capabilities.contains("OWE")) {
             return SECURITY_OWE;
         }
-
         return SECURITY_NONE;
     }
 
@@ -1628,6 +1648,8 @@ public class AccessPoint implements Comparable<AccessPoint> {
             return "OWE";
         } else if (security == SECURITY_PSK_SAE_TRANSITION) {
             return "PSK+SAE";
+        } else if (security == SECURITY_OWE_TRANSITION) {
+            return "OWE_TRANSITION";
         }
         return "NONE";
     }
index 6269a71..dae5464 100644 (file)
@@ -201,7 +201,8 @@ public class AccessPointPreference extends Preference {
             return;
         }
         if ((mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE)
-                && (mAccessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) {
+                && (mAccessPoint.getSecurity() != AccessPoint.SECURITY_OWE)
+                && (mAccessPoint.getSecurity() != AccessPoint.SECURITY_OWE_TRANSITION)) {
             mFrictionSld.setState(STATE_SECURED);
         } else if (mAccessPoint.isMetered()) {
             mFrictionSld.setState(STATE_METERED);
index 0b1108d..c0c0361 100644 (file)
@@ -160,6 +160,11 @@ public class ScanResult implements Parcelable {
     public static final int KEY_MGMT_FT_SAE = 11;
     /**
      * @hide
+     * Security key management scheme: OWE in transition mode.
+     */
+    public static final int KEY_MGMT_OWE_TRANSITION = 12;
+    /**
+     * @hide
      * No cipher suite.
      */
     public static final int CIPHER_NONE = 0;