Loading src/com/android/settings/wifi/WifiConfigController2.java +31 −18 Original line number Diff line number Diff line Loading @@ -592,28 +592,32 @@ public class WifiConfigController2 implements TextWatcher, return null; } WifiConfiguration config = new WifiConfiguration(); WifiConfiguration config; if (mWifiEntry == null) { config = new WifiConfiguration(); config.SSID = "\"" + mSsidView.getText().toString() + "\""; // If the user adds a network manually, assume that it is hidden. config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK; } else if (!mWifiEntry.isSaved()) { config.SSID = "\"" + mWifiEntry.getTitle() + "\""; } else if (mWifiEntry.isSaved()) { config = new WifiConfiguration(mWifiEntry.getWifiConfiguration()); } else { config.networkId = mWifiEntry.getWifiConfiguration().networkId; config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID; config = new WifiConfiguration(); config.SSID = "\"" + mWifiEntry.getTitle() + "\""; } config.shared = mSharedCheckBox.isChecked(); switch (mWifiEntrySecurity) { case WifiEntry.SECURITY_NONE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN); } break; case WifiEntry.SECURITY_WEP: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP); } if (mPasswordView.length() != 0) { int length = mPasswordView.length(); String password = mPasswordView.getText().toString(); Loading @@ -628,7 +632,9 @@ public class WifiConfigController2 implements TextWatcher, break; case WifiEntry.SECURITY_PSK: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK); } if (mPasswordView.length() != 0) { String password = mPasswordView.getText().toString(); if (password.matches("[0-9A-Fa-f]{64}")) { Loading @@ -642,14 +648,17 @@ public class WifiConfigController2 implements TextWatcher, case WifiEntry.SECURITY_EAP: case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE: case WifiEntry.SECURITY_EAP_SUITE_B: if (mWifiEntry == null || !mWifiEntry.isSaved()) { if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) { // allowedSuiteBCiphers will be set according to certificate type config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B); } 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 { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP); } } config.enterpriseConfig = new WifiEnterpriseConfig(); int eapMethod = mEapMethodSpinner.getSelectedItemPosition(); int phase2Method = mPhase2Spinner.getSelectedItemPosition(); Loading Loading @@ -790,7 +799,9 @@ public class WifiConfigController2 implements TextWatcher, } break; case WifiEntry.SECURITY_SAE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE); } if (mPasswordView.length() != 0) { String password = mPasswordView.getText().toString(); config.preSharedKey = '"' + password + '"'; Loading @@ -798,7 +809,9 @@ public class WifiConfigController2 implements TextWatcher, break; case WifiEntry.SECURITY_OWE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE); } break; default: Loading tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java +6 −5 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public class WifiConfigController2Test { private void checkSavedMacRandomizedValue(int macRandomizedValue) { 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(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.macRandomizationSetting = macRandomizedValue; Loading Loading @@ -809,9 +809,10 @@ public class WifiConfigController2Test { private void setUpModifyingSavedPeapConfigController() { when(mWifiEntry.isSaved()).thenReturn(true); 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)); final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class); final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig()); when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP); mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig; when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); Loading Loading @@ -980,8 +981,8 @@ public class WifiConfigController2Test { private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate, String savedUserCertificate) { final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class); final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig()); mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig; when(mWifiEntry.isSaved()).thenReturn(true); Loading Loading
src/com/android/settings/wifi/WifiConfigController2.java +31 −18 Original line number Diff line number Diff line Loading @@ -592,28 +592,32 @@ public class WifiConfigController2 implements TextWatcher, return null; } WifiConfiguration config = new WifiConfiguration(); WifiConfiguration config; if (mWifiEntry == null) { config = new WifiConfiguration(); config.SSID = "\"" + mSsidView.getText().toString() + "\""; // If the user adds a network manually, assume that it is hidden. config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK; } else if (!mWifiEntry.isSaved()) { config.SSID = "\"" + mWifiEntry.getTitle() + "\""; } else if (mWifiEntry.isSaved()) { config = new WifiConfiguration(mWifiEntry.getWifiConfiguration()); } else { config.networkId = mWifiEntry.getWifiConfiguration().networkId; config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID; config = new WifiConfiguration(); config.SSID = "\"" + mWifiEntry.getTitle() + "\""; } config.shared = mSharedCheckBox.isChecked(); switch (mWifiEntrySecurity) { case WifiEntry.SECURITY_NONE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN); } break; case WifiEntry.SECURITY_WEP: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP); } if (mPasswordView.length() != 0) { int length = mPasswordView.length(); String password = mPasswordView.getText().toString(); Loading @@ -628,7 +632,9 @@ public class WifiConfigController2 implements TextWatcher, break; case WifiEntry.SECURITY_PSK: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK); } if (mPasswordView.length() != 0) { String password = mPasswordView.getText().toString(); if (password.matches("[0-9A-Fa-f]{64}")) { Loading @@ -642,14 +648,17 @@ public class WifiConfigController2 implements TextWatcher, case WifiEntry.SECURITY_EAP: case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE: case WifiEntry.SECURITY_EAP_SUITE_B: if (mWifiEntry == null || !mWifiEntry.isSaved()) { if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) { // allowedSuiteBCiphers will be set according to certificate type config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B); } 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 { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP); } } config.enterpriseConfig = new WifiEnterpriseConfig(); int eapMethod = mEapMethodSpinner.getSelectedItemPosition(); int phase2Method = mPhase2Spinner.getSelectedItemPosition(); Loading Loading @@ -790,7 +799,9 @@ public class WifiConfigController2 implements TextWatcher, } break; case WifiEntry.SECURITY_SAE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE); } if (mPasswordView.length() != 0) { String password = mPasswordView.getText().toString(); config.preSharedKey = '"' + password + '"'; Loading @@ -798,7 +809,9 @@ public class WifiConfigController2 implements TextWatcher, break; case WifiEntry.SECURITY_OWE: if (mWifiEntry == null || !mWifiEntry.isSaved()) { config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE); } break; default: Loading
tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java +6 −5 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public class WifiConfigController2Test { private void checkSavedMacRandomizedValue(int macRandomizedValue) { 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(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); mockWifiConfig.macRandomizationSetting = macRandomizedValue; Loading Loading @@ -809,9 +809,10 @@ public class WifiConfigController2Test { private void setUpModifyingSavedPeapConfigController() { when(mWifiEntry.isSaved()).thenReturn(true); 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)); final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class); final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig()); when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP); mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig; when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig); Loading Loading @@ -980,8 +981,8 @@ public class WifiConfigController2Test { private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate, String savedUserCertificate) { final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class); final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class); final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration()); final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig()); mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig; when(mWifiEntry.isSaved()).thenReturn(true); Loading