softap: Use set/getPassphrase to replace set/getWpa2Passphrase
Bug: 142752869 Test: Manual, on/off/setting change for hotspot function Test: make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest Change-Id: I22c89f15a6ef1c5366394431cc5aa7031a573d45
This commit is contained in:
@@ -349,7 +349,7 @@ public class WifiDppUtils {
|
||||
// When the value of this key is read, the actual key is not returned, just a "*".
|
||||
// Call privileged system API to obtain actual key.
|
||||
final String preSharedKey = removeFirstAndLastDoubleQuotes(
|
||||
softApConfiguration.getWpa2Passphrase());
|
||||
softApConfiguration.getPassphrase());
|
||||
|
||||
if (!TextUtils.isEmpty(ssid)) {
|
||||
intent.putExtra(EXTRA_WIFI_SSID, ssid);
|
||||
|
@@ -51,10 +51,10 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
|
||||
final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
|
||||
if (config == null
|
||||
|| (config.getSecurityType() == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
|
||||
&& TextUtils.isEmpty(config.getWpa2Passphrase()))) {
|
||||
&& TextUtils.isEmpty(config.getPassphrase()))) {
|
||||
mPassword = generateRandomPassword();
|
||||
} else {
|
||||
mPassword = config.getWpa2Passphrase();
|
||||
mPassword = config.getPassphrase();
|
||||
}
|
||||
((ValidatedEditTextPreference) mPreference).setValidator(this);
|
||||
((ValidatedEditTextPreference) mPreference).setIsPassword(true);
|
||||
|
@@ -214,8 +214,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
final int securityType = mSecurityPreferenceController.getSecurityType();
|
||||
configBuilder.setSsid(mSSIDPreferenceController.getSSID());
|
||||
if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
|
||||
configBuilder.setWpa2Passphrase(
|
||||
mPasswordPreferenceController.getPasswordValidated(securityType));
|
||||
configBuilder.setPassphrase(
|
||||
mPasswordPreferenceController.getPasswordValidated(securityType),
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
|
||||
}
|
||||
configBuilder.setBand(mApBandPreferenceController.getBandIndex());
|
||||
return configBuilder.build();
|
||||
|
@@ -66,7 +66,7 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
|
||||
mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
|
||||
.setWpa2Passphrase("test_password").build();
|
||||
.setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
|
||||
@@ -83,8 +83,8 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
public void displayPreference_shouldStylePreference() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mPreference.getText()).isEqualTo(mConfig.getWpa2Passphrase());
|
||||
assertThat(mPreference.getSummary()).isEqualTo(mConfig.getWpa2Passphrase());
|
||||
assertThat(mPreference.getText()).isEqualTo(mConfig.getPassphrase());
|
||||
assertThat(mPreference.getSummary()).isEqualTo(mConfig.getPassphrase());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,14 +111,14 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
|
||||
// Create a new config using different password
|
||||
final SoftApConfiguration config = new SoftApConfiguration.Builder()
|
||||
.setWpa2Passphrase(VALID_PASS2).build();
|
||||
.setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
|
||||
|
||||
// Call updateDisplay and verify it's changed.
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getPasswordValidated(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK))
|
||||
.isEqualTo(config.getWpa2Passphrase());
|
||||
assertThat(mPreference.getSummary()).isEqualTo(config.getWpa2Passphrase());
|
||||
.isEqualTo(config.getPassphrase());
|
||||
assertThat(mPreference.getSummary()).isEqualTo(config.getPassphrase());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,7 +131,7 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
|
||||
// Create a new config using different password
|
||||
final SoftApConfiguration config = new SoftApConfiguration.Builder()
|
||||
.setWpa2Passphrase(VALID_PASS2).build();
|
||||
.setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
|
||||
|
||||
// Call updateDisplay and verify it's changed.
|
||||
|
@@ -124,7 +124,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
|
||||
public void displayPreference_wifiApDisabled_shouldHideQrCodeIcon() {
|
||||
when(mWifiManager.isWifiApEnabled()).thenReturn(false);
|
||||
final SoftApConfiguration config = new SoftApConfiguration.Builder()
|
||||
.setSsid("test_1234").setWpa2Passphrase("test_password").build();
|
||||
.setSsid("test_1234").setPassphrase("test_password",
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -135,7 +136,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
|
||||
public void displayPreference_wifiApEnabled_shouldShowQrCodeIcon() {
|
||||
when(mWifiManager.isWifiApEnabled()).thenReturn(true);
|
||||
final SoftApConfiguration config = new SoftApConfiguration.Builder()
|
||||
.setSsid("test_1234").setWpa2Passphrase("test_password").build();
|
||||
.setSsid("test_1234").setPassphrase("test_password",
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
@@ -45,7 +45,8 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
|
||||
.setWpa2Passphrase("test_password").build();
|
||||
.setPassphrase("test_password",
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
@@ -84,7 +85,7 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
|
||||
// test open tether network
|
||||
SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig)
|
||||
.setWpa2Passphrase(null).build();
|
||||
.setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getSecurityType()).isEqualTo(
|
||||
@@ -93,7 +94,8 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
|
||||
// test WPA2-Personal tether network
|
||||
SoftApConfiguration config2 = new SoftApConfiguration.Builder(mConfig)
|
||||
.setWpa2Passphrase("test_password").build();
|
||||
.setPassphrase("test_password",
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
|
||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(config2);
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getSecurityType()).isEqualTo(
|
||||
|
Reference in New Issue
Block a user