From aa6f920a627cdefdfbbdf066888c07bdae2fdcc5 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Tue, 16 Oct 2018 14:30:02 -0700 Subject: [PATCH] [WPA3] Settingslib changes to support new WPA3/OWE types Added new strings and types for WPA3 and OWE new Wi-Fi Security standards. Modified WPA2-PSK to WPA2-Personal, and added WPA3-Personal, WPA3-Enterprise and Enhanced Open modes. Bug: 112195778 Test: Functional unit tests Change-Id: Ie5d27c2bbf082bf536d4f8c5cb5d5704155c0940 --- packages/SettingsLib/res/values/strings.xml | 40 +++++++++----- .../android/settingslib/wifi/AccessPoint.java | 53 ++++++++++++++++--- .../wifi/AccessPointPreference.java | 3 +- 3 files changed, 75 insertions(+), 21 deletions(-) diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 508adbd2a1217..e2a34f42369a1 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -21,35 +21,47 @@ Can\'t scan for networks - WEP + WEP - WPA + WPA - WPA2 + WPA2 - WPA/WPA2 + WPA/WPA2 - @string/wifi_security_short_wpa_wpa2 + @string/wifi_security_short_wpa_wpa2 - 802.1x + 802.1x + + WPA3 + + OWE + + Suite-B - None + None - WEP + WEP - WPA PSK + WPA-Personal - WPA2 PSK + WPA2-Personal - WPA/WPA2 PSK + WPA/WPA2-Personal - @string/wifi_security_wpa_wpa2 + @string/wifi_security_wpa_wpa2 - 802.1x EAP + WPA/WPA2-Enterprise - Passpoint + Passpoint + + WPA3-Personal + + Enhanced Open + + WPA3-Enterprise Saved diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index e950e8e670d7d..523361dc1d966 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -158,9 +158,12 @@ public class AccessPoint implements Comparable { * These values are matched in string arrays -- changes must be kept in sync */ public static final int SECURITY_NONE = 0; - public static final int SECURITY_WEP = 1; - public static final int SECURITY_PSK = 2; - public static final int SECURITY_EAP = 3; + public static final int SECURITY_OWE = 1; + public static final int SECURITY_WEP = 2; + public static final int SECURITY_PSK = 3; + public static final int SECURITY_SAE = 4; + public static final int SECURITY_EAP = 5; + public static final int SECURITY_EAP_SUITE_B = 6; private static final int PSK_UNKNOWN = 0; private static final int PSK_WPA = 1; @@ -433,7 +436,7 @@ public class AccessPoint implements Comparable { if (isConnectable()) { builder.append(',').append("connectable"); } - if (security != SECURITY_NONE) { + if ((security != SECURITY_NONE) && (security != SECURITY_OWE)) { builder.append(',').append(securityToString(security, pskType)); } builder.append(",level=").append(getLevel()); @@ -720,6 +723,9 @@ public class AccessPoint implements Comparable { case SECURITY_EAP: return concise ? context.getString(R.string.wifi_security_short_eap) : context.getString(R.string.wifi_security_eap); + case SECURITY_EAP_SUITE_B: + return concise ? context.getString(R.string.wifi_security_short_eap_suiteb) : + context.getString(R.string.wifi_security_eap_suiteb); case SECURITY_PSK: switch (pskType) { case PSK_WPA: @@ -739,6 +745,12 @@ public class AccessPoint implements Comparable { case SECURITY_WEP: return concise ? context.getString(R.string.wifi_security_short_wep) : context.getString(R.string.wifi_security_wep); + case SECURITY_SAE: + return concise ? context.getString(R.string.wifi_security_short_sae) : + context.getString(R.string.wifi_security_sae); + case SECURITY_OWE: + return concise ? context.getString(R.string.wifi_security_short_owe) : + context.getString(R.string.wifi_security_owe); case SECURITY_NONE: default: return concise ? "" : context.getString(R.string.wifi_security_none); @@ -980,13 +992,20 @@ public class AccessPoint implements Comparable { * Can only be called for unsecured networks. */ public void generateOpenNetworkConfig() { - if (security != SECURITY_NONE) + if ((security != SECURITY_NONE) && (security != SECURITY_OWE)) { throw new IllegalStateException(); + } if (mConfig != null) return; mConfig = new WifiConfiguration(); mConfig.SSID = AccessPoint.convertToQuotedString(ssid); - mConfig.allowedKeyManagement.set(KeyMgmt.NONE); + + if (security == SECURITY_NONE) { + mConfig.allowedKeyManagement.set(KeyMgmt.NONE); + } else { + mConfig.allowedKeyManagement.set(KeyMgmt.OWE); + mConfig.requirePMF = true; + } } public void saveWifiState(Bundle savedState) { @@ -1288,22 +1307,38 @@ public class AccessPoint implements Comparable { private static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; + } else if (result.capabilities.contains("SAE")) { + return SECURITY_SAE; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; + } else if (result.capabilities.contains("EAP_SUITE_B_192")) { + return SECURITY_EAP_SUITE_B; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; + } else if (result.capabilities.contains("OWE")) { + return SECURITY_OWE; } + return SECURITY_NONE; } static int getSecurity(WifiConfiguration config) { + if (config.allowedKeyManagement.get(KeyMgmt.SAE)) { + return SECURITY_SAE; + } if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } + if (config.allowedKeyManagement.get(KeyMgmt.SUITE_B_192)) { + return SECURITY_EAP_SUITE_B; + } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } + if (config.allowedKeyManagement.get(KeyMgmt.OWE)) { + return SECURITY_OWE; + } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } @@ -1321,6 +1356,12 @@ public class AccessPoint implements Comparable { return "PSK"; } else if (security == SECURITY_EAP) { return "EAP"; + } else if (security == SECURITY_SAE) { + return "SAE"; + } else if (security == SECURITY_EAP_SUITE_B) { + return "SUITE_B"; + } else if (security == SECURITY_OWE) { + return "OWE"; } return "NONE"; } diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java index f3c43cce0f833..db364a3b75e58 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java @@ -200,7 +200,8 @@ public class AccessPointPreference extends Preference { if (frictionImageView == null || mFrictionSld == null) { return; } - if (mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE) { + if ((mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE) + && (mAccessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) { mFrictionSld.setState(STATE_SECURED); } else if (mAccessPoint.isMetered()) { mFrictionSld.setState(STATE_METERED);