Merge "Don't overwrite security params when editing saved config" into udc-dev
This commit is contained in:
@@ -592,28 +592,32 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiConfiguration config = new WifiConfiguration();
|
WifiConfiguration config;
|
||||||
|
|
||||||
if (mWifiEntry == null) {
|
if (mWifiEntry == null) {
|
||||||
|
config = new WifiConfiguration();
|
||||||
config.SSID = "\"" + mSsidView.getText().toString() + "\"";
|
config.SSID = "\"" + mSsidView.getText().toString() + "\"";
|
||||||
// If the user adds a network manually, assume that it is hidden.
|
// If the user adds a network manually, assume that it is hidden.
|
||||||
config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
|
config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
|
||||||
} else if (!mWifiEntry.isSaved()) {
|
} else if (mWifiEntry.isSaved()) {
|
||||||
config.SSID = "\"" + mWifiEntry.getTitle() + "\"";
|
config = new WifiConfiguration(mWifiEntry.getWifiConfiguration());
|
||||||
} else {
|
} else {
|
||||||
config.networkId = mWifiEntry.getWifiConfiguration().networkId;
|
config = new WifiConfiguration();
|
||||||
config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID;
|
config.SSID = "\"" + mWifiEntry.getTitle() + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
config.shared = mSharedCheckBox.isChecked();
|
config.shared = mSharedCheckBox.isChecked();
|
||||||
|
|
||||||
switch (mWifiEntrySecurity) {
|
switch (mWifiEntrySecurity) {
|
||||||
case WifiEntry.SECURITY_NONE:
|
case WifiEntry.SECURITY_NONE:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiEntry.SECURITY_WEP:
|
case WifiEntry.SECURITY_WEP:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
|
||||||
|
}
|
||||||
if (mPasswordView.length() != 0) {
|
if (mPasswordView.length() != 0) {
|
||||||
int length = mPasswordView.length();
|
int length = mPasswordView.length();
|
||||||
String password = mPasswordView.getText().toString();
|
String password = mPasswordView.getText().toString();
|
||||||
@@ -628,7 +632,9 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiEntry.SECURITY_PSK:
|
case WifiEntry.SECURITY_PSK:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
|
||||||
|
}
|
||||||
if (mPasswordView.length() != 0) {
|
if (mPasswordView.length() != 0) {
|
||||||
String password = mPasswordView.getText().toString();
|
String password = mPasswordView.getText().toString();
|
||||||
if (password.matches("[0-9A-Fa-f]{64}")) {
|
if (password.matches("[0-9A-Fa-f]{64}")) {
|
||||||
@@ -642,14 +648,17 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
case WifiEntry.SECURITY_EAP:
|
case WifiEntry.SECURITY_EAP:
|
||||||
case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE:
|
case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE:
|
||||||
case WifiEntry.SECURITY_EAP_SUITE_B:
|
case WifiEntry.SECURITY_EAP_SUITE_B:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
|
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||||
// allowedSuiteBCiphers will be set according to certificate type
|
// allowedSuiteBCiphers will be set according to certificate type
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
|
||||||
} else if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE) {
|
} else if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
|
config.setSecurityParams(
|
||||||
|
WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
|
||||||
} else {
|
} else {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
config.enterpriseConfig = new WifiEnterpriseConfig();
|
config.enterpriseConfig = new WifiEnterpriseConfig();
|
||||||
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
|
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
|
||||||
int phase2Method = mPhase2Spinner.getSelectedItemPosition();
|
int phase2Method = mPhase2Spinner.getSelectedItemPosition();
|
||||||
@@ -790,7 +799,9 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WifiEntry.SECURITY_SAE:
|
case WifiEntry.SECURITY_SAE:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
|
||||||
|
}
|
||||||
if (mPasswordView.length() != 0) {
|
if (mPasswordView.length() != 0) {
|
||||||
String password = mPasswordView.getText().toString();
|
String password = mPasswordView.getText().toString();
|
||||||
config.preSharedKey = '"' + password + '"';
|
config.preSharedKey = '"' + password + '"';
|
||||||
@@ -798,7 +809,9 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiEntry.SECURITY_OWE:
|
case WifiEntry.SECURITY_OWE:
|
||||||
|
if (mWifiEntry == null || !mWifiEntry.isSaved()) {
|
||||||
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
|
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -470,7 +470,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
private void checkSavedMacRandomizedValue(int macRandomizedValue) {
|
private void checkSavedMacRandomizedValue(int macRandomizedValue) {
|
||||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||||
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
|
final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
|
||||||
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
||||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||||
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
|
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
|
||||||
@@ -809,9 +809,10 @@ public class WifiConfigController2Test {
|
|||||||
private void setUpModifyingSavedPeapConfigController() {
|
private void setUpModifyingSavedPeapConfigController() {
|
||||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||||
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
|
final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
|
||||||
|
mockWifiConfig.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
|
||||||
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
|
||||||
final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
|
final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig());
|
||||||
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
|
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
|
||||||
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
||||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||||
@@ -980,8 +981,8 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate,
|
private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate,
|
||||||
String savedUserCertificate) {
|
String savedUserCertificate) {
|
||||||
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
|
final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
|
||||||
final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
|
final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig());
|
||||||
|
|
||||||
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
||||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||||
|
Reference in New Issue
Block a user