[Settings] Use WifiConfiguration#setSecurityParams
Use WifiConfiguration#setSecurityParams instead of manually initializing security params. Bug: 150889755 Test: Created new connections and manually connected to open, WPA2, WPA3, EAP and SUITE-B networks. Change-Id: I42f4c21a37428ee87be14f6ba09dc54fa327054a
This commit is contained in:
@@ -27,8 +27,6 @@ import android.net.ProxyInfo;
|
||||
import android.net.StaticIpConfiguration;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
|
||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.net.wifi.WifiEnterpriseConfig;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Eap;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Phase2;
|
||||
@@ -633,13 +631,11 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
switch (mWifiEntrySecurity) {
|
||||
case WifiEntry.SECURITY_NONE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
|
||||
break;
|
||||
|
||||
case WifiEntry.SECURITY_WEP:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
|
||||
if (mPasswordView.length() != 0) {
|
||||
int length = mPasswordView.length();
|
||||
String password = mPasswordView.getText().toString();
|
||||
@@ -654,7 +650,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
break;
|
||||
|
||||
case WifiEntry.SECURITY_PSK:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
|
||||
if (mPasswordView.length() != 0) {
|
||||
String password = mPasswordView.getText().toString();
|
||||
if (password.matches("[0-9A-Fa-f]{64}")) {
|
||||
@@ -667,16 +663,11 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
case WifiEntry.SECURITY_EAP:
|
||||
case WifiEntry.SECURITY_EAP_SUITE_B:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
|
||||
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
|
||||
config.requirePmf = true;
|
||||
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
|
||||
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
|
||||
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
|
||||
.BIP_GMAC_256);
|
||||
// allowedSuiteBCiphers will be set according to certificate type
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
|
||||
} else {
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
|
||||
}
|
||||
config.enterpriseConfig = new WifiEnterpriseConfig();
|
||||
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
|
||||
@@ -809,8 +800,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
break;
|
||||
case WifiEntry.SECURITY_SAE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.SAE);
|
||||
config.requirePmf = true;
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
|
||||
if (mPasswordView.length() != 0) {
|
||||
String password = mPasswordView.getText().toString();
|
||||
config.preSharedKey = '"' + password + '"';
|
||||
@@ -818,8 +808,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
break;
|
||||
|
||||
case WifiEntry.SECURITY_OWE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.OWE);
|
||||
config.requirePmf = true;
|
||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user